且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何跨多个表将外键引用到主键?

更新时间:2023-01-29 09:22:12

问题来自于你将人分成两部分这一事实单独的表格。



所以不要单独的医生护士 table,用一个 Person 表替换它们,并添加一个列,用于标识该人是医生还是护士。



所以这个人可能像

The problem comes from the fact that you have split the persons into two separate tables.

So instead of having separate Doctor and Nurse table, replace them with a single Person table and add a column which identifies if the person is a doctor or a nurse.

So the person could be something like
Person
------
- PersonCode
- PersonType (e.g. 1=doctor, 2=nurse)
- Name
- ...





外键参考会计中的nce现在只指向人员表。



The foreign key reference in Accounting would now point only to person table.