Re: How to create unique constraint on NULL columns

From: ptjm(at)interlog(dot)com (Patrick TJ McPhee)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to create unique constraint on NULL columns
Date: 2005-07-16 20:54:22
Message-ID: 3jtafuF4p8u1U1@uni-berlin.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <db8s6o$f36$1(at)news(dot)hub(dot)org>, Andrus <eetasoft(at)online(dot)ee> wrote:
% > Then redesign this as a many to many relation. That way someone can
% > have access to one, two, three, four, or all departments.
%
% This means adding separate row for each department into permission table.
% If new department is added, I must determine in some way users which are
% allowed access to all
% departments and add nw rows to permission table automatically.
%
% It seems more reasonable to use NULL department value as "do'nt know, all
% departments allowed"

But wouldn't you want to have an entry in the department table with
NULL for the department ID? I mean, why should NULL act like NULL wrt
foreign keys, but not wrt unique constraints?

--

Patrick TJ McPhee
North York Canada
ptjm(at)interlog(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Garrett Kalleberg 2005-07-16 21:39:59 foreign key constraints and inheritence
Previous Message Peter Eisentraut 2005-07-16 19:43:09 Re: encoding and locale