Re: primary + foreign key

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Huub <v(dot)niekerk(at)freeler(dot)nl>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: primary + foreign key
Date: 2002-12-12 08:54:25
Message-ID: 3DF84EC1.2020506@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Huub 2002-12-12 09:02:28 Re: primary + foreign key
Previous Message Tomasz Myrta 2002-12-12 08:34:53 Re: Getting the latest unique items