Skip to the stories
Excel & Power BI

Database Normalization: 2NF, BCNF and the Limits of 3NF

  • Lee Asher
  • 433 views

See how 2NF and BCNF prevent duplicated facts, and why converting a 3NF table can sometimes weaken a constraint.

Database Normalization: 2NF, BCNF and the Limits of 3NF

Database normalization is easiest to apply when you connect each rule to the problem it prevents. Second Normal Form (2NF) catches facts that depend on only part of a multi-column key. Boyce-Codd Normal Form (BCNF) catches facts that depend on something other than a key. Both aim to keep each fact in one place, but pushing a schema to BCNF can sometimes make a business constraint harder to enforce.

The mnemonic “the key, the whole key, and nothing but the key” offers a useful way to remember the progression. Its parts describe three different dependency checks: columns must be determined by a key, by the complete key when that key has multiple columns, and by a key rather than by some other attribute. The practical question is what determines each fact in the table.

Start with what determines each row

A relational table needs a key that identifies each row. Under the “key” part of the mnemonic, the other facts in a row should be determined by that key. In a point-of-sale table, for example, sale_id might identify a sale, while sale_amount, tax_amount and total describe that particular transaction.

An image showing a table of a simple POS database recording purchases at a retail shop.

A tax_rate presents a different dependency: it is a general fact, rather than a fact about one sale. Repeating it in every sale row creates unnecessary duplication. A separate table for that fact gives it a place of its own. The key check is a starting point; the next checks matter when keys contain multiple columns or when one non-key attribute determines another.

2NF: depend on the whole key

Second Normal Form addresses partial dependencies. It applies when a table has a composite key, meaning that multiple columns together identify a row. Every non-key fact should depend on the complete combination, not just one part or a subset of it.

Consider enrollment records identified by student_id, course_id and term. A student may take the same course in more than one term, so all three values are needed to distinguish an enrollment. A final grade belongs to that specific student, course and term combination; it depends on the whole key.

An image showing a table representing college course enrollments and final grades.

The instructor assignment, however, depends on the course and term. It does not depend on which student enrolled. If the instructor’s name appears in every enrollment row, one class’s assignment is stored repeatedly. Changing the instructor then means updating several rows. Miss one, and records for the same class can disagree.

That is an update anomaly: duplication makes an ordinary change vulnerable to inconsistent results. It also wastes space and complicates maintenance. The guiding principle is to store a fact once, in the table whose key actually determines it.

Decompose the enrollment data into two relations: one for the class offering, keyed by course_id and term, with its instructor; another for enrollments, keyed by student_id, course_id and term, with the student’s grade. Now each instructor assignment has a single home, while grades remain attached to individual enrollments.

An image showing the two tables merged.

This is the “whole key” rule in action: 2NF rules out non-key columns that depend on only part of a composite key. A single-column key has no proper subset, so this particular partial-dependency check does not arise in the same way.

Many teams add a surrogate identifier such as enrollment_id to make rows easier to reference. That can simplify joins or applications, but it does not change what the facts mean. The natural key remains the combination that identifies an enrollment, and the instructor assignment still depends on course and term. Adding a surrogate does not remove that dependency or, by itself, fix the duplication.

BCNF: depend on a key

BCNF tightens the dependency rule. For every non-trivial functional dependency, the attribute or set of attributes on the left must be a candidate key. A functional dependency says that knowing one value determines another: if case_id determines blood_type, each case identifier has one associated blood type.

A research case table might initially store only those two values. Adding a patient’s name and address brings more facts into the same relation. If a patient name determines the address and blood type, those facts are now represented both through the case identifier and through the patient name. The patient information belongs in a separate relation keyed by the patient identifier or other suitable key; case-specific research data can reference that patient.

An image showing the table of the stored patient blood type.

The expanded table below shows the additional patient details.

An image showing the expanded table, with two new columns: patient_name and patient_address.

Keeping patient details in the case table can produce an update anomaly if the same patient has multiple cases: a change to the address or other repeated information has to be made in each row. It can also produce a delete anomaly. If a patient’s last case is removed, the table may also lose the only stored connection between that patient’s name, address and blood type. Separating patient facts from case facts preserves them independently.

The “nothing but the key” phrase captures BCNF’s stricter demand: a column should not depend on a non-key attribute, even when the relation already meets 2NF. BCNF is named for mathematician Edgar Codd and Raymond F. Boyce.

Where 3NF differs

Third Normal Form is close to BCNF, and most tables that meet 3NF also meet BCNF. The distinction appears in a narrower situation involving overlapping candidate keys. 3NF permits a dependency whose determining attribute is not a key when the dependent attribute is prime, meaning it belongs to at least one candidate key. BCNF has no such exception.

Imagine a company training program that records employees, teams and mentors. An employee can participate in multiple teams. Each employee-team pairing has one mentor, and each mentor is assigned to one team, although a team can have several mentors. The dependencies are:

(employee, team) → mentor
mentor → team

The pair (employee, team) determines the mentor for that participation. But the mentor also determines the team, and mentor alone is not a key for the whole relation. That dependency violates BCNF. The table can still meet 3NF because team is part of a candidate key, making it a prime attribute.

An image showing a table of sample data.

The remaining design can still lose information when a row is deleted. If employee “Schrute, D.” leaves “Office Conflict Resolution,” deleting that employee-team row also removes the only record that Smith mentors that team. Splitting the data into separate BCNF relations for employee-team participation and mentor-team assignment keeps those facts independent.

Why BCNF can cost a constraint

Decomposition is not automatically a free improvement. A nurse roster shows the tradeoff. Each nurse has one shift, while each patient has one nurse per shift. The dependencies are nurse → shift and (patient, shift) → nurse. The candidate keys are (patient, nurse) and (patient, shift).

An image of a table showing an example hospital shift roster of nurses assigned to patients.

This relation meets 3NF because shift is part of a candidate key. It fails BCNF because nurse determines shift without being a key for the relation. Splitting it into BCNF relations can remove the duplication, but the original constraint that each patient has only one nurse per shift may no longer be enforceable by a constraint on either table alone. Enforcing it may require checking the joined data.

An image showing what happens when a 3NF table is decomposed into two separate BCNF-compliant tables.

The decomposed rows can allow “Mallon, Mary” to appear with two nurses on the same shift, even though the original relation ruled that out. That is the cost to assess: whether a dependency remains enforceable after decomposition, and what checks the application or database needs to perform.

Leaving the table in 3NF has its own drawbacks. If one nurse serves three patients, the nurse’s shift is repeated in three rows. A shift change requires several updates, creating the possibility of inconsistent values. And if a nurse has no patients, the relation has no row in which to record that nurse’s shift. BCNF removes that redundancy, while the patient-per-shift rule may need to be enforced across the decomposed relations.

Choosing the right decomposition

The core checks are practical: identify candidate keys, write down which attributes determine which facts, then look for dependencies that involve only part of a composite key or start from something that is not a key. For each proposed split, check both whether the original information can be reconstructed and whether the business rules still hold.

A table can always be decomposed to 3NF, but a BCNF decomposition may not preserve every functional dependency within an individual relation. In that exceptional 3NF case, the design choice involves weighing repeated facts and anomalies against the complexity of enforcing a constraint across tables. The schema should make the chosen rules explicit, particularly where enforcement depends on a join.

Fourth Normal Form and Fifth Normal Form address additional kinds of dependency. They’re less commonly taught, but they apply to real database designs too. For the rules covered here, the useful takeaway is to treat the mnemonic as a dependency check: find what determines each fact, store it with the key that determines it, and verify what a decomposition does to the constraints users rely on.

Source: Lee Asher · www.red-gate.com

Neighbouring cells