Re: foreign key references two different table?

From: Maximus <qweqwe_at_qwqwewq.com>
Date: Sat, 31 May 2003 07:42:37 GMT
Message-ID: <N1ZBa.100066$ro6.2861901_at_news2.calgary.shaw.ca>


"Susan Lam" <susana73_at_hotmail.com> wrote in message news:7186ed56.0305301413.50ce90f7_at_posting.google.com...
> I have 3 tables.
>
> parent1 (id, ...)
> parent2 (id, ...)
> child (id, memberid, type)
>
> child.memberid came from parent1.id and parent2.id. child.type
> distinguishs where the memberid are from parent1 or parent2 table.
>
> I would like to have a fk relationship between child.memberid ->
> parent1.id and parent2.id. However, I can't create two separate fks
> because parent1.id and parent2.id together are not unique.
>
> Is there a way to create one fk to two different tables?

It would make more sense to put a fk for the child in the parent tables:

parent1(id,child_id,...)
parent2(id,child_id,...)
child(id,...)

Just my two bits worth ;) Received on Sat May 31 2003 - 09:42:37 CEST

Original text of this message