Oracle optional relationship

2019-06-18 22:42发布

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条回答
女痞
2楼-- · 2019-06-18 23:18

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.

查看更多
登录 后发表回答