Re: Referencing multiple primary keys from a single table.
От | Bruno LEVEQUE |
---|---|
Тема | Re: Referencing multiple primary keys from a single table. |
Дата | |
Msg-id | bkoplu$1mr7$1@news.hub.org обсуждение исходный текст |
Ответ на | Referencing multiple primary keys from a single table. (Daniel Staal <DStaal@usa.net>) |
Список | pgsql-novice |
Why do you not use a sequence number like index ? Something like : create table tale1 { seque serial, field1, field2, field3, ... primary key (field1, field2, field3) ) create tabla table2 { field4, ... seque integer, ...) with table1.seque = table2.seque Bruno Daniel Staal wrote: > > What is the best way to reference (use as foreign key) a table with > multiple primary keys? > > Here's what I have: > Table1: > field1 > field2 > field3 > ... > primary key (field1, field2, field3) > > Then I have another table that needs to reference Table1 with a > foreign key. What I really want to do is: > Table2: > field1 Primary key > field2 references table1 > ... > > But that doesn't work. I haven't yet tried the option of giving > Table2 all three fields of Table1, partly because I'm not really sure > how to write that... (I did try linking it to the implicit field > generated when I created Table1. Didn't work.) The option I'm sure > would work is shoving all three key fields of Table1 into one field, > but that's a bit messy with the data. (Though it is doable.) > > Is there any really good way to do this that I'm just missing? > > Daniel T. Staal > > --------------------------------------------------------------- > This email copyright the author. Unless otherwise noted, you > are expressly allowed to retransmit, quote, or otherwise use > the contents for non-commercial purposes. This copyright will > expire 5 years after the author's death, or in 30 years, > whichever is longer, unless such a period is in excess of > local copyright law. > --------------------------------------------------------------- > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- Bruno LEVEQUE System Engineer SARL NET6D bruno.leveque@net6d.com http://www.net6d.com
В списке pgsql-novice по дате отправления: