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 endSayMermaid
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.

Library ER diagram in crow's foot notation without attributes: MEMBER, LOAN, COPY and BOOK joined by three one to many lines
The library model without attributes. Rendered with Mermaid 11.17.2 from the code below.
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.

Library ER diagram in crow's foot notation with attributes, primary keys and foreign keys
The finished library model with keys. Rendered with Mermaid 11.17.2 from the code below.
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.

Online shop ER diagram in crow's foot notation: CUSTOMER, ORDER, ORDER_LINE and PRODUCT
Online shop in crow's foot notation. Rendered with Mermaid 11.17.2 from the code below.
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
    }

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.

School enrolment ER diagram in crow's foot notation: STUDENT and COURSE joined through ENROLMENT, TEACHER teaches COURSE
School enrolment in crow's foot notation. Rendered with Mermaid 11.17.2 from the code below.
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
    }

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.

Clinic ER diagram in crow's foot notation: PATIENT, DOCTOR, APPOINTMENT and an optional PRESCRIPTION
Clinic in crow's foot notation. Rendered with Mermaid 11.17.2 from the code below.
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
    }

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.

Staff ER diagram in crow's foot notation with a recursive relationship: EMPLOYEE manages EMPLOYEE
Staff hierarchy with a recursive relationship. Rendered with Mermaid 11.17.2 from the code below.
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
    }

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.

Hotel ER diagram in crow's foot notation with a solid identifying line from HOTEL to ROOM and dashed non-identifying lines to BOOKING
Hotel with one identifying (solid) and two non-identifying (dashed) relationships. Rendered with Mermaid 11.17.2 from the code below.
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
    }

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

Many to many: a crow's foot at both ends of the line between STUDENT and COURSE

STUDENT }o--o{ COURSE : takes

Correct

The many to many relationship resolved: ENROLMENT sits between STUDENT and COURSE and holds the grade

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

Wrong: the foreign key loan_id sits in MEMBER, the one side

Correct

Step 3: the same line, and LOAN now holds the foreign key member_id

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

A relationship line with no label between CUSTOMER and ORDER

Correct

One to many symbol in crow's foot notation: two bars next to CUSTOMER, a circle and a crow's foot next to ORDER

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.

Related references

Describe the entities in plain English. ChartCraft puts the right marks on every line.

ER diagram generator →