Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Quick question re foreign keys.



On Wed, 24 Oct 2007 09:43:10 +0200
Nis Jørgensen <nis(at)superlativ(dot)dk> wrote:
> Well, I have a couple of times had the "need" to have a primary
> key/uniqueness constraint with one column nullable (indicating "Not
> Applicable"). The "problem" is that we have only one NULL, which for
> comparison purposes is interpreted as "Not Known".

Of course.  Happens all the time.  However, UNIQUE and PRIMARY are not
the same thing.  PRIMARY implies that the column uniquely and
definitively identifies the row.  If you have NULLs in the column than
it does not meet the criteria.  Here are the rules for primary key
taken from http://articles.techrepublic.com.com/5100-22-1045050.html.

 - The primary key must uniquely identify each record.
 - A record?s primary-key value can?t be null.
 - The primary key-value must exist when the record is created.
 - The primary key must remain stable?you can?t change the primary-key field(s). 
 - The primary key must be compact and contain the fewest possible attributes. 
 - The primary-key value can?t be changed.

-- 
D'Arcy J.M. Cain <darcy(at)druid(dot)net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group