Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 63196476194 for ; Thu, 12 Dec 2002 03:52:03 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id C535E476138 for ; Thu, 12 Dec 2002 03:52:02 -0500 (EST) Received: from klaster.net (pi210.krakow.cvx.ppp.tpnet.pl [217.99.209.210]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 8092B2B266; Thu, 12 Dec 2002 09:36:48 +0100 (CET) Message-ID: <3DF84EC1.2020506@klaster.net> Date: Thu, 12 Dec 2002 09:54:25 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Huub Cc: pgsql-sql@postgresql.org Subject: Re: primary + foreign key References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/148 X-Sequence-Number: 10736 Huub wrote: > Hi, > > I want to create a table where the 2 columns are both primary as well as > foreign key. What is the correct syntax for that? > > Thanks > > Huub create table detail ( id1 integer, id2 integer, CONSTRAINT c1 PRIMARY KEY(id1,id2), CONSTRAINT c2 FOREIGN KEY(id1,id2) REFERENCES master ); Do you really need such detail table? You can just add columns to master table. Tomasz Myrta