</> Class Docs

Normalization: Making Data Tidy

A picture explainer you can read in five minutes

Normalization is a fancy word for a simple idea:

Computers keep information in tables, kind of like charts on graph paper. A table has rows (going across) and columns (going down). Normalization is how we tidy those tables so the same fact is not written over and over.

A messy chart

Ms. Lee wants to remember each kid's favorite snack. She makes one big chart:

THE SNACK CHART (messy)
+--------+-----------------+-------------+----------+
| Kid    | Favorite Snack  | Snack Color | Price    |
+--------+-----------------+-------------+----------+
| Ava    | Apple           | Red         | 50c      |
| Ben    | Apple           | Red         | 50c      |
| Cara   | Banana          | Yellow      | 30c      |
| Dan    | Apple           | Rad  <-- oops, typo!   |
+--------+-----------------+-------------+----------+

See the problem? "Apple is red and costs 50c" is written three times. Poor Dan's row even has a spelling mistake: Rad instead of Red.

Why copying facts is trouble

Problem

What happens

Hard to change

If apples go up to 60c, you must fix every single apple row. Miss one and the chart disagrees with itself.

Wastes space

The computer stores "Apple, Red, 50c" again and again for no reason.

Mistakes sneak in

Type it 100 times and sooner or later you write Rad. Now the computer thinks that is a new color.

The tidy way

Split the one messy chart into two smaller charts. Each chart describes one kind of thing.

  • One chart is about kids.

  • One chart is about snacks.

Give every snack a short ID (like a name tag). The kids' chart just writes the ID instead of copying all the snack details.

KIDS                          SNACKS
+------+------+---------+      +---------+--------+--------+-------+
| Kid  | Name | SnackID |      | SnackID | Snack  | Color  | Price |
+------+------+---------+      +---------+--------+--------+-------+
|  1   | Ava  |   A     |----->|   A     | Apple  | Red    |  50c  |
|  2   | Ben  |   A     |--\   |   B     | Banana | Yellow |  30c  |
|  3   | Cara |   B     |---\->  (Ava, Ben, and Dan all point to A)
|  4   | Dan  |   A     |--/
+------+------+---------+

Now:

  • "Apple is red and costs 50c" is written one time, in the SNACKS chart.

  • Apples go up to 60c? Change one box. Everybody who points to A is instantly correct.

  • No room for a Rad typo, because nobody types the color anymore. They just point.

Say it like a rule

Word bank

table

A chart of information, with rows and columns.

row

One line going across. Usually one row = one thing (one kid, one snack).

column

One stack going down. All the boxes in a column hold the same kind of fact (all names, all prices).

key / ID

A short label that names a row so other tables can point to it.

normalization

Tidying tables so each fact is stored once and pointed to, not copied.

Another meaning of the word

Grown-ups also use "normalize" to mean squish numbers onto the same scale so they are easy to compare.

Imagine three plants of very different heights. Normalizing turns each height into a number from 0 to 1, where 1 is the tallest:

BEFORE (centimeters)          AFTER (0 to 1 scale)

Plant A |##                   Plant A |##                0.20
Plant B |#########            Plant B |#########         0.90
Plant C |##########           Plant C |##########        1.00
        +------------                 +------------
        0        100                  0           1

Same shape, friendlier numbers. Computers do this a lot when they are learning patterns, because it keeps one giant number from bossing all the small ones around.

Try it yourself