pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D'Arcy J.M. Cain <darcy@druid.net>
To: Nis Jørgensen <nis@superlativ.dk>
Cc: pgsql-sql@postgresql.org, Paul Lambert <paul.lambert@autoledgers.com.au>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: Quick question re foreign keys.
Date: Wed, 24 Oct 2007 10:53:43 -0400
Message-ID: <20071024105343.582fb4e0.darcy@druid.net> (raw)
In-Reply-To: <471EF78E.8050503@superlativ.dk>
References: <471EA7D5.9040403@autoledgers.com.au>
	<21715.1193193880@sss.pgh.pa.us>
	<471EB55F.5050600@autoledgers.com.au>
	<20071024012705.5f253946.darcy@druid.net>
	<471EF78E.8050503@superlativ.dk>

On Wed, 24 Oct 2007 09:43:10 +0200
Nis Jørgensen <nis@superlativ.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@druid.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.



view thread (9+ messages)

Message-ID: <20071024105343.582fb4e0.darcy@druid.net>
Permalink:  ../20071024105343.582fb4e0.darcy@druid.net/
Also on:    postgresql.org/message-id/20071024105343.582fb4e0.darcy@druid.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: darcy@druid.net, nis@superlativ.dk, paul.lambert@autoledgers.com.au, tgl@sss.pgh.pa.us
  Subject: Re: Quick question re foreign keys.
  In-Reply-To: <20071024105343.582fb4e0.darcy@druid.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox