Chris Whisenhunt
Chris Whisenhunt

Reputation: 351

Multiple foreign key constraints on a single column in SQL Server 2008

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!

Upvotes: 3

Views: 1228

Answers (1)

HLGEM
HLGEM

Reputation: 96658

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.

Upvotes: 6

Related Questions