简体   繁体   English

在一个表中合并两个实体

[英]Consolidation of two entities in one table

I am making a thesis repository, and I came across another situation. 我正在建立一个论文库,但遇到了另一种情况。 I have 3 user levels, admin, staff and guest. 我有3个用户级别,分别是admin,staff和guest。 I have this ERD diagram below. 我在下面有此ERD图。 Situation: A user can be a student, admin or staff. 情况:用户可以是学生,管理员或工作人员。 However, one feature of this web app is to search theses by authors. 但是,此Web应用程序的一项功能是按作者搜索论文。 Also, a user with admin / staff privilege upload thesis. 另外,具有admin / staff特权的用户可以上传论文。 Question: Can I consolidate student and other user privilege information in one table? 问题:我可以将学生和其他用户特权信息合并到一个表中吗? Say like, all info will be stored in one table called users? 就像说,所有信息都将存储在一个称为用户的表中? Thanks in advance 提前致谢

InitialERD InitialERD

A. If a user can have multiple privileges for an instance both a student & staff. 答:如果用户可以为一个实例同时拥有多个特权,则学生和职员都可以。 Then you should have a user table with a one to many relationship with a user privilege table. 然后,您应该拥有一个与用户特权表具有一对多关系的用户表。 User privilege table will contain the user privileges like student, guest, admin etc. 用户权限表将包含学生,访客,管理员等用户权限。

B. If a user will have exactly one privilege then you can include that within the user table as a field/column String privilegeKind; B.如果一个用户将只拥有一个特权,那么您可以将它作为字段/列String privilegeKind包含在用户表中;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM