Re: how could a foreign key ever be NULL?

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Terrence Brannon <metaperl(at)mac(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: how could a foreign key ever be NULL?
Date: 2001-12-17 17:24:07
Message-ID: 1008609847.2808.2.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 2001-12-17 at 11:38, Terrence Brannon wrote:
> The Momjian book states:
>
> A single-column foreign key is either NULL or matches a primary key
>
> But the problem I have with this statement is that a primary key
> cannot be null or duplicate. And since the foreign key references
> a value that is neither null or duplicate, how could it ever be
> NULL?

If the foreign key is NULL, it doesn't reference anything. If this is
not a valid condition, the column should be declared as NOT NULL.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C

"For I say, through the grace given unto me, to every
man that is among you: Do not think of yourself more
highly than you ought, but rather think of yourself
with sober judgement, in accordance with the measure
of faith God has given you." Romans 12:3

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-12-17 20:15:20 Re: how could a foreign key ever be NULL?
Previous Message Bruce Momjian 2001-12-17 17:06:10 Re: how could a foreign key ever be NULL?