Boyce-Codd Normal Form (BCNF)

Understand the stricter Boyce-Codd normal form, spot a violation in a workshop mentoring table, and fix it by splitting the table.

By Kevin McAleer,    7 Minutes

Page last updated November 24, 2026


Course Cover Image


By the end of this lesson you will be able to state the Boyce-Codd rule, recognise a table that breaks it, and split that table so it complies.


Third normal form catches most design problems. Boyce-Codd normal form (BCNF) closes a small gap that remains, and it appears when a table has more than one way to identify a row. It is a stricter cousin of 3NF, sometimes called “3.5NF”.

The rule

Some columns determine others: knowing robot_id tells you the robot’s name. We write that as robot_id -> name, and call it a functional dependency.

BCNF: whenever one set of columns determines another, the determining columns must be able to identify the whole row on their own (a candidate key).

In plain words: if a column can decide the value of another column, it had better be a key. Almost all well-designed tables already follow this, which is why the problem cases feel a bit contrived.

A table that breaks the rule

The workshop runs tool sessions. Each builder books a tool, and each tool is taught by one mentor. The rules of the club:

  1. A builder can book several tools, but each tool only once.
  2. Each mentor teaches exactly one tool (Ada always does soldering, Grace always does 3D printing).
  3. A tool can have more than one mentor.
CREATE TABLE tool_sessions (
    builder TEXT,
    tool    TEXT,
    mentor  TEXT,
    PRIMARY KEY (builder, tool)
);

INSERT INTO tool_sessions VALUES
    ('Kev', 'soldering',   'Ada'),
    ('Sam', 'soldering',   'Ada'),
    ('Kev', '3d printing', 'Grace'),
    ('Jo',  '3d printing', 'Grace');

The key is (builder, tool), and that determines the mentor. This table is in 3NF. But rule 2 gives us another dependency, mentor -> tool, and mentor alone is not a key, because Ada appears in several rows. That breaks BCNF.

flowchart LR
    A["builder + tool"] -->|"determines"| C["mentor"]
    C -->|"determines (but is not a key)"| B["tool"]

Why it matters: an anomaly

Ada switches from soldering to laser cutting. We try to record that for one row:

UPDATE tool_sessions SET tool = 'laser cutting'
WHERE mentor = 'Ada' AND builder = 'Kev';

SELECT * FROM tool_sessions ORDER BY builder, tool;
builder  tool           mentor
-------  -------------  ------
Jo       3d printing    Grace
Kev      3d printing    Grace
Kev      laser cutting  Ada
Sam      soldering      Ada

Now Ada teaches laser cutting for Kev and soldering for Sam, which contradicts rule 2. The table let us store a state that should be impossible, because the fact “Ada teaches X” is written in every one of her rows.

Put the data back before we fix the design:

DELETE FROM tool_sessions;
INSERT INTO tool_sessions VALUES
    ('Kev', 'soldering',   'Ada'),
    ('Sam', 'soldering',   'Ada'),
    ('Kev', '3d printing', 'Grace'),
    ('Jo',  '3d printing', 'Grace');

The fix: split the table

Give the mentor -> tool fact its own table, where mentor is the key. Then keep only who booked which mentor:

CREATE TABLE mentors (
    mentor TEXT PRIMARY KEY,
    tool   TEXT NOT NULL
);
CREATE TABLE bookings (
    builder TEXT NOT NULL,
    mentor  TEXT NOT NULL REFERENCES mentors (mentor),
    PRIMARY KEY (builder, mentor)
);

INSERT INTO mentors  SELECT DISTINCT mentor, tool FROM tool_sessions;
INSERT INTO bookings SELECT builder, mentor FROM tool_sessions;

INSERT ... SELECT copies rows straight from one table into another, which is a handy way to migrate data. Check the pieces:

SELECT * FROM mentors;
mentor  tool
------  -----------
Ada     soldering
Grace   3d printing

Now Ada’s change is one update, in one place:

UPDATE mentors SET tool = 'laser cutting' WHERE mentor = 'Ada';

SELECT b.builder, m.tool, m.mentor
FROM bookings AS b
JOIN mentors AS m ON m.mentor = b.mentor
ORDER BY b.builder, m.tool;
builder  tool           mentor
-------  -------------  ------
Jo       3d printing    Grace
Kev      3d printing    Grace
Kev      laser cutting  Ada
Sam      laser cutting  Ada

Every one of Ada’s bookings now agrees. The join rebuilds the original view of the data whenever you want it.

3NF versus BCNF

Question 3NF BCNF
Rule Non-key columns depend only on the key Every determining column set must be a key
Strictness Allows a dependency whose target is part of a key Allows no exceptions
Cost Rarely loses anything Can lose the ability to enforce a rule with a constraint

The trade-off is in that last row. After our split, nothing stops one builder from booking two soldering mentors, whereas rule 1 said each tool only once per builder. BCNF removed a contradiction but made one rule harder to enforce. In practice, designers aim for BCNF and accept 3NF when a split would lose an important rule.

Teachers: this is the most abstract lesson in the course. Try the “who determines what” game on paper first: write each rule on a card, and have pairs mark which columns decide which. Students who struggle can safely stop at 3NF and move on, as BCNF is a refinement and nothing later depends on it.

Try it Yourself

  1. Add a new mentor, Linus, who teaches laser cutting, and book Jo with him. Which tables do you change?
  2. Query which builders have booked a mentor who teaches soldering. Use the join from above.
  3. Challenge: a courses(room, hour, teacher) table has the rule that each teacher always uses the same room. Which dependency breaks BCNF, and how would you split the table?

Common Issues

  • Problem: I can’t tell whether a column is a key or just unique-looking.
  • Solution: Ask “could two rows ever share this value in the real world?” If yes, it isn’t a key, however unique your sample data looks.
  • Why: Keys are rules about the real world, not patterns in a few rows.

  • Problem: FOREIGN KEY constraint failed when I insert into bookings.
  • Solution: Insert into mentors first, as bookings points at it.
  • Why: A booking can’t refer to a mentor who doesn’t exist yet.

  • Problem: My split table seems to have lost data.
  • Solution: Use INSERT ... SELECT DISTINCT for the lookup table, and check row counts with COUNT(*).
  • Why: Without DISTINCT, duplicate mentors cause a primary key clash. Without the copy, rows never arrive.

Check your understanding

Quick quiz 1 of 3

What does BCNF require?

Quick quiz 2 of 3

In tool_sessions, why does mentor -> tool break BCNF?

Quick quiz 3 of 3

What did splitting into mentors and bookings fix?

Now let’s learn to put one query inside another.

< Previous Next >

Was this lesson helpful?

Course complete

Congratulations, you finished Getting Started with SQL!

That's all 16 lessons done. Let people know, it's a great way to inspire someone else to start.

Share card: I completed Getting Started with SQL on KevsRobots
Post Bluesky LinkedIn Facebook


What are you looking for?
Watch Videos Get Ideas Learn Something Read a Review Read the Blog Search
... Z Z z