Diagram Desk

Library ERD

Member, book, loan and author for a library system. Loans join members and books; an author writes many books.

The diagram

MemberPK member_id intname varcharphone varcharBookPK isbn varchartitle varcharFK author_id intAuthorPK author_id intauthor_name varcharLoanPK loan_id intFK member_id intFK isbn varcharloaned_on datedue_on dateborrowsis_lentwrites
ER diagram · 17 shapes

Reading it step by step

  • 'Member' has 3 attributes, primary key member_id.
  • 'Book' has 3 attributes, primary key isbn, foreign key author_id.
  • 'Author' has 2 attributes, primary key author_id.
  • 'Loan' has 5 attributes, primary key loan_id, foreign key member_id, isbn.
  • Each 'Member' relates to zero or more 'Loan'; each 'Loan' to exactly one 'Member' (borrows).
  • Each 'Book' relates to zero or more 'Loan'; each 'Loan' to exactly one 'Book' (is_lent).
  • Each 'Author' relates to zero or more 'Book'; each 'Book' to exactly one 'Author' (writes).

Shape by shape

ShapeSymbolConnections
MemberEntityholds member_id, name, phone · → Loan(borrows)
BookEntityholds isbn, title, author_id · → Loan(is_lent) · ← Author
AuthorEntityholds author_id, author_name · → Book(writes)
LoanEntityholds loan_id, member_id, isbn, loaned_on, due_on · ← Member, Book

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.

# Library ERD
erDiagram
  Member {
    int member_id PK
    varchar name
    varchar phone
  }
  Book {
    varchar isbn PK
    varchar title
    int author_id FK
  }
  Author {
    int author_id PK
    varchar author_name
  }
  Loan {
    int loan_id PK
    int member_id FK
    varchar isbn FK
    date loaned_on
    date due_on
  }
  Member ||--o{ Loan : borrows
  Book ||--o{ Loan : is_lent
  Author ||--o{ Book : writes

More er diagram examples

All SeewolLabs tools