Database Design and Normalization

Database design is the discipline of turning a set of real-world data requirements into a schema of tables, columns, keys, and relationships that MySQL can store and query reliably. A well-designed schema avoids storing the same fact in more than one place, which in turn avoids the update, insert, and delete anomalies that redundant data causes: a fact changed in one row but not another, a fact that cannot be recorded until an unrelated fact exists, or a fact that disappears when an unrelated row is deleted.

This chapter works through the standard design process: modeling the entities and relationships in the problem domain, expressing the rules that must hold between columns as functional dependencies, and then applying a series of increasingly strict normal forms to remove redundancy from the resulting tables. It closes with two decisions every working schema eventually faces: when to denormalize on purpose, and how to choose between surrogate and natural primary keys.

Most production schemas target 3NF or BCNF — normalized enough to remove redundancy, denormalized enough to keep the queries the application actually runs fast. Higher normal forms (4NF, 5NF) matter mostly when a single table mixes two or more independent multi-valued facts about the same entity, a case that comes up less often but produces subtle duplication when it does.