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
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
| Shape | Symbol | Connections |
|---|---|---|
| Patient | Entity | holds patient_id, name, birth_date · → Appointment(books) |
| Doctor | Entity | holds doctor_id, name, dept_id · → Appointment(sees) · ← Department |
| Department | Entity | holds dept_id, dept_name · → Doctor(employs) |
| Appointment | Entity | holds appointment_id, patient_id, doctor_id, starts_at · ← Patient, Doctor |
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. |
| One or many | A crow's foot and a bar. |
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