Re: Foreign keys question (performance)

Поиск
Список
Период
Сортировка
От Phoenix Kiula
Тема Re: Foreign keys question (performance)
Дата
Msg-id CAFWfU=tNz63sZQf=LJJWjzqrDJx6rx=8XkOuJSj8rVZ6FRcRYg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Foreign keys question (performance)  (Alban Hertroys <haramrae@gmail.com>)
Ответы Re: Foreign keys question (performance)
Список pgsql-general
On Sun, Dec 4, 2011 at 7:14 PM, Alban Hertroys <haramrae@gmail.com> wrote:
> On 4 Dec 2011, at 11:19, Phoenix Kiula wrote:
....

>
> INSERTs in the parent table don't need to check for any reference from the child table, since they're new; there
can'tbe a reference. UPDATEs and DELETEs do though, whether you let them CASCADE or not. If you don't, then the
databaseraises a foreign key constraint violation. If you do, then it needs to modify the relevant rows in the child
table.
>
> Likewise, INSERTs and UPDATEs in the child table need to verify that - if their reference key changed - they're still
referencinga valid row. 



Thanks Albert. Very useful.

I had ON DELETE...ALSO DELETE rules earlier and in some cases they let
some keys go by in associated tables. Hope foreign key constraint is
more reliable!

PK

В списке pgsql-general по дате отправления:

Предыдущее
От: Phoenix Kiula
Дата:
Сообщение: Weird behavior: deleted row still in index?
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: Weird behavior: deleted row still in index?