Quantcast
Channel: Nullable Foreign Key bad practice? - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by Stephen S. for Nullable Foreign Key bad practice?

$
0
0

You could always add an artificial row to your Customer table, something like Id=-1 and CustomerName = 'Unknown' and then in cases when you would normally set your CustomerId in Order NULL set it to -1.

This allows you to have no nullable FKs but still represent the lack of data appropriately (and will save you from downstream users not knowing how to deal with NULLs).


Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>