| От | Tom Lane |
|---|---|
| Тема | Re: One or Both Foregin Keys |
| Дата | |
| Msg-id | 8831.1083374025@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | One or Both Foregin Keys (Dennis Gearon <gearond@fireserve.net>) |
| Ответы |
1 foreign key to 2 different tables?
|
| Список | pgsql-general |
Dennis Gearon <gearond@fireserve.net> writes:
> I am working on a design where a location for something can have:
> Fully qualified address with even building names, room numbers, and
> booth numbers.
> **-OR-**
> GPS location
> **-OR-**
> Both
> Other than triggers, is there a way to enforce this using tables and
> primary keys?
Put foreign key constraints on the address and GPS loc (so that they
must be either valid or NULL) and then add a CHECK constraint saying
they can't both be NULL.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера