Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Foriegn Key Question
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