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.


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


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