Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: foreign key references two different table?

Re: foreign key references two different table?

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Fri, 30 May 2003 15:56:44 -0700
Message-ID: <3ED7E1AC.3A2C5F05@exxesolutions.com>


Susan Lam wrote:

> 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?
>
> Thanks.
> Susan

There is no way to do it and based on your posting your design is the problem. Please explain why you have two parent tables and how you expect them to work.

The proper solution is almost undoubtedly a single parent table foreign keyed to parent attributes as well as to the child table.

PS: If this is your class final or homework, and it certainly seems that way, expect hints ... not answers. We only do other people's classwork when we get the certificate.

--
Daniel Morgan
http://www.outreach.washington.edu/extinfo/certprog/oad/oad_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Fri May 30 2003 - 17:56:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US