Nullable Foreign Key bad practice?

前端 未结 11 869
猫巷女王i
猫巷女王i 2020-11-28 03:51

Let\'s say you have a table Orders with a foreign key to a Customer Id. Now, suppose you want to add an Order without a Customer Id, (whether that should be possible is anot

11条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 04:23

    Yes theres something wrong. Its not a foreign key if its nullable. Its database design by code. Maybe you make a zero link to unassigned. or "Unassigned" if your using a character col. Keep the integrity of your data 100%.

提交回复
热议问题