Re: Foreign keys: referencing a REFERENCES doesn7t work?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Foreign keys: referencing a REFERENCES doesn7t work?
Date: 2002-08-05 14:14:36
Message-ID: 20607.1028556876@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> writes:
> Seems that pgsql is fine when MOVIES.id references PRODUCTS.id for a
> foreign key but if a table references MOVIES.prod_id for a foreign key
> pgsql cannot go up the reference "tree" and follow what MOVIES.id
> references to see that there really is a unique constraint ...

No, there isn't a unique constraint. Your REFERENCES clause says that
every ID in MOVIES must equal some ID in PRODUCTS; it does *not* say
that two different rows in MOVIES can't reference the same ID in
PRODUCTS. Add a UNIQUE constraint to MOVIES if that's the behavior you
want.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-08-05 14:20:27 Re: O'Reilly Open Source Convention Report
Previous Message Jakub Ouhrabka 2002-08-05 14:07:36 Re: Memory usage / concept