MySQL + SQL · Lesson 22
ER Diagram Examples for School Database
Practical ER Diagrams
Here are common ER diagram scenarios asked in exams and used in real projects.
School ER Diagram
Entities: Student, Class, Teacher, Subject.
- A Class has many Students (1:N).
- A Teacher teaches many Subjects (1:N).
- A Student studies many Subjects (M:N).
Library ER Diagram
Entities: Member, Book, Issue.
- A Member borrows many Books (M:N, resolved by Issue table).
- Issue stores member_id, book_id, issue_date, return_date.
Converting M:N
A many-to-many relationship is converted into a junction table with two foreign keys. Example: student_subject(roll_no, subject_id).
Summary
- Identify entities, then their relationships and cardinality.
- M:N relationships become junction tables with two foreign keys.
💻 Live Code Editor
Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.