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 -> Foriegn Key Question

Foriegn Key Question

From: Wally <wallyraju_at_gmail.com>
Date: 11 Aug 2006 07:21:17 -0700
Message-ID: <1155306077.832063.276330@m73g2000cwd.googlegroups.com>


All,

Database Version: 10.2.0.1
OS: XP Pro

I have a question about Foriegn Keys. Forgive me if this has been answered before.

I have three tables which are

subject with primary_key subject_id (VARCHAR2(10)), contact with primary_key contact_id (VARCHAR2(10)), &
address with primary_key address_id (VARCHAR2(10))

The address table has another column called owner_id (VARCHAR2(10)) where the owner_id could be the subject_id or the contact_id, because either the subject or the contact could have an address. Currently the constraint is being maintained through pl/sql code.

I know that I can have one foriegn key where the address.owner_id is linked to the subject.subject_id, or one foriegn key where the address.owner_id is linked to the contact.contact_id, but not both. Please correct me if I am wrong.

This will not work since the owner_id can be either the subject_id or the contact_id.

Is there a way other than a database trigger or pl/sql code where I can define the above relationship in the database.

Thanks for your help. Received on Fri Aug 11 2006 - 09:21:17 CDT

Original text of this message

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