Skip to the guide

Normalisation vs denormalisation

IntermediateConcept3 pages

Normalising means storing each fact once. Denormalising means copying a fact to where it's read. Interviewers bring it up whenever a read needs data from several places, and they listen for the cost you choose: extra lookups on every read, or extra writes and copies that can fall out of step.

A sports club's team sheets

A sports club keeps one membership list with every member's number, name and phone number. Each week's team sheet just lists member numbers; to ring a player, the coach looks the number up on the membership list. Coaches got tired of that, so team sheets started carrying phone numbers too. Ringing round got quicker. Then a player changed her number, and only half the team sheets were fixed, so some coaches kept ringing a dead line.

  • the coaches → the services that read, such as the feed service
  • the membership list → a normalised table: each fact in one place
  • member numbers on the team sheets → foreign keys, looked up when read (a join)
  • phone numbers copied onto team sheets → denormalised data: faster to read, more to update
  • the dead line → an update anomaly: copies that disagree