From: Bruno Wolff III <bruno@wolff.to>
To: Arunachalam Jaisankar <jsankar@xtra.co.nz>
Cc: pgsql-sql@postgresql.org
Subject: Re: null foreign key column
Date: Wed, 12 Feb 2003 14:41:09 -0600
Message-ID: <20030212204109.GB30483@wolff.to> (raw)
In-Reply-To: <000801c2d181$6c0be360$020000c0@singlarc01>
References: <000801c2d181$6c0be360$020000c0@singlarc01>
On Tue, Feb 11, 2003 at 16:55:28 +1300,
Arunachalam Jaisankar <jsankar@xtra.co.nz> wrote:
> Hi all,
>
> I would like to have a foreign key column in my table which allows null value also.
> But the below create table sql command doesn't accept null value for person_id.
> How to do in postgres?
>
> create table event
> (
> event_id serial not null,
> event_description char(255) ,
> person_id serial ,
> primary key (event_id),
> foreign key (person_id)
> references person (person_id)
> );
I don't think you want to use serial type for a value that references
another table. Use integer instead. Serial also implies not null which
is why you couldn't stick null values into that field.
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: bruno@wolff.to, jsankar@xtra.co.nz
Subject: Re: null foreign key column
In-Reply-To: <20030212204109.GB30483@wolff.to>
* 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