Home > Software design >  How to represent 2 Entity with 2 Relation in ER diagram
How to represent 2 Entity with 2 Relation in ER diagram

Time:04-10

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.

CodePudding user response:

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.

CodePudding user response:

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

  • Related