From: | Bruno LEVEQUE <bruno(dot)leveque(at)libertysurf(dot)fr> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Referencing multiple primary keys from a single table. |
Date: | 2003-09-23 06:36:58 |
Message-ID: | bkoplu$1mr7$1@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)leveque(at)net6d(dot)com
http://www.net6d.com
From | Date | Subject | |
---|---|---|---|
Next Message | Glenn_Wiens | 2003-09-23 14:05:09 | Is there an equivalent in plpgsql of Oracle's DBMS_OUTPUT.PUT_LINE? |
Previous Message | Noel | 2003-09-23 00:55:47 | Re: Replication |