How to Check Third Normal Form (3NF): Find Transitive Dependencies
title: "How to Check Third Normal Form (3NF): Find Transitive Dependencies" summary: "Third Normal Form (3NF) requires a relation to be in 2NF and, for every functional dependency X → A, either X to be a superkey or A to be a prime attribute. This guide tests that rule with a supplier and company example, shows a decomposition, and explains the narrower BCNF rule." --- # How to Check Third Normal Form (3NF): Find Transitive Dependencies
title: "How to Check Third Normal Form (3NF): Find Transitive Dependencies" summary: "Third Normal Form (3NF) requires a relation to be in 2NF and, for every functional dependency X → A, either X to be a superkey or A to be a prime attribute. This guide tests that rule with a supplier and company example, shows a decomposition, and explains the narrower BCNF rule."
How to Check Third Normal Form (3NF): Find Transitive Dependencies
Third Normal Form (3NF) requires a relation to be in 2NF and, for every functional dependency X → A, either X to be a superkey or A to be a prime attribute. In practice, look for a non-key attribute that determines another non-prime attribute. For example, if a supplier belongs to a company and each company is assigned one city, check whether the company city needs to be repeated in every supplier row. University of Wollongong CSCI235 lecture slides
What kind of redundancy does 3NF detect?
A functional dependency X → Y means that, under a business rule, the same value of X must imply the same value of Y. A candidate key is a minimal set of attributes that uniquely identifies a row. A superkey is any identifying set that contains a candidate key. A prime attribute belongs to at least one candidate key. This article uses functional dependencies in the relational model; a pattern that happens to appear in a few sample rows is not by itself a business rule.
Where 2NF addresses non-prime attributes determined by only part of a composite candidate key, 3NF also addresses dependencies whose determinant is not a key but that still determine another non-prime attribute. A common path is key → non-prime attribute → another non-prime attribute. That middle attribute matters: the last fact may otherwise be repeated in many rows. BCcampus: Database Design, Chapter 7
Find a violation in a supplier example
Consider this relation:
SUPPLIER(supplier_id, supplier_name, company_id, company_city)Assume the following business rules for this example:
Each supplier ID determines one supplier name and one company: `supplier_id → supplier_name, company_id`.
Each company ID determines one registered city: `company_id → company_city`.
Supplier ID is a candidate key for supplier rows.
These rules also imply supplier_id → company_city. With several suppliers, however, the same company city is repeated. If a company changes its registered city, every supplier row for that company must be updated. Missing one row creates conflicting values. This relation also cannot easily record a company that has no supplier yet.
To test the violation formally, examine each nontrivial functional dependency. In company_id → company_city, company_id is not a superkey for the whole relation: one company may have many suppliers. We assume company_city is non-prime because it belongs to no candidate key. The dependency therefore fails the 3NF condition. Do not decide from the intuition of “two steps from the key” alone; check separately whether the determinant is a superkey and whether the right-hand attribute is prime.
What rules and joins remain after decomposition?
Store the company city once, with its company ID:
CREATE TABLE company (
company_id bigint PRIMARY KEY,
company_city text NOT NULL
);
CREATE TABLE supplier (
supplier_id bigint PRIMARY KEY,
supplier_name text NOT NULL,
company_id bigint NOT NULL REFERENCES company(company_id)
);This is illustrative PostgreSQL 18 DDL; it was not executed. The primary key on company enforces company_id → company_city. The foreign key ensures a supplier references an existing company. To display the supplier, company ID, and city together, join the tables:
SELECT s.supplier_id, s.supplier_name, s.company_id, c.company_city
FROM supplier AS s
JOIN company AS c USING (company_id);In this example, company_id is a key on one side of the join, so a supplier row does not multiply into several rows. The example assumes one current city per company. If cities vary by branch or the database must preserve relocation history, a different model, perhaps including a validity period such as (company_id, valid_from), is needed. Copying a decomposition without checking the business rules can make the schema semantically wrong.
How do you check a schema for 3NF?
Write functional dependencies from actual business rules, not column names. State rules such as “one company code identifies one city” and “only the current city is stored.”
Compute attribute closures to find all candidate keys. Checking only the chosen primary key can miss another candidate key. Record the candidate keys and whether each dependent attribute is prime.
Split each dependency's right-hand side into single attributes and ignore trivial dependencies. For each `X → A`, 3NF holds if `X` is a superkey or `A` is prime; either condition is sufficient.
For a dependency that fails, trace which non-key fact is repeated and consider insert, update, and delete scenarios. The actual anomalies depend on the business rules and data.
After decomposition, check that the needed rows can be reconstructed through joins and that important dependencies can be enforced with keys, unique constraints, or other constraints in the resulting tables. A rule that exists only in application queries is not automatically enforced by the database.
A relation with only two attributes is ordinarily in 3NF: it cannot also contain a separate non-key determinant and non-prime dependent attribute that violate the rule. Also, if every candidate key has one attribute, there can be no 2NF violation caused by a proper subset of that key. But this does not make 3NF automatic. As in the supplier example, a single key may still determine another non-key attribute, which in turn determines a non-prime attribute. University of Wollongong: 3NF and its alternative definition
How is 3NF different from BCNF?
3NF permits every nontrivial functional dependency whose determinant is a superkey or whose right-hand attribute is prime. BCNF is stricter: every nontrivial determinant must be a superkey, regardless of the right-hand attribute.
Suppose LOCATION(city, street, zipcode) satisfies (city, street) → zipcode and zipcode → city, and its candidate keys are (city, street) and (zipcode, street). Both city and zipcode are then prime. The determinant zipcode is not a superkey, but city is prime, so that dependency can satisfy 3NF while violating BCNF. Rather than declaring one form universally better, compare which constraints can be checked within a single table and whether the redundancy reduction justifies a decomposition. Depending on the decomposition, BCNF may make some functional dependencies impossible to enforce as a constraint on one table alone. University of Wollongong: comparing 3NF and BCNF
What should a practical review record?
Record the candidate keys, the prime/non-prime classification, the dependencies checked, and where each rule will be enforced after decomposition. This explains not just that the schema was split, but which business rule caused repetition and where the revised design enforces it.
Normal forms guide schema design; constraints such as primary keys, unique constraints, foreign keys, and validation logic enforce behavior. PostgreSQL supports declarative constraints, but a CHECK constraint cannot safely enforce every business rule spanning multiple rows. For a rule involving several rows or tables, review the limitations in the official constraint documentation and choose an appropriate constraint or transaction design. PostgreSQL 18: Constraints