如果关系具有属性,如何实现一对一关系?
how to implement one to one relationship if the relation has attributes?
我的数据库中有两个 table,Department
和 Academic_staff
。 Department
table 中的主键是 depId
而 Academic_staff
table 中的主键是 aNo
.
每个系仅由一名教职员工管理,因此两者 table 之间的关系是一对一的。
我需要记录学术人员开始管理一个部门的日期,所以关系必须有它自己的属性(mStartDate
)。
如何实现这个新属性?
起初我想创建一个新的table,具有三个属性(depId
、aNo
、mStartDate
),并在新的[=之间建立两个关系34=]和其他两个table,但我后来意识到这不是多对多关系。
那么如何将属性 mStartDate
添加到两个 table 之间的一对一关系中?
There's more than one relation between the two tables, and some of those relations are one-to-many (the department employs more than one academic staff), so I can't merge the two tables.
部门
- depId
- fk_aNo(独一无二)
*****- 主键 (depId, fk_aNo)*****
学术资料
- a否(PK)
新表
- depId --- 重要"Both depId,aNo are from Departments, be sure"
- a否---
mStartDate
-主键(depId,aNo)
Constraints--> a academicStuff can't start to manage a department more
than one time. If this structure proper for you and you want to enable
a aacademic stuff manage a department more than one time inform me.
你提议的新table(我称之为DepartmentManagement)原则上可以记录每个部门的经理的历史,在这种情况下,它将是多对多(时间)关系在部门和学术之间。
但是,如果您只想记录当前经理,将 "absorb" DepartmentManager 放入部门 table 是合理的,在那里给出两列(Manager_aNo 和 Manager_StartDate).从概念上讲,对象 "DepartmentManagement" 仍然存在,但它被吸收了,它没有自己的 table.
你也可以在另一个方向(进入学术)吸收它,但这不允许一个学术部门管理多个部门。你现在可能不需要那个,但原则上它比一个部门有两个经理更有可能。
我的数据库中有两个 table,Department
和 Academic_staff
。 Department
table 中的主键是 depId
而 Academic_staff
table 中的主键是 aNo
.
每个系仅由一名教职员工管理,因此两者 table 之间的关系是一对一的。
我需要记录学术人员开始管理一个部门的日期,所以关系必须有它自己的属性(mStartDate
)。
如何实现这个新属性?
起初我想创建一个新的table,具有三个属性(depId
、aNo
、mStartDate
),并在新的[=之间建立两个关系34=]和其他两个table,但我后来意识到这不是多对多关系。
那么如何将属性 mStartDate
添加到两个 table 之间的一对一关系中?
There's more than one relation between the two tables, and some of those relations are one-to-many (the department employs more than one academic staff), so I can't merge the two tables.
部门
- depId
- fk_aNo(独一无二)
*****- 主键 (depId, fk_aNo)*****
学术资料
- a否(PK)
新表
- depId --- 重要"Both depId,aNo are from Departments, be sure"
- a否---
mStartDate
-主键(depId,aNo)
Constraints--> a academicStuff can't start to manage a department more than one time. If this structure proper for you and you want to enable a aacademic stuff manage a department more than one time inform me.
你提议的新table(我称之为DepartmentManagement)原则上可以记录每个部门的经理的历史,在这种情况下,它将是多对多(时间)关系在部门和学术之间。
但是,如果您只想记录当前经理,将 "absorb" DepartmentManager 放入部门 table 是合理的,在那里给出两列(Manager_aNo 和 Manager_StartDate).从概念上讲,对象 "DepartmentManagement" 仍然存在,但它被吸收了,它没有自己的 table.
你也可以在另一个方向(进入学术)吸收它,但这不允许一个学术部门管理多个部门。你现在可能不需要那个,但原则上它比一个部门有两个经理更有可能。