doctors
Clinicians who see patients.
An appointment system connects people who need care with the people who give it, at a particular time. This sketch covers the essentials and shows how a record can hang off an appointment.
Clinicians who see patients.
People receiving care.
A scheduled visit between one patient and one doctor.
Medication prescribed during an appointment. One visit can produce several.
appointments.patient_id references patients.id: one row in patients can have many rows in appointments.appointments.doctor_id references doctors.id: one row in doctors can have many rows in appointments.prescriptions.appointment_id references appointments.id: one row in appointments can have many rows in prescriptions.Copy it into your database, or open it in Crowsfoot to edit the diagram, add notes, and export again.
CREATE TABLE doctors (
id bigint PRIMARY KEY,
name varchar(120) NOT NULL,
specialty varchar(80) NOT NULL
);
CREATE TABLE patients (
id bigint PRIMARY KEY,
name varchar(120) NOT NULL,
date_of_birth date NOT NULL,
phone varchar(30)
);
CREATE TABLE appointments (
id bigint PRIMARY KEY,
patient_id bigint NOT NULL REFERENCES patients (id),
doctor_id bigint NOT NULL REFERENCES doctors (id),
starts_at timestamptz NOT NULL,
status varchar(20) NOT NULL DEFAULT 'scheduled',
reason text
);
CREATE TABLE prescriptions (
id bigint PRIMARY KEY,
appointment_id bigint NOT NULL REFERENCES appointments (id),
medication varchar(160) NOT NULL,
dosage varchar(80) NOT NULL
);
New to ER diagrams? Read the crow’s foot notation guide.