X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DBA68474E5C for ; Wed, 12 Feb 2003 17:37:40 -0500 (EST) Received: from pd5mo3so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by postgresql.org (Postfix) with ESMTP id 51717474E44 for ; Wed, 12 Feb 2003 17:37:40 -0500 (EST) Received: from pd4mr3so.prod.shaw.ca (pd4mr3so-qfe3.prod.shaw.ca [10.0.141.214]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0HA7009J6W6KR5@l-daemon> for pgsql-sql@postgresql.org; Wed, 12 Feb 2003 15:37:32 -0700 (MST) Received: from pn2ml9so.prod.shaw.ca (pn2ml9so-qfe0.prod.shaw.ca [10.0.121.7]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.6 (built Apr 26 2002)) with ESMTP id <0HA700026W6KP3@l-daemon> for pgsql-sql@postgresql.org; Wed, 12 Feb 2003 15:37:32 -0700 (MST) Received: from kimiko (h24-78-132-76.vc.shawcable.net [24.78.132.76]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with SMTP id <0HA70076FW6JJ2@l-daemon> for pgsql-sql@postgresql.org; Wed, 12 Feb 2003 15:37:32 -0700 (MST) Date: Wed, 12 Feb 2003 14:35:07 -0800 From: Vernon Wu Subject: Re: null foreign key column In-reply-to: To: pgsql-sql@postgresql.org, Dmitry Tkach Reply-To: vernonw@gatewaytech.com Message-id: MIME-version: 1.0 X-Mailer: Opera 6.05 build 1140 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Priority: 3 (Normal) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/266 X-Sequence-Number: 11664 12/02/2003 2:24:49 PM, Dmitry Tkach wrote: >You don't want it to be serial - just make it 'person_id in' Any reasons? > >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 >> ------=_NextPart_000_0005_01C2D1EE.61998D70 >> Content-Type: text/html; >> charset="iso-8859-1" >> Content-Transfer-Encoding: quoted-printable >> >> >> >> >> >> >> >> >>
Hi all,
>>
 
>>
I would like to have a foreign key column = >> in my=20 >> table which allows null value also.
>>
But the below create table sql command doe= >> sn't=20 >> accept null value for person_id.
>>
How to do in postgres?
>>
= >>  
>>
create table event
(
  &nb= >> sp;=20 >> event_id           &= >> nbsp;  =20 >> serial           &nb= >> sp;   =20 >> not null,
    event_description    &n= >> bsp;=20 >> char(255)           = >>          =20 >> ,
   =20 >> person_id           = >>   =20 >> serial           &nb= >> sp;           =20 >> ,
    primary key (event_id),
    forei= >> gn=20 >> key  (person_id)
       references pe= >> rson=20 >> (person_id)
);
>>
 
>>
regards
>>
Jai
>> >> ------=_NextPart_000_0005_01C2D1EE.61998D70-- >> > > >---------------------------(end of broadcast)--------------------------- >TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >