Lossless decomposition: avoid spurious tuples
Overview
A decomposition is lossless if joining the projections reconstructs every legal original relation exactly. For a binary decomposition R into R1 and R2 under only functional dependencies F, the criterion is (R1 ∩ R2) → R1 or (R1 ∩ R2) → R2 in F+. Assume classical non-NULL set relations. Example 1 uses the V49 relation R(A,B,C), with no nontrivial FDs assumed other than the full key. Joining AB and BC on B yields two original and two spurious triples. Load the three fixtures described in lesson 5.
First example
WITH ab AS (SELECT DISTINCT a,b FROM norm_lossy),bc AS (SELECT DISTINCT b,c FROM norm_lossy)SELECT ab.a,ab.b,bc.c FROM ab JOIN bc ON ab.b=bc.bEXCEPT SELECT a,b,c FROM norm_lossyORDER BY 1,2,3;Observed SQLite result (rows in JSON):
[ [ 1, 10, 200 ], [ 2, 10, 100 ]]How it works
Example 2 compares a lossless reconstruction of the training enrollment relation against the original. Learner ID determines learner name, course ID determines title and instructor ID, and instructor ID determines instructor name. The binary splits from V48 meet the criterion, so their successive joins are lossless under these FDs. EXCEPT in both directions is a useful diagnostic: each result must be empty. It is not a proof over all legal instances; nor does it test duplicate multiplicity because EXCEPT removes duplicates. The binary criterion is specific to FD-based binary splits, not an arbitrary multiway JD test. A foreign key helps enforce references but is not by itself a proof of losslessness for an arbitrary decomposition.
Practical example
SELECT * FROM fd_enrollmentEXCEPTSELECT e.learner_id,e.course_id,l.name,c.title,c.instructor_id,i.name,e.statusFROM norm_enrollment_final e JOIN norm_learner l ON l.id=e.learner_idJOIN norm_course c ON c.id=e.course_id JOIN norm_instructor i ON i.id=c.instructor_id;Observed SQLite result (rows in JSON):
[]Practice and mistakes
Practice: reverse the EXCEPT comparison in example 2 and expect no rows. Explain why joining the lossy split creates false associations rather than merely missing rows. For bag data also compare grouped multiplicities.