Normalizing a database means storing each fact once, in the table of the thing it describes, and linking the tables by identifiers instead of copying values from row to row. This guide follows one small example, a sheet of football players, from its flat form to its normalized form, and shows on that data what each form allows and what it costs.
The starting point is a sheet with one row per player. Each row also carries the player's club, the club's city and the year the club was founded: five columns, two of them about the player, three about the club.
| player | born | club | club_city | club_founded |
|---|---|---|---|---|
| Carles Puyol | 1978 | FC Barcelona | Barcelona | 1899 |
| Paolo Maldini | 1968 | AC Milan | Milan | 1899 |
| Franco Baresi | 1960 | AC Milan | Milan | 1899 |
| Ryan Giggs | 1973 | Manchester United | Manchester | 1878 |
| Paul Scholes | 1974 | Manchester United | Manchester | 1902 |
| Francesco Totti | 1976 | AS Roma | Rome | 1927 |
AC Milan appears on two rows and Manchester United on two, so their city and founding year are written twice. The two Manchester United rows already disagree: Ryan Giggs's row says the club was founded in 1878, Paul Scholes's row (the cell in red) says 1902, the year the club took its current name.
Nothing in the sheet says which copy is right. Repeating a fact on several rows is called redundancy, and this is what it leads to: sooner or later two copies of the same fact differ.
The normalized form gives each kind of thing a table of its own: players, clubs and cities. A player's row no longer copies the club's details. It holds the club's identifier, a pointer called a foreign key, and the club's row holds the identifier of its city in the same way.
| _id | name |
|---|---|
| 1 | Barcelona |
| 2 | Milan |
| 3 | Manchester |
| 4 | Rome |
| _id | name | founded | city_id |
|---|---|---|---|
| 1 | FC Barcelona | 1899 | 1 |
| 2 | AC Milan | 1899 | 2 |
| 3 | Manchester United | 1878 | 3 |
| 4 | AS Roma | 1927 | 4 |
| _id | name | born | club_id |
|---|---|---|---|
| 1 | Carles Puyol | 1978 | 1 |
| 2 | Paolo Maldini | 1968 | 2 |
| 3 | Franco Baresi | 1960 | 2 |
| 4 | Ryan Giggs | 1973 | 3 |
| 5 | Paul Scholes | 1974 | 3 |
| 6 | Francesco Totti | 1976 | 4 |
Manchester United's founding year is now written in one place, the club's own row. Ryan Giggs and Paul Scholes both point at club 3, so they cannot disagree about it. The six players, four clubs and four cities of the sheet are all still there; only the copies are gone.
Each of the eight points below comes from the same cause, a fact stored once, and each is shown on the example in both forms.
Correcting Manchester United's founding year means finding every row that names the club, two here and hundreds in a real sheet, and changing each one. A row that is missed keeps the old value, and the sheet disagrees with itself again.
The correction is one cell, the founding year of club 3. Every player pointing at club 3 reads the corrected value.
UPDATE club SET founded = 1878 WHERE _id = 3;
Francesco Totti's row is the only one naming AS Roma: deleting it erases the club, its city and its founding year with him. In the other direction, a club with no player listed yet, such as Inter Milan, has no row to be written on.
Deleting player 6 leaves club 4, AS Roma, in place. Inter Milan is added as club 5 (the row in green) before any of its players, pointing at city 2, Milan, which is already there.
| _id | name | founded | city_id |
|---|---|---|---|
| 4 | AS Roma | 1927 | 4 |
| 5 | Inter Milan | 1908 | 2 |
Nothing stops a seventh row from naming a club “Manchester Utd” in a city spelled “Manchestr”. To the sheet, that is a new club in a new city, and nobody is told.
The database checks every pointer: a player row pointing at club 9 is rejected, because no club has that identifier. When the club's name is declared as its key, a second row named “AC Milan” is rejected too.
INSERT INTO player (name, born, club_id) VALUES ('Xavi', 1980, 9);
-- refused: no row of club has _id = 9Recording the country of each city adds a column to fill on all six rows, with “Italy” typed three times and “England” twice. Each new row repeats it again.
The country is one new column on the city table: four values, one per city (the cells in green). The player and club tables are not touched. A new kind of thing, such as stadiums, becomes a table of its own that clubs point at.
| _id | name | country |
|---|---|---|
| 1 | Barcelona | Spain |
| 2 | Milan | Italy |
| 3 | Manchester | England |
| 4 | Rome | Italy |
“How many clubs were founded before 1900?” has no direct answer. The sheet has six rows for four clubs, so the clubs must first be told apart by their names, and Manchester United falls on both sides of 1900 depending on the row that is read.
The question is asked of the club table, which has one row per club: three clubs. “Which cities have several clubs?” is answered the same way, by counting the clubs pointing at each city.
SELECT count(*) FROM club WHERE founded < 1900;
Another system, a ticketing tool or a CRM, can only match a club by its name, and “Man United”, “Manchester United” and “Manchester United F.C.” are three different texts.
The club has one identifier, 3, however its name is written. The other system stores that identifier, and a club that is renamed keeps every link to it.
“Milan” is written on every row of a Milan club. An Italian version of the sheet means translating the city on each of those rows, and keeping all the translations identical afterwards.
The city's name exists in one row, so it is translated once per language (the cells in green). Every club and every player pointing at city 2 then reads “Milano” in Italian, with no other row changed.
| _id | name (en) | name (fr) | name (it) |
|---|---|---|---|
| 1 | Barcelona | Barcelone | Barcellona |
| 2 | Milan | Milan | Milano |
| 3 | Manchester | Manchester | Manchester |
| 4 | Rome | Rome | Roma |
Adding each club's stadium to the sheet means looking it up row by row: six lookups for four clubs, two of them done twice.
The stadium is looked up once per club: four lookups for six players. In a base where one club is cited by a hundred rows, ninety-nine lookups are saved, whether a person does them or a language model billed per request.
Reading the data back takes more work. The flat sheet shows a player, the club and the city on one line. The normalized tables need a join: a query that follows the pointers from player to club to city to rebuild that line.
SELECT player.name, club.name AS club, city.name AS city, club.founded FROM player JOIN club ON club._id = player.club_id JOIN city ON city._id = club.city_id;
Joins also take time on large tables. This is why reporting tools often read a flat copy rebuilt from the normalized tables: the copies exist again, but they are derived automatically and never edited by hand.
A flat table is enough when the data is written once and never corrected, when one person reads it by eye, or when it holds a single kind of thing with nothing repeated: a list of measurements, a log, an export made for one report.
Normalizing an existing sheet is four pieces of work: deciding which columns describe a thing of their own, choosing what tells two rows of that thing apart, recognizing that “Man United” and “Manchester United” are the same club, and rewriting every row as pointers. On six rows it takes minutes. On a sheet of fifty thousand rows it is a project, and part of it starts again each time a column is added.
Entity Enricher does these four steps from the data itself. It reads a sample and proposes the entities it describes, here players, clubs and cities, with the fields that identify each one, and the user accepts or changes the proposal. During enrichment, a semantic ID gives one identifier to a club written in several ways. A database sync then creates one table per kind of entity in a database the user owns, fills it, and applies a migration when the schema changes.
A field declared multilingual is filled in each requested language during the same run, once per entity, which is the seventh point above.