Multiple foreign keys

Поиск
Список
Период
Сортировка
От 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Long time Vacuum full
Следующее
От: Rory Campbell-Lange
Дата:
Сообщение: Re: Learning Plpgsql ??