如何在 ER 图中表示 2 个实体和 2 个关系

发布于 2025-01-20 12:42:26 字数 262 浏览 4 评论 0原文

假设我有2个实体设置一个用户和其他booksuser包含两种类型的user.roles。 /代码>管理员添加书籍和学生读取它们,因此如何表示这些实体用户 and books with Restions reads and 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

永言不败 2025-01-27 12:42:26

概念 ER图

最上面一行代表管理员角色。我假设一本书仅由一位管理员添加,而管理员可以添加多本书。管理员需要添加书籍,新管理员可能尚未添加任何书籍。

底线代表学生的角色。一个学生可能读很多本书,一本书也可能被很多学生读。学生可能没有读过任何书,也可能学生还没有读过书。

这里已经包含的答案提到,将其放入 DBMS 时,您需要一个用于多对多关系的联接表。这里的符号是鱼尾纹。如果您不熟悉,这里有一个解释该符号的链接,https: //vertabelo.com/blog/crow-s-foot-notation/

Conceptual ER Diagram

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/.

許願樹丅啲祈禱 2025-01-27 12:42:26

据推测,这两者都是多对多关系,因此最常见的做法是显式包含联接表,每个联接表在书籍和用户之间都是多对多的,但会适当命名以区分其功能。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文