| От | Prokopis Prokopidis |
|---|---|
| Тема | Multiple foreign keys |
| Дата | |
| Msg-id | 3E30F86E.6050103@ilsp.gr обсуждение исходный текст |
| Ответы |
Re: Multiple foreign keys
|
| Список | pgsql-novice |
Hi, I've just started playing with SQL and postgres, and I have a question about multiple foreign keys. Let's say we have three tables "student", "teacher" and "staff", plus a table "comment" with attributes like "date" and "text". We want zero or N comments to be associated with each row of the other three tables. I was thinking of creating three foreign keys in the "comment" table, say "fk_student", "fk_teacher" and "fk_staff". Now, is there a way to impose a constraint that a comment row must have one and only one NOT NULL fk value? If this is not the correct way to solve the problem, what alternative solutions are there? Best, P.
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера