Re: Foreign keys: referencing a REFERENCES doesn7t work? - Mailing list pgsql-general

From Tom Lane
Subject Re: Foreign keys: referencing a REFERENCES doesn7t work?
Date
Msg-id 20607.1028556876@sss.pgh.pa.us
Whole thread Raw
In response to Foreign keys: referencing a REFERENCES doesn7t work?  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
Jean-Christian Imbeault <jc@mega-bucks.co.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

pgsql-general by date:

Previous
From: Jakub Ouhrabka
Date:
Subject: Re: Memory usage / concept
Next
From: Tom Lane
Date:
Subject: Re: O'Reilly Open Source Convention Report