Diagram Desk

Resolving many-to-many ERD

Students and clubs are many-to-many; a membership entity splits it and holds attributes of the relationship itself (joined date, role).

The diagram

StudentPK student_no intname varcharClubPK club_id intclub_name varcharClubMemberPK membership_id intFK student_no intFK club_id intjoined_on daterole varcharjoinsadmits
ER diagram · 12 shapes

Reading it step by step

  • 'Student' has 2 attributes, primary key student_no.
  • 'Club' has 2 attributes, primary key club_id.
  • 'ClubMember' has 5 attributes, primary key membership_id, foreign key student_no, club_id.
  • Each 'Student' relates to zero or more 'ClubMember'; each 'ClubMember' to exactly one 'Student' (joins).
  • Each 'Club' relates to zero or more 'ClubMember'; each 'ClubMember' to exactly one 'Club' (admits).

Shape by shape

ShapeSymbolConnections
StudentEntityholds student_no, name · → ClubMember(joins)
ClubEntityholds club_id, club_name · → ClubMember(admits)
ClubMemberEntityholds membership_id, student_no, club_id, joined_on, role · ← Student, Club

Symbols used here

SymbolMeaning
EntityA thing to store: name on top, attributes below.
Primary key (PK)The attribute that identifies one row; underlined.
Foreign key (FK)An attribute pointing to another entity's key.
Exactly oneTwo short bars at the line end.
Zero or manyA crow's foot and a circle.

All er diagram symbols and how to draw

Diagram text

Paste this text into the editor to get the same picture, then change the names to fit your own work.

# Resolving many-to-many ERD
erDiagram
  Student {
    int student_no PK
    varchar name
  }
  Club {
    int club_id PK
    varchar club_name
  }
  ClubMember {
    int membership_id PK
    int student_no FK
    int club_id FK
    date joined_on
    varchar role
  }
  Student ||--o{ ClubMember : joins
  Club ||--o{ ClubMember : admits

More er diagram examples

All SeewolLabs tools