DEV Community

Discussion on: ELI5: What is a database normalization?

Collapse
xowap profile image
Rémy 🤖

It's all about having a single source of truth.

Suppose you have an e-commerce store, specialized in selling fine beers.

Imagine you have those tables:

  • beer for the beers themselves
  • client are the clients
  • review are reviews left by clients on beers
  • order are the orders

When a client leaves a review, you don't want to embed the client's data inside the review but just to create a link. This way when the client changes his profile picture it gets updated on all his comments at once.

However when a client makes an order you want to copy both the client's information and the product's information (like the price). This way even if the client changes his address later or the product changes its price then the order still is accurately describing what was paid and where it was shipped.

All you're looking for is the truth, nothing more. If a single item of data were to appear twice in a database, which one would you trust? On the other hand, you need to make sure that the data you're storing is the truth.