Here is my situation. I have a table where the value of a column can be NULL, 0, or a value from anther table. The other table does not have a 0 value for any rows.
What is my best option?
1) Don’t add the FK.
2) add a 0 record to the foreign table.
3) something else.
I can’t change the 0 value to a null. and the 0 represents a valid value.
Thanks for the help.
If 0 is a valid value, I would personally add 0 as a record of the “foreign table”.
Or 3) use a CHECK CONSTRAINT instead of a FOREIGN KEY.
But the answer can’t be 1) or 2) or 3) as a “best practice generic answer” : it depends on your needs (what must happen when something, related to your table, is deleted in the foreign table is one of the most important thing to consider).
Weakness of check constraints :
http://msdn.microsoft.com/en-us/library/ms188258(v=sql.105).aspx