Skip to the guide

Relational databases and SQL

BeginnerConcept3 pages

Most designs in an interview start with a relational database, and for good reason. This guide covers what one gives you (tables, keys, joins, constraints and SQL) and the question that follows as soon as you draw it: what does a join cost, and when does it stop working?

A school office's registers

A school office keeps three registers. The pupils register gives every pupil a number, with their name and year. The courses register numbers every course. A third register holds nothing but pairs: pupil 1042 takes course 7. Nobody copies a pupil's name into it; the clerk looks the name up by number when she needs it. And the office has rules: no enrolment for a pupil number that doesn't exist, and no two pupils with the same number.

When the head asks "who's in Year 9 Maths?", the clerk finds Maths in the courses register, runs down the enrolments for course 7, and looks up each pupil by number.