如何在 ER 图中表示 2 个实体和 2 个关系
假设我有2个实体设置一个用户
和其他books
和user
包含两种类型的user.roles。 /代码>管理员添加书籍和学生读取它们,因此如何表示这些实体
and 用户
and books
with Restions reads
在 er图中。
Suppose I have 2 entity set one user
and other books
and the user
contains two types of user.roles : student and admin
the admin adds books and student reads them so how to I represent these entity user
and books
with relations reads
and adds
in an ER Diagram.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最上面一行代表管理员角色。我假设一本书仅由一位管理员添加,而管理员可以添加多本书。管理员需要添加书籍,新管理员可能尚未添加任何书籍。
底线代表学生的角色。一个学生可能读很多本书,一本书也可能被很多学生读。学生可能没有读过任何书,也可能学生还没有读过书。
这里已经包含的答案提到,将其放入 DBMS 时,您需要一个用于多对多关系的联接表。这里的符号是鱼尾纹。如果您不熟悉,这里有一个解释该符号的链接,https: //vertabelo.com/blog/crow-s-foot-notation/。
The top line is representing the admin role. I assumed a book is added by only by one admin and an admin may add many books. A book is required to be added by an admin and a new admin may not have added any books.
The bottom line is representing the student role. A student may read many books and a book may be read by many students. A student may not have read any books and a book my not yet have been read by a student.
The answer already included here mentioned you need a join table for the many-to-many relationship when putting this into a DBMS. The notation here is crow's foot. Here is a link for an explanation of the notation if you're not familiar, https://vertabelo.com/blog/crow-s-foot-notation/.
据推测,这两者都是多对多关系,因此最常见的做法是显式包含联接表,每个联接表在书籍和用户之间都是多对多的,但会适当命名以区分其功能。
Presumably both of those are many to many relationships, so the most common thing to do would be to explicitly include the join tables, each of which would be a many to many between books and users, but would be named appropriate to distinguish thier functions.