Re: Reference to multiple cols

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Reference to multiple cols
Дата
Msg-id 20030112005121.GA13716@wolff.to
обсуждение исходный текст
Ответ на Re: Reference to multiple cols  ("Josh Berkus" <josh@agliodbs.com>)
Ответы ERROR: NEW used in non-rule query  ("Rod Kreisler" <rod@23net.net>)
Список pgsql-novice
On Sat, Jan 11, 2003 at 14:00:14 -0800,
  Josh Berkus <josh@agliodbs.com> wrote:
>
> This should give you a system in which animal_id is the primary key for
> each table, and therefore there is a one-for-one relationship between
> the animal table and each of the dog and cat tables, and would prevent
> you from deleting a referenced record from the animal table.
>
> You would need an additional trigger to prevent duplication *between*
> the dog and cat tables.

There is a way to do this without triggers. You add an animal type
field to all of the tables. The foreign keys then should use both animal id
and animal type (which means you need to make animal_id and animal_type
a combined unique key on the animal table). You add a constraint to the animal
specific tables forcing the animal type to be the appropiate type.

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

Предыдущее
От: "Ville Jungman"
Дата:
Сообщение: Re: Reference to multiple cols
Следующее
От: "Rod Kreisler"
Дата:
Сообщение: ERROR: NEW used in non-rule query