skip to content

What makes a decomposition of one table into two tables lossless-join, and what goes wrong when that condition does not hold?

level: middleimportance: must knowfreq 40%

answer

  1. join must return exactly the original rows
  2. shared columns = superkey of one piece
  3. lossy adds rows, does not drop them
  4. employee-department-project spurious tuples
  5. split on a determinant, keyed by the FK you leave

basics

~20 s

A split is lossless when the natural join of the two pieces returns exactly the original rows. The condition: the shared columns must functionally determine all of at least one piece, meaning they form a superkey there. Otherwise the join invents spurious rows that were never in the original.

solid answer

~50 s

Decomposing R into R1 and R2 is lossless-join when joining R1 and R2 on their common columns reproduces R exactly, no rows missing and no rows added. The test is simple: the intersection of R1 and R2 must be a superkey of R1 or of R2. In other words the shared columns must uniquely identify rows in at least one of the pieces. When the condition fails you get spurious tuples. Split R(employee, department, project) into (employee, department) and (department, project). The shared column is department, which is not a key of either piece. Joining them pairs every employee in a department with every project of that department, so the result contains employee-project combinations that were never facts. The join returns more rows than you started with, and the original is unrecoverable. Note the counterintuitive naming: lossless does not mean no rows are lost, it means no information is lost, and the usual failure adds rows rather than dropping them.

code

text · 6 lines
text
original R                 ED(employee,dept)   DP(dept,project)
(Ann, Sales, Alpha)        (Ann, Sales)        (Sales, Alpha)
(Bob, Sales, Beta)         (Bob, Sales)        (Sales, Beta)

ED JOIN DP ON dept  ->  Ann-Alpha, Ann-Beta*, Bob-Alpha*, Bob-Beta
                        (* never asserted; original is unrecoverable)

go deeper

for a junior

Know that a split must rejoin to the original and that the join column should be the primary key of one of the tables.

for a middle

State the superkey condition precisely, show the spurious-tuple example, and explain why textbook decompositions satisfy it automatically.

for a senior

Add why the lossy failure is worse than the redundancy it replaces, and describe how you would verify a decomposition against real data before cutting over.

for a principal

Treat it as the non-negotiable safety gate on any schema restructuring, with a verification step in the migration plan rather than a trust-the-model assumption.

## What the property actually says Normalization proceeds by splitting tables. The whole approach is only safe if the split is reversible, so the correctness criterion is: joining the pieces back together on their shared columns yields exactly the original set of rows. That is the lossless-join property, sometimes called non-additive join, which is the more honest name because the failure mode is extra rows rather than missing ones. ## The condition for a binary split For R decomposed into R1 and R2, the decomposition is lossless if and only if the common attributes determine one of the pieces entirely. Written as a functional dependency, either (R1 intersect R2) determines R1, or (R1 intersect R2) determines R2. Equivalently: the shared columns form a superkey of at least one of the two tables. The intuition is matching. During the join, each row of R1 finds the rows of R2 that share its join-column values. If the shared columns are a key of R2, each R1 row matches at most one R2 row, so the join cannot manufacture combinations. If they are a key of neither, one shared value can match many rows on both sides, and the join produces the cross product of those groups. ## The spurious-tuple example R(employee, department, project) with rows (Ann, Sales, Alpha) and (Bob, Sales, Beta). Split into ED(employee, department) and DP(department, project). ED holds (Ann, Sales) and (Bob, Sales). DP holds (Sales, Alpha) and (Sales, Beta). The shared column, department, is not a key of either. The join gives four rows: Ann-Alpha, Ann-Beta, Bob-Alpha, Bob-Beta. Two of those are fabrications. Worse, they are indistinguishable from the real ones, so the original data cannot be recovered from the decomposition. Information has been destroyed even though every original row is still present somewhere. ## The correct split Split the same table into EP(employee, project) and ED(employee, department) instead, assuming an employee belongs to one department. The shared column, employee, is a key of ED, so each EP row matches exactly one ED row and the join reconstructs R precisely. The general recipe when extracting a fact: the extracted table should be keyed by the column you leave behind as a foreign key. Every normalization step from 2NF up follows this pattern, which is why textbook decompositions are lossless by construction, you split on a determinant, and a determinant is by definition a key of the new table. ## Relationship to the anomalies Losslessness is the safety condition that makes anomaly removal legitimate. Any table can be split to reduce redundancy; the question is whether you can still answer the questions you could answer before. A lossy split trades a visible problem, duplicated facts, for an invisible one, fabricated facts, which is strictly worse because it produces confidently wrong query results with no error. ## How to verify in practice For a two-way split, checking the superkey condition is enough and takes seconds. For an n-way split there is a tableau-based chase algorithm, but interviews almost never go there. The practical check for engineers: after decomposing, does the join key uniquely identify rows in the parent table, and does a COUNT of the rejoined result match the COUNT of the original? A larger count is the immediate signal of a lossy split.

  • Why is it called lossless when the failure actually produces extra rows?
    The loss is of information, not of rows. When the join fabricates combinations, real facts and invented ones become indistinguishable, so the original relation can no longer be recovered from the pieces. The alternative name, non-additive join, describes the mechanism more accurately: a correct decomposition adds nothing when rejoined.
  • Why are the standard normalization decompositions lossless by construction?
    Because each step extracts a set of attributes along with the determinant they depend on, and that determinant becomes the primary key of the new table. The shared column is therefore a superkey of the extracted piece, which is exactly the lossless-join condition. You only get a lossy split when you split on a column that determines neither side, such as a non-key attribute shared between two relationships.

saying these in an interview costs you the question

  • Believing lossless means no rows disappear, and therefore that a split can never be lossy
  • Thinking any decomposition is safe as long as you keep a common column to join on
  • Confusing the lossless-join condition with dependency preservation, which is a separate property
  • Assuming a foreign key constraint guarantees the split was lossless

context