Boyce-Codd normal form (BCNF): every determinant is a superkey
Overview
BCNF strengthens 3NF: for every implied nontrivial FD X→A, X must be a superkey. Consider machine assignments R(P,L,M): each project P uses one machine M per lab L (PL→M), and each machine belongs to one lab (M→L). Candidate keys are PL and PM, so all attributes are prime. The dependency M→L passes 3NF but fails BCNF because M cannot determine P. This is a separate teaching model from the enrollment symbols. The original sample satisfies M→L, but its SQL table definition alone does not enforce that cross-row rule. Load the fixtures from lesson 1.
First example
SELECT a.project_id,m.lab_id,a.machine_idFROM norm_assignment a JOIN norm_machine m ON m.id=a.machine_idORDER BY a.project_id,m.lab_id,a.machine_id;Observed SQLite result (rows in JSON):
[ [ 1, 10, 101 ], [ 1, 20, 201 ], [ 2, 10, 101 ]]How it works
Decompose into Machine(M,L) and Assignment(P,M). Their intersection M determines Machine, which is sufficient for losslessness of this binary decomposition. Both components satisfy BCNF under projected FDs. The first query reconstructs the original sample assignments. The second query simulates adding project 1 to machine 102, which belongs to the same lab as machine 101. Local keys would allow this new pair but the joined data violates PL→M. Thus the split does not preserve that dependency through local constraints alone. A full treatment of dependency preservation follows next batch. Keeping a 3NF schema or designing additional integrity enforcement may be preferable; a plain pre-insert query alone does not ensure concurrent correctness.
Practical example
WITH trial AS ( SELECT project_id,machine_id FROM norm_assignment UNION ALL SELECT 1,102)SELECT t.project_id,m.lab_id,COUNT(DISTINCT t.machine_id)FROM trial t JOIN norm_machine m ON m.id=t.machine_idGROUP BY t.project_id,m.lab_id HAVING COUNT(DISTINCT t.machine_id)>1ORDER BY t.project_id,m.lab_id;Observed SQLite result (rows in JSON):
[ [ 1, 10, 2 ]]Practice and mistakes
Practice: compute M⁺ and PL⁺ and explain the 3NF exception. Predict the result of adding (2,201) to Assignment: it introduces no duplicate project/lab in the original sample. Do not assume BCNF always preserves every FD. The included offline Python checker verifies projected closures for these small models.