Examples · ER diagrams
Crow's foot ER diagram examples: six models read line by line
In short
Below are six complete entity relationship diagrams in crow's foot notation: a library, an online shop, a school, a clinic, a staff hierarchy and a hotel. Each shows boxes for entities with their attributes, and lines whose ends carry the crow's foot marks: a bar for one, a circle for zero and a crow's foot for many. Under each diagram every line is read out loud as two sentences, and the Mermaid code that draws it is printed, so you can copy any example and change it.
Updated · by the ChartCraft team · drawings rendered with Mermaid 11.17.2 · part of the ER diagram symbols reference
How do you read a crow's foot ER diagram?
Each box is an entity and each line is a relationship. Read a line from one box to the marks at the other end: the mark nearest that box is the maximum and the mark further out is the minimum. Every line therefore gives two sentences.
| Line end | Say | Mermaid |
|---|---|---|
| exactly one | || | |
| zero or one | |o o| | |
| one or many | }| |{ | |
| zero or many | }o o{ |
A solid line is an identifying relationship and a dashed line a non-identifying one. PK marks a primary key, FK a foreign key and UK a unique key. The full key is on ER diagram cardinality symbols.
What does a library ER diagram look like in crow's foot notation?
Four entities: MEMBER, LOAN, COPY and BOOK. A book exists as one or many physical copies, and each loan records one member borrowing one copy. LOAN sits between MEMBER and COPY, so it holds both foreign keys.
Step 1
Lines first
Draw the entities and the three relationships without attributes, and check that every line reads as two true sentences.
erDiagram
MEMBER ||--o{ LOAN : "takes out"
COPY ||--o{ LOAN : "is lent in"
BOOK ||--|{ COPY : "exists as"Step 2
Read every line
Read each line in both directions before adding anything.
- Each member takes out zero or many loans. Each loan is taken out by exactly one member.
- Each copy is lent in zero or many loans. Each loan is for exactly one copy.
- Each book exists as one or many copies. Each copy is of exactly one book.
Step 3
Add keys and attributes
Give every entity a primary key, then put a foreign key in the entity at each crow's foot end: member_id and copy_id in LOAN, isbn in COPY.
erDiagram
MEMBER ||--o{ LOAN : "takes out"
COPY ||--o{ LOAN : "is lent in"
BOOK ||--|{ COPY : "exists as"
MEMBER {
int member_id PK
string name
string email UK
}
LOAN {
int loan_id PK
int member_id FK
int copy_id FK
date due_date
date returned_on
}
COPY {
int copy_id PK
string isbn FK
string shelf
}
BOOK {
string isbn PK
string title
string author
}Draw this in the editor → Opens ChartCraft with this description filled in: “Crow's foot ER diagram for a library: a member takes out zero or many loans, a book exists as one or many copies, and each copy is lent in zero or many loans. Show primary and foreign keys.”
What does an online shop ER diagram look like?
A customer places orders, each order contains one or many order lines, and each line names one product. ORDER_LINE resolves the many to many relationship between ORDER and PRODUCT, and its primary key is made of two foreign keys.
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ ORDER_LINE : contains
PRODUCT ||--o{ ORDER_LINE : "appears in"
CUSTOMER {
int customer_id PK
string name
string email UK
}
ORDER {
int order_id PK
int customer_id FK
date ordered_on
}
ORDER_LINE {
int order_id PK, FK
int product_id PK, FK
int quantity
}
PRODUCT {
int product_id PK
string name
decimal price
}- Each customer places zero or many orders. Each order is placed by exactly one customer.
- Each order contains one or many order lines. Each order line belongs to exactly one order.
- Each product appears in zero or many order lines. Each order line is for exactly one product.
What does a school enrolment ER diagram look like?
Students and courses are many to many, so ENROLMENT sits between them and stores what belongs to the pair: the grade. A teacher teaches zero or many courses.
erDiagram
STUDENT ||--o{ ENROLMENT : has
COURSE ||--o{ ENROLMENT : has
TEACHER ||--o{ COURSE : teaches
STUDENT {
int student_id PK
string name
}
ENROLMENT {
int student_id PK, FK
int course_id PK, FK
string grade
}
COURSE {
int course_id PK
int teacher_id FK
string title
}
TEACHER {
int teacher_id PK
string name
}- Each student has zero or many enrolments. Each enrolment belongs to exactly one student.
- Each course has zero or many enrolments. Each enrolment is for exactly one course.
- Each teacher teaches zero or many courses. Each course is taught by exactly one teacher.
What does a clinic ER diagram look like?
Patients book appointments with doctors, and an appointment may lead to one prescription. The zero or one end at PRESCRIPTION, together with the unique foreign key appointment_id, is how a one to one optional relationship is shown.
erDiagram
PATIENT ||--o{ APPOINTMENT : books
DOCTOR ||--o{ APPOINTMENT : holds
APPOINTMENT ||--o| PRESCRIPTION : "may lead to"
PATIENT {
int patient_id PK
string name
date born_on
}
DOCTOR {
int doctor_id PK
string name
}
APPOINTMENT {
int appointment_id PK
int patient_id FK
int doctor_id FK
datetime starts_at
}
PRESCRIPTION {
int prescription_id PK
int appointment_id FK, UK
string medicine
}- Each patient books zero or many appointments. Each appointment is booked by exactly one patient.
- Each doctor holds zero or many appointments. Each appointment is held by exactly one doctor.
- Each appointment leads to zero or one prescription. Each prescription comes from exactly one appointment.
How is a recursive relationship drawn in crow's foot notation?
A recursive (unary) relationship is a line that leaves an entity and returns to it. Here an employee manages zero or many employees and is managed by zero or one, because the head of the company has no manager.
erDiagram
DEPARTMENT ||--o{ EMPLOYEE : employs
EMPLOYEE |o--o{ EMPLOYEE : manages
DEPARTMENT {
int department_id PK
string name
}
EMPLOYEE {
int employee_id PK
int department_id FK
int manager_id FK
string name
}- Each department employs zero or many employees. Each employee is employed by exactly one department.
- Each employee manages zero or many employees. Each employee is managed by zero or one employee.
The foreign key manager_id points back into the same table. It must allow an empty value, which matches the circle at the managed-by end.
What do solid and dashed lines mean in a crow's foot example?
A solid line is an identifying relationship: the child's primary key includes the parent's key. A dashed line is non-identifying: the child has its own key and only refers to the parent. In the hotel, a room is identified by its hotel and room number, so HOTEL to ROOM is solid.
erDiagram
HOTEL ||--|{ ROOM : has
GUEST ||..o{ BOOKING : makes
ROOM ||..o{ BOOKING : "is reserved in"
HOTEL {
int hotel_id PK
string name
}
ROOM {
int hotel_id PK, FK
int room_no PK
string type
}
GUEST {
int guest_id PK
string name
}
BOOKING {
int booking_id PK
int guest_id FK
int hotel_id FK
int room_no FK
date check_in
}- Each hotel has one or many rooms. Each room belongs to exactly one hotel.
- Each guest makes zero or many bookings. Each booking is made by exactly one guest.
- Each room is reserved in zero or many bookings. Each booking reserves exactly one room.
What mistakes do students make in crow's foot diagrams?
Three mistakes show up in almost every set of marked coursework: a many to many line left unresolved, a foreign key on the one side, and a line with no verb.
1. Many to many left as one line
Loses marks
STUDENT }o--o{ COURSE : takes
Correct
A relational database cannot store a many to many line directly. Add an associative entity such as ENROLMENT, which also gives the grade a place to live.
2. Foreign key on the one side
Loses marks
Correct
The foreign key goes in the entity at the crow's foot end. A member cannot hold one loan_id for every loan.
3. Lines without a verb
Loses marks
Correct
CUSTOMER ||--o{ ORDER : places
Without a verb the line cannot be read as a sentence, and a marker cannot tell whether a customer places orders or approves them.
Can you read these crow's foot examples?
Five questions on the diagrams above. Look back at the drawing, answer, then open the worked answer.
Question 1. In the library model, why does LOAN hold two foreign keys?
Worked answer
LOAN is at the crow's foot end of two lines: one from MEMBER and one from COPY. Each loan must remember its member and its copy, so it stores member_id and copy_id.
Question 2. In the shop, could an order exist with no order lines?
Worked answer
No. The ORDER_LINE end of the line from ORDER shows a bar and a crow's foot: one or many. Every order has at least one line.
Question 3. In the clinic, what makes the prescription relationship one to one and not one to many?
Worked answer
The PRESCRIPTION end shows a circle and a bar, zero or one, so an appointment has at most one prescription. In the table, appointment_id is marked UK, unique, which enforces it.
Question 4. Why is the managed-by end of the staff line a circle and a bar, not two bars?
Worked answer
Somebody at the top has no manager. Two bars would mean every employee has exactly one manager, which is impossible in a finite company. Zero or one is right.
Question 5. Change the school model so that every course must have at least one enrolment. Which line changes, and how?
Worked answer
The COURSE to ENROLMENT line. Its ENROLMENT end changes from zero or many to one or many: COURSE ||--|{ ENROLMENT : has.
Where can you see more ER diagram examples?
Diagrams from the public ChartCraft gallery, each generated from a plain-English description.
Questions
What is an entity relationship diagram in crow's foot notation?
An ER diagram where entities are boxes and relationships are lines whose ends carry a bar (one), a circle (zero) or a crow's foot (many). Two marks at each end give the minimum and maximum.
What is a crow foot notation ER diagram example?
A library: MEMBER ||--o{ LOAN, COPY ||--o{ LOAN and BOOK ||--|{ COPY. Each member takes out zero or many loans, and each book exists as one or many copies.
How do you read a crows foot diagram?
Start at one entity, follow the line, and read the two marks at the far end: nearest the box is the maximum, further out the minimum. Then read the line the other way.
What do entity relationship diagram crows feet mean?
A crow's foot means many. It always sits next to the entity box, as the maximum. A circle or bar further out gives the minimum.
Where do foreign keys go in a crow's foot ER diagram?
In the entity at the crow's foot end of each one to many line. An associative entity that resolves a many to many relationship holds two foreign keys.
What does a dashed line mean in a crow's foot ERD?
A non-identifying relationship: the child has its own primary key and only refers to the parent. A solid line is identifying.
Sources
The rules and names on this page were checked against these documents.
- Mermaid documentation, Entity Relationship Diagrams. The four mark pairs (|o, ||, }o, }|), the word aliases, identifying (--) and non-identifying (..) lines, and the PK, FK and UK keys.
- A Practical Introduction to Databases, chapter 2.4, ERD alternatives and variations. Open textbook on Runestone Academy. Source for the reading rule of crow's foot marks (the symbol closest to the entity is the maximum, the one further away the minimum) and for the (min,max) and 0..N alternatives.
- FIPS PUB 184, Integration Definition for Information Modeling (IDEF1X). Clause 3.5.2: a line with a dot at the child end, P for one or more, Z for zero or one, a solid line for an identifying and a dashed line for a non-identifying relationship.