When to use it
Use it for a software engineering or database course project, a capstone clinic booking system, or to model any appointment-based business. The schedule table is the key: it holds the doctor, date, time block and number of slots, and an appointment points to a schedule, not straight to a doctor.
Make it yours
- For billing, tests or prescriptions, add entities and connect them to the visit.
- Salons, driving schools and meeting rooms share the structure; replace departments and doctors with locations and staff.
- The example lists few fields. A real system holds personal health information, so design access control and masking.
Mermaid code
erDiagram
DEPARTMENT ||--o{ DOCTOR : has
DOCTOR ||--o{ SCHEDULE : works
SCHEDULE ||--o{ APPOINTMENT : fills
PATIENT ||--o{ APPOINTMENT : books
APPOINTMENT ||--o| VISIT : becomes
DOCTOR ||--o{ VISIT : conducts
PATIENT {
string patient_id PK
string name
string phone
date birth_date
}
DEPARTMENT {
string department_id PK
string name
string location
}
DOCTOR {
string doctor_id PK
string name
string specialty
string department_id FK
}
SCHEDULE {
string schedule_id PK
string doctor_id FK
date work_date
string time_block
int total_slots
int open_slots
}
APPOINTMENT {
string appointment_id PK
string patient_id FK
string schedule_id FK
string status
datetime booked_at
}
VISIT {
string visit_id PK
string appointment_id FK
string doctor_id FK
datetime seen_at
}Ask an AI for one with this structure
Send the prompt below to ChatGPT or Claude, then paste the whole reply into the editor; the code inside is detected automatically.
Draw a clinic appointment system ER diagram with Mermaid erDiagram syntax. Entities are PATIENT, DEPARTMENT, DOCTOR, SCHEDULE, APPOINTMENT and VISIT. Department to doctor, doctor to schedule, schedule to appointment, patient to appointment and doctor to visit are one to many; appointment to visit is one to zero or one. The schedule has a work date, time block, total slots and open slots. List three to six fields per entity and mark PK and FK. Output only the mermaid code block.
FAQ
- Why is appointment to visit one to zero or one?
A booked appointment may be cancelled or missed.
||--o|means an appointment has at most one visit.- How do I show slots being taken?
An ER diagram shows data structure only. Decrementing open slots is logic, which a sequence diagram or flowchart shows better.
- Can I use real patient data as sample data?
No. Use made-up data for coursework; real patient information is protected by law.
More in this category
Updated 2026-11-11