pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@klaster.net>
To: Huub <v.niekerk@freeler.nl>
Cc: pgsql-sql@postgresql.org
Subject: Re: primary + foreign key
Date: Thu, 12 Dec 2002 09:54:25 +0100
Message-ID: <3DF84EC1.2020506@klaster.net> (raw)
In-Reply-To: <at9hdh$1jid$1@news.hub.org>
References: <at9hdh$1jid$1@news.hub.org>

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




view thread (7+ messages)  latest in thread

Message-ID: <3DF84EC1.2020506@klaster.net>
Permalink:  ../3DF84EC1.2020506@klaster.net/
Also on:    postgresql.org/message-id/3DF84EC1.2020506@klaster.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasiek@klaster.net, v.niekerk@freeler.nl
  Subject: Re: primary + foreign key
  In-Reply-To: <3DF84EC1.2020506@klaster.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox