Any example of a necessary nullable foreign key?

后端 未结 8 1660
感情败类
感情败类 2020-12-03 01:42
Customers
 customer_id

Orders
 order_id
 customer_id fk

If I have two tables and define a foreign key on customer_id in the Orders table, by allow

相关标签:
8条回答
  • 2020-12-03 02:20

    We have lots of these things as our application is something that starts with some basic information for an event and over time, as the event is more fully planned, more information is added. But when the information is added we want to make sure it meets the FK constraint. FKs are for data integrity but all data is not always known at the time the initial data is inserted, so nulls are allowed.

    0 讨论(0)
  • 2020-12-03 02:21

    To set a foreign key nullable or null use below sql script

    ALTER TABLE Return_COMMENTS MODIFY order_ID Number NULL;
    
    0 讨论(0)
提交回复
热议问题