tezvyn:

Third Normal Form (3NF): Nothing But The Key

AI-drafted, machine-checkedSource: Wikipedia: Third normal formintermediate

Third Normal Form (3NF) dictates that every non-key column must describe 'nothing but the key.' This prevents transitive dependencies, where one non-key column determines another.

WHY IT EXISTS Third Normal Form (3NF) was created to solve data anomalies that arise from transitive dependencies. If a non-key attribute depends on another non-key attribute, you create redundant data. For example, storing a department's location in every employee row for that department means changing the location requires many updates, risking inconsistency.

THE MENTAL MODEL The rule of thumb is that a non-key field must provide a fact about "the key, the whole key, and nothing but the key." 3NF is the "nothing but the key" part. It means that every column that isn't part of the primary key must depend exclusively on that primary key, not on any other non-key column.

HOW IT WORKS A table is in 3NF if two conditions are met: first, it is already in Second Normal Form (2NF), and second, it contains no transitive dependencies. A transitive dependency exists when a non-prime attribute (a column not in any candidate key) functionally depends on another non-prime attribute. To achieve 3NF, you break these dependencies out into their own tables. For example, if Column C depends on Column B, and Column B depends on the key Column A, you would split this into two tables: one with A and B, and another with B and C.

WHEN TO USE IT Use 3NF as the default for most transactional database designs (OLTP systems). It's the industry standard for ensuring data integrity, eliminating redundancy, and preventing update, insert, and delete anomalies. It keeps your schema clean and maintainable.

WHEN NOT TO USE IT You might intentionally violate 3NF (a process called denormalization) for performance reasons, particularly in data warehouses or reporting databases (OLAP systems). The joins required by a fully normalized 3NF schema can be slow for complex queries. In these read-heavy scenarios, tolerating some data redundancy can lead to faster query performance.

ONE CANONICAL EXAMPLE Consider a table of employees: EmployeeID (PK), Name, Department, DepartmentManager. Here, DepartmentManager depends on Department, which in turn depends on EmployeeID. This is a transitive dependency and violates 3NF. To fix it, you create two tables. First, an Employees table with EmployeeID, Name, and DepartmentID (FK). Second, a Departments table with DepartmentID (PK), DepartmentName, and DepartmentManager. Now, every non-key attribute depends only on its table's primary key.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.