pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Elphick <olly@lfix.co.uk>
To: Terrence Brannon <metaperl@mac.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: how could a foreign key ever be NULL?
Date: 17 Dec 2001 17:24:07 +0000
Message-ID: <1008609847.2808.2.camel@linda> (raw)
In-Reply-To: <8BBB36A0-F2E2-11D5-92F7-003065C2A10C@mac.com>
References: <8BBB36A0-F2E2-11D5-92F7-003065C2A10C@mac.com>

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.Elphick@lfix.co.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 

view thread (4+ messages)  latest in thread

Message-ID: <1008609847.2808.2.camel@linda>
Permalink:  ../1008609847.2808.2.camel@linda/
Also on:    postgresql.org/message-id/1008609847.2808.2.camel@linda

 · 

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: olly@lfix.co.uk, metaperl@mac.com
  Subject: Re: how could a foreign key ever be NULL?
  In-Reply-To: <1008609847.2808.2.camel@linda>

* 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