Diagram Desk

Clinic appointment ERD

Patient, doctor, department and appointment. Each doctor belongs to one department; each appointment points to one patient and one doctor.

The diagram

PatientPK patient_id intname varcharbirth_date dateDoctorPK doctor_id intname varcharFK dept_id intDepartmentPK dept_id intdept_name varcharAppointmentPK appointment_id intFK patient_id intFK doctor_id intstarts_at datetimeemploysbookssees
ER diagram · 16 shapes

Reading it step by step

  • 'Patient' has 3 attributes, primary key patient_id.
  • 'Doctor' has 3 attributes, primary key doctor_id, foreign key dept_id.
  • 'Department' has 2 attributes, primary key dept_id.
  • 'Appointment' has 4 attributes, primary key appointment_id, foreign key patient_id, doctor_id.
  • Each 'Department' relates to one or more 'Doctor'; each 'Doctor' to exactly one 'Department' (employs).
  • Each 'Patient' relates to zero or more 'Appointment'; each 'Appointment' to exactly one 'Patient' (books).
  • Each 'Doctor' relates to zero or more 'Appointment'; each 'Appointment' to exactly one 'Doctor' (sees).

Shape by shape

ShapeSymbolConnections
PatientEntityholds patient_id, name, birth_date · → Appointment(books)
DoctorEntityholds doctor_id, name, dept_id · → Appointment(sees) · ← Department
DepartmentEntityholds dept_id, dept_name · → Doctor(employs)
AppointmentEntityholds appointment_id, patient_id, doctor_id, starts_at · ← Patient, Doctor

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.
One or manyA crow's foot and a bar.

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.

# Clinic appointment ERD
erDiagram
  Patient {
    int patient_id PK
    varchar name
    date birth_date
  }
  Doctor {
    int doctor_id PK
    varchar name
    int dept_id FK
  }
  Department {
    int dept_id PK
    varchar dept_name
  }
  Appointment {
    int appointment_id PK
    int patient_id FK
    int doctor_id FK
    datetime starts_at
  }
  Department ||--|{ Doctor : employs
  Patient ||--o{ Appointment : books
  Doctor ||--o{ Appointment : sees

More er diagram examples

All SeewolLabs tools