| От | Bruno Wolff III |
|---|---|
| Тема | Re: Creating a foreign key on the Union of two tables |
| Дата | |
| Msg-id | 20030407165030.GA17741@wolff.to обсуждение исходный текст |
| Ответ на | Creating a foreign key on the Union of two tables (saads@umich.edu (Saad Saeed)) |
| Список | pgsql-sql |
On Sun, Apr 06, 2003 at 14:53:50 -0700, Saad Saeed <saads@umich.edu> wrote: > I have 2 tables "A" and "B" in mySQL. They both have an attribute 'id' > which is unique between the 2 tables. I want the union of these 2 > attributes to be a foreign key in a 3rd table "C". How do I specify > this constraing in sql (mySQL) in table C? And for complex reasons I > cannot merge the 2 tables A and B. One way to do this is to have two foreign key references from C. One to A and the other to B. To make sure just one of these is used, you can use a constraint in C to make sure exactly one of the columns is null. This technique doesn't need for the IDs in A and B to be unique accross both tables.
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера