Re: primary + foreign key - Mailing list pgsql-sql

From Tomasz Myrta
Subject Re: primary + foreign key
Date
Msg-id 3DF84EC1.2020506@klaster.net
Whole thread Raw
In response to primary + foreign key  (Huub <v.niekerk@freeler.nl>)
Responses Re: primary + foreign key  (Huub <v.niekerk@freeler.nl>)
Re: primary + foreign key  (Tomasz Myrta <jasiek@klaster.net>)
List pgsql-sql
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



pgsql-sql by date:

Previous
From: Tomasz Myrta
Date:
Subject: Re: Getting the latest unique items
Next
From: Huub
Date:
Subject: Re: primary + foreign key