I have two tables TableA and TableB. Now TableA has 2 columns: ID & Name, TableB has 3 columns: ID, Name, & TableAID. Now there is a foreign key constraint from TableA.ID = TableB.TableAID. I need to be able to allow for TableB.TableAID to either use values from TableA.ID or TableB.ID, hence multiple foreign key constraints on a single column and I need it to allow either or. Thanks!
-
Can you use a NULL in TableB.TableAID as an indication that you should use TableB.ID? That would mean that the TableB.ID you want to stick in there would be the one on the record already which probably is not the case...DKnight– DKnight2011-04-12 15:02:42 +00:00Commented Apr 12, 2011 at 15:02
Add a comment
|
1 Answer
That is a clear sign of a bad design. You should never need to do this and if you do then you need to rethink your design.
You cannot make a field be associated with two different FKs.
1 Comment
Chris Whisenhunt
Yeah I can only add constraints to these tables, I can't change the design of the tables or remove any constraints. :(