Oracle optional relationship

扶醉桌前 提交于 2019-12-10 13:20:03

问题


What is the proper way to define an oracle table who has an optional foreign key relationship with another table? For instance, some employee records have defined the country they are from (a FK from countries table), and some have not.


回答1:


Just allow the column to be nullable (don't make it NOT NULL) and create your foreign key as normal. The database will enforce the foreign key for any rows that contain a value in that row, but nothing will be enforced if the row is null.



来源:https://stackoverflow.com/questions/1190446/oracle-optional-relationship

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!