Normalization, Practically

One rule carries most of the theory: store each fact once.

A table repeating the author's name on every book row will eventually hold two spellings of that name, because someone will type it slightly differently and nothing stops them. Once that happens, grouping by author is wrong and nobody notices until the counts look odd.

Try it

Octavia Butler now appears as two authors, and the US as two countries. No query can fix this, because the information that they are the same was never stored.

loading editor…
real SQLite, in your browser

This is a real flat table with a real problem. Look carefully at the author names and countries: 'Octavia Bulter' and 'USA' are typos that the design permitted.

The fix is a second table. Authors get their own table with one row each, and loans point at them by id. The name is stored once, so a typo is a single row to correct rather than an unknown number scattered through the data.

A comma-separated list in a column is the same mistake. tags TEXT holding 'novel,scifi' cannot be joined, indexed or counted properly. Many-to-many needs its own table.

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Constraints →
← Back