database ER图中2个实体之间的2个关系
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14542763/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
2 relationships between 2 entities in ER diagram
提问by user1330217
I'm trying to draw an ER diagram describing the following:
我正在尝试绘制描述以下内容的 ER 图:
-"Department" employs "Employees"
——“部门”聘用“员工”
-Some "Employees" are "Special" and have more attributes
- 一些“员工”是“特殊的”并且有更多的属性
-Some of the "Employees" ("Special" and non special) are "Managers"
- 一些“员工”(“特殊”和非特殊)是“经理”
-"Managers" manage "Departments"
-“经理”管理“部门”
So, to convey this I have:
所以,为了传达这一点,我有:
Department ------(employs)------- Employee-----<--------Special
      |                             |
      |-----------(manages)----------
From my understanding, I cannot have 2 relationships between 2 entities. How do I deal with this situation then?
根据我的理解,我不能在 2 个实体之间建立 2 个关系。那我该如何处理这种情况呢?
回答by High Performance Mark
There is no reason you can't have multiple relationships between the same two entities, your understanding is wrong in this respect.
没有理由您不能在相同的两个实体之间建立多种关系,您在这方面的理解是错误的。
You have to be certain, of course, that the relationships capture different information and that you haven't, say, mistaken the two aspects of a single relationship as two different relationships. Your example seems to be a good candidate for having two relationships between the two entities.
当然,您必须确定这些关系捕获了不同的信息,并且您没有将单个关系的两个方面误认为是两个不同的关系。您的示例似乎很适合在两个实体之间建立两种关系。
回答by Nikola Mitev


Hi mate watch this diagram, hope it helps
嗨,伙计,看这张图,希望对你有帮助
回答by Nikola Mitev
 Better approach is to add a bit field in Employee table IsManager, so if he is a manager, that means that he is a manager on department he works.
Better approach is to add a bit field in Employee table IsManager, so if he is a manager, that means that he is a manager on department he works.
 更好的方法是在Employee表IsManager中增加一个位域,所以如果他是经理,那就意味着他是他工作的部门的经理。
更好的方法是在Employee表IsManager中增加一个位域,所以如果他是经理,那就意味着他是他工作的部门的经理。
回答by Omar
Your relationship for employs and manages are going to be two linking tables. e.g. Consider the tables and fields as below:
您的雇用和管理关系将是两个链接表。例如,考虑如下表和字段:
Department
   DepartmentID
   DepartmentName
Employee
   EmployeeID
   EmployeeName
SpecialEmployee
   EmployeeID
   Attr1
   Attr2
Now you can go on and link Employee and Department as such:
现在,您可以继续将 Employee 和 Department 链接起来:
DepartmentEmploys
     DepartmentEmploysID
     DepartmentID
     EmployeeID
ManagesDepartment
     ManagesDepartmentID    
     EmployeeID
     DepartmentID
Now your relationships do not overlap or interfere. What seems to be drawn in your diagram is correct. There can be more than one relationships between two entities.
现在你们的关系不会重叠或干扰。您的图表中似乎绘制的内容是正确的。两个实体之间可以有多个关系。
回答by Hafiz Muhammad Atif
There should be only one class of employee If you have multiple categories of the employee then you can make child classes of Employee Class.
Parent: Employee
1st child: Special Employee
2nd child: Normal Employee  
应该只有一类员工如果您有多个类别的员工,那么您可以创建员工类的子类。
父:员工
第一个孩子:特殊员工
第二个孩子:普通员工  

