1 foreign key to 2 different tables?

Поиск
Список
Период
Сортировка
От Ryan Riehle
Тема 1 foreign key to 2 different tables?
Дата
Msg-id 000001c42fad$5350abe0$0302a8c0@buildways
обсуждение исходный текст
Ответ на Re: One or Both Foregin Keys  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: 1 foreign key to 2 different tables?  (Jean-Luc Lachance <jllachan@sympatico.ca>)
Re: 1 foreign key to 2 different tables?  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
Hi,

I have a key structure like so:

 a                c              b
+----------+    +---------+    +----------+
| PriKey1  |--->| ForKey  |<---| PriKey2  |
|          |    | Flag    |    |          |
+----------+    +---------+    +----------+

...where c.ForKey is a value from PriKey1 OR PriKey2, which are different
values.  All fields have the same data type; a.PriKey1 and b.PriKey2 are
sequences. How does one enfore referential integrity in this structure so
that c.ForKey references a.PriKeya when Flag is True or references b.PriKey2
when Flag is False? Looked pretty hard through the lists and on Google last
night with no luck :(

  -Ryan Riehle
   http://www.buildways.com

KEYWORDS: one foreign key, multiple primary keys, multiple tables,
generalization, superclass, subclass, constraint


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

Предыдущее
От: victor
Дата:
Сообщение: users rights per table
Следующее
От: Mike Nolan
Дата:
Сообщение: Re: users rights per table