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 <jc@mega-bucks.co.jp>)
Список 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 по дате отправления:

Предыдущее
От: Jakub Ouhrabka
Дата:
Сообщение: Re: Memory usage / concept
Следующее
От: Tom Lane
Дата:
Сообщение: Re: O'Reilly Open Source Convention Report