Subject RE: [firebird-support] Foreign Key on 2 or more columns
Author Svein Erling Tysvær
I assume you mean that TableA.ID_Contact may either be pointing to ContactA.ID_Contact or ContactB.ID_Contact. If so, I suppose you could have triggers that populated a table 'ContactAB' with values that were in those tables (and don't forget UPDATE/DELETE triggers if appropriate), and then have a foreign key pointing to this table. Though I've never done anything like this.

A stored procedure could have problems with you in one transaction deleting a record from ContactA or ContactB at the same time as you in another transaction inserted into TableA - probably both transactions would succeed with the result that TableA contained a record not in either of the other tables.

HTH,
Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of svanderclock
Sent: 23. september 2009 14:59
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Foreign Key on 2 or more columns

hello,

in tableA i have some record with the field ID_contact that point to the table ContactA or to the table ContactB. so in this way i can not create a foreign key on my field ID_Contact.

How to do ? i thing by stored procedure, but what is the best way and the most efficient way to do that in store procedure ?

thanks you by advance

--
stephane

http://www.arkadia.com/usa/real-estate/for-sale/france/ile-de-france/paris/listings/
http://www.arkadia.com/fra/immobilier/vente/france/ile-de-france/paris/annonces/
http://www.arkadia.com/rus/real-estate/for-sale/france/ile-de-france/paris/listings/