Library ERD
Member, book, loan and author for a library system. Loans join members and books; an author writes many books.
The diagram
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
| Shape | Symbol | Connections |
|---|---|---|
| Member | Entity | holds member_id, name, phone · → Loan(borrows) |
| Book | Entity | holds isbn, title, author_id · → Loan(is_lent) · ← Author |
| Author | Entity | holds author_id, author_name · → Book(writes) |
| Loan | Entity | holds loan_id, member_id, isbn, loaned_on, due_on · ← Member, Book |
Symbols used here
| Symbol | Meaning |
|---|---|
| Entity | A 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 one | Two short bars at the line end. |
| Zero or many | A crow's foot and a circle. |
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