Re: multiple primary keys and reference

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Matt <matthew(dot)berardi(at)weilpublishing(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: multiple primary keys and reference
Date: 2002-06-10 15:58:00
Message-ID: 20020610085457.L67911-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 7 Jun 2002, Matt wrote:

> I have a table, OrderDetail, with two primary keys OrderID and ProductID

I assume you mean it has a primary key with two columns.
>
> I want another table, Claims, to reference the primary keys of
> OrderDetail so that the pair has to match between table not just one
> attrib. I can't figure out how to do this from the docs I have. can
> anyone help? thankyou in advance

If I understand what you want, use the table constraint form of foreign
keys:

create table a (a int, b int, primary key(a,b));
create table b (a int, b int, foreign key(a,b) references a);

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2002-06-10 16:10:42 Re: [SQL] VIEWs and FOREIGN keys
Previous Message Achilleus Mantzios 2002-06-10 14:40:20 Re: multiple primary keys and reference