Re: Foreign keys: referencing a REFERENCES doesn7t work?
От
Tom Lane
Тема
Re: Foreign keys: referencing a REFERENCES doesn7t work?
Дата
Msg-id
20607.1028556876@sss.pgh.pa.us
Ответ на
Foreign keys: referencing a REFERENCES doesn7t work? (Jean-Christian Imbeault)
Список
Дерево обсуждения
Foreign keys: referencing a REFERENCES doesn7t work? Jean-Christian Imbeault <jc@mega-bucks.co.jp>
Re: Foreign keys: referencing a REFERENCES doesn7t work? Christian Ullrich <chris@chrullrich.de>
Re: Foreign keys: referencing a REFERENCES doesn7t work? Tom Lane <tgl@sss.pgh.pa.us>
Jean-Christian Imbeault 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 по дате отправления