An ER diagram is the schema as a picture โ the one artefact you can put in front of a non-developer and get a useful correction from. Then the opposite question: when is deliberately breaking 3NF the right engineering call?
4a
Six entities, three relationship shapes. Walk it with Next โ the diagram assembles in the same order you designed it across sessions 01 to 03.
The diagram is a review tool, not decoration. Show this to the clinic manager and they will spot in ten seconds that a patient can be seen by two doctors at once, or that nothing records which room was used โ corrections that cost days once there is Go code on top.
4b
A finished ERD translates into CREATE TABLE statements with no judgement left to exercise โ which is the point of doing it first.
-- crow's foot at appointments โ FK lives on appointments patients 1 โโ< N appointments โ appointments.patient_id integer NOT NULL REFERENCES patients(id) -- bar + circle on both ends โ FK on the optional side, plus UNIQUE patients 1 โโโ 1 medical_records โ medical_records.patient_id integer NOT NULL UNIQUE REFERENCES patients(id) -- crow's foot at BOTH ends โ the line itself becomes a table doctors N >โโ โโ< M specialities โ doctor_specialities(doctor_id, speciality_id) PRIMARY KEY (both)
UNIQUE to the foreign key you would otherwise have written.Keep the ERD in the repository as text, not as an image someone exported once and lost the source for. Mermaid's erDiagram renders on GitHub, diffs like code, and can be edited in a pull request โ which means it stands a chance of staying true.
4c
3NF is the default, not a moral position. Denormalizing means storing a fact twice on purpose โ and accepting that you now own the job of keeping both copies true.
count(*) over millions of rows on every load is a real reason. "Joins feel slow" without a query plan is not.(a) Draw the full clinic ERD โ six entities, correct crow's feet โ using Mermaid erDiagram syntax, and commit it next to your schema. (b) The clinic wants a screen listing every doctor with their appointment count for today. Write the normalized query first. (c) Now justify, in three sentences, either keeping it normalized or denormalizing โ and if you denormalize, name exactly what keeps the copy correct and what happens when that mechanism fails.
Recap
UNIQUE, two feet โ a join table.