Re: null foreign key column - Mailing list pgsql-sql

From Wei Weng
Subject Re: null foreign key column
Date
Msg-id Pine.LNX.4.44.0302121802350.14220-100000@localhost.localdomain
Whole thread Raw
In response to Re: null foreign key column  (Vernon Wu <vernonw@gatewaytech.com>)
List pgsql-sql
On Wed, 12 Feb 2003, Vernon Wu wrote:

> 
> 12/02/2003 2:24:49 PM, Dmitry Tkach <dmitry@openratings.com> wrote:
> 
> >You don't want it to be serial - just make it 'person_id in'
> 
> Any reasons?

serial is an auto-increment datatype. In your table, you probably want to 
control what person_id is, rather than letting them mindlessly 
auto-increment row after row, given it is a foreign key to a Person table.

> 
> >
> >I hope, it helps...
> >
> >Dima
> >
> >Arunachalam Jaisankar wrote:
> >> This is a multi-part message in MIME format.
> >> 
> >> ------=_NextPart_000_0005_01C2D1EE.61998D70
> >> Content-Type: text/plain;
> >>     charset="iso-8859-1"
> >> Content-Transfer-Encoding: quoted-printable
> >> 
> >> Hi all,
> >> 
> >> I would like to have a foreign key column in my table which allows null val=
> >> ue 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)
> >> );
> >> 
> >> regards
> >> Jai



pgsql-sql by date:

Previous
From: Dmitry Tkach
Date:
Subject: Re: null foreign key column
Next
From: Josh Berkus
Date:
Subject: Re: anal about my syntax