Two relationship shapes that cover almost everything
Most data relationships boil down to two patterns:
- One-to-many: one author writes many books; one customer places many orders. The "many" side holds a foreign key pointing to the "one" side.
- Many-to-many: many students take many courses; many posts have many tags. Requires a junction table with two foreign keys.
One-to-one is just a one-to-many in disguise
If you genuinely need a one-to-one relationship, it's usually a one-to-many with a UNIQUE constraint on the foreign key. (Often the right answer is "don't split the table at all and just put the columns on the parent.")
Junction tables are first-class
The junction table connecting students and courses is not a hack — it's the correct shape. It can carry its own data: enrollment date, role, grade. The composite primary key (student_id, course_id) is the natural identity for the relationship row.