Decomposition

Decomposing relations has the purpose of fixing the problems (redundancy) created by functional dependencies when they are not superkeys.

BCNF Decomposition Algorithm
Given a functional dependency $$X \rightarrow Y$$ belonging to a relation $$R$$ we can decompose the relation by taking all attributes that are not $$Y$$ and make that into a new relation $$R _1$$ and take $$X$$ and $$Y$$ to make another relation $$R _2$$

Lossless Decomposition
Decomposition of $$R$$ into $$X$$ and $$Y$$ is said to be lossless if and only if $$F^+$$ contains
 * 1) $$X \cap Y \rightarrow X$$, or
 * 2) $$X \cap Y \rightarrow Y$$

Quick Tip
If $$W \rightarrow Z$$ holds over $$R$$ and $$W \cap Z$$ is empty, then decomposition of $$R$$ into $$R - Z$$ and $$WZ$$ is guaranteed to be lossless

Projection
The projection of $$F$$ on attribute set $$X$$ (denoted $$F _X$$) is the set of functional dependencies $$U \rightarrow V$$ in $$F^+$$ such that all of the attributes on both sides of the functional dependency are in $$X$$. That is, $$U,V \supseteq X$$

Definition
Decomposition of $$R$$ into $$X$$ and $$Y$$ is said to be dependency preserving if $$(F _X \cup F _Y)^+ = F^+$$

Lossless Decomposition
We see in the example to the right that $$X \cap Y = C$$ and through the functional dependency $$C \rightarrow B$$, we see that $$C \rightarrow Y$$

Dependency Preserving Decomposition

 * $$R = \{ ABC \}$$
 * $$F = \{ A \rightarrow B, B \rightarrow C, C \rightarrow A \}$$

Is the decomposition of $$R$$ into $$X = AB$$ and $$Y = BC$$ dependency preserving?

To answer this question, we must first consider $$F^+$$
 * $$F^+ = F \cup \{ A \rightarrow C, B \rightarrow A, C \rightarrow B \}$$

Then, we must consider $$F _X$$ and $$F _Y$$
 * $$F _X = \{ A \rightarrow B, B \rightarrow A \}$$
 * $$F _Y = \{ B \rightarrow C, C \rightarrow B \}$$

Computing, we get $$F _X \cup F _Y = \{ A \rightarrow B, B \rightarrow A, B \rightarrow C, C \rightarrow B \}$$

The last step is to calculate the closure of $$F _X \cup F _Y$$. Computing for $$(F _X \cup F _Y)^+ = (F _X \cup F _Y) \cup \{ A \rightarrow C, C \rightarrow A \} = F^+$$. Therefore, this decomposition is dependency preserving.