In SQL, is there a way to enforce that only one column out of a group of columns has a value, and the others are null? Maybe a constraint or trigger? This type of thing might be for a lookup table, but are there any alternate table designs that might accomplish this better?
For example:
ID OtherTable1ID OtherTable2ID OtherTable3ID
-----------------------------------------------------
1 23 NULL NULL
2 NULL 45 NULL
3 33 55 NULL -- NOT ALLOWED
The main issue is that these columns are all FKs to other tables, so I can't collapse them down to a single column.
I'm using SQL Server, but any answer will do.