pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
multiple primary keys and reference
3+ messages / 3 participants
[nested] [flat]

* multiple primary keys and reference
@ 2002-06-07 20:00 Matt <matthew.berardi@weilpublishing.com>
  2002-06-10 14:40 ` Re: multiple primary keys and reference Achilleus Mantzios <achill@matrix.gatewaynet.com>
  2002-06-10 15:58 ` Re: multiple primary keys and reference Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Matt @ 2002-06-07 20:00 UTC (permalink / raw)
  To: pgsql-sql

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

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

matthew berardi
weil publishing




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: multiple primary keys and reference
  2002-06-07 20:00 multiple primary keys and reference Matt <matthew.berardi@weilpublishing.com>
@ 2002-06-10 14:40 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Achilleus Mantzios @ 2002-06-10 14:40 UTC (permalink / raw)
  To: Matt <matthew.berardi@weilpublishing.com>; +Cc: pgsql-sql


CREATE TABLE Parts(
PartNo varchar(20) NOT NULL,
machtypesid int4 NOT NULL,
BestPrice decimal(100,2),
Comment text,
PRIMARY KEY (PartNo,machtypesid));

CREATE TABLE MachDefs(
defid serial NOT NULL UNIQUE PRIMARY KEY,
Description text,
PartNo varchar(20),
MachTypeID int4 NOT NULL,
FOREIGN KEY (PartNo,MachTypeID) REFERENCES Parts (PartNo,machtypesid));

-- 
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
tel:    +30-10-8981112
fax:    +30-10-8981877
email:  achill@matrix.gatewaynet.com
        mantzios@softlab.ece.ntua.gr




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: multiple primary keys and reference
  2002-06-07 20:00 multiple primary keys and reference Matt <matthew.berardi@weilpublishing.com>
@ 2002-06-10 15:58 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2002-06-10 15:58 UTC (permalink / raw)
  To: Matt <matthew.berardi@weilpublishing.com>; +Cc: 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);





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2002-06-10 15:58 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-07 20:00 multiple primary keys and reference Matt <matthew.berardi@weilpublishing.com>
2002-06-10 14:40 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2002-06-10 15:58 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

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