Chapter 6 of 7

Normalization

Functional Dependencies

Functional Dependency (FD) — Definition

A functional dependency $\alpha \rightarrow \beta$ holds on a relation $R$ if, for any two tuples $t_1$ and $t_2$ in $R$, whenever $t_1[\alpha] = t_2[\alpha]$, it must also be the case that $t_1[\beta] = t_2[\beta]$.

Key points:

  • $\alpha$ determines $\beta$ uniquely.

  • If $\alpha$ is a superkey, then $\alpha \rightarrow R$ holds.

  • Trivial FDs: $\beta \subseteq \alpha$, e.g., $A \rightarrow A$.

Example 221

Consider $r(A,B)$ with the following instance of $r$. On this instance, $B \rightarrow A$ holds; $A \rightarrow B$ does NOT hold, \[ \begin{array}{|c|c|} \hline A & B \\ \hline 1 & 4 \\ 1 & 5 \\ 3 & 7 \\ \hline \end{array} \]

Example 222: Sample Relation

Consider the following instance of relation $r(A,B,C,D)$:

diagram

Step-by-step FD analysis:

  • Check if $A \rightarrow C$ holds:

    • Tuples with $A = a1$: $c1, c1$ → same → OK

    • Tuples with $A = a2$: $c2, c2$ → same → OK

    • $A = a3$: only one tuple → trivially OK

    • Conclusion: $A \rightarrow C$ holds

  • Check if $C \rightarrow A$ holds:

    • Tuples with $C = c2$: $A = a2, a2, a3$ → different → violates FD

    • Conclusion: $C \rightarrow A$ does not hold

  • Check if $B \rightarrow D$ holds:

    • $B = b2$: tuples $(a1,b2,c1,d2)$ and $(a2,b2,c2,d2)$ → D = d2 in both → holds

    • $B = b3$: tuples $(a2,b3,c2,d3)$ and $(a3,b3,c2,d4)$ → D = d3, d4 → violates FD

    • Conclusion: $B \rightarrow D$ does not hold

  • Trivial FDs:

    • $A \rightarrow A$, $B \rightarrow B$, $C \rightarrow C$, $D \rightarrow D$ always hold

    • Any FD $\alpha \rightarrow \beta$ where $\beta \subseteq \alpha$ is trivial

Summary:

  • Non-trivial FD that holds: $A \rightarrow C$

  • Non-trivial FDs that do not hold: $C \rightarrow A$, $B \rightarrow D$

Example 223: Finding FDs — Student Table
diagram

Analysis:

  • sNo uniquely identifies student name and department → FD: $sNo \rightarrow sName, dNo$.

  • dNo uniquely identifies department name → FD: $dNo \rightarrow dName$.

  • Combination $sNo, dNo$ is a superkey → $sNo, dNo \rightarrow sName, dName$.

Example 224: Employee Table FDs
diagram

Analysis:

  • empID is unique → $empID \rightarrow empName, dept, salary$

  • dept does not determine salary (Sales has multiple salaries) → no FD $dept \rightarrow salary$

  • Combination empID, dept → still determines all attributes (superkey)

Example 225: Course Table FDs
diagram

Analysis:

  • cNo uniquely identifies course → $cNo \rightarrow cName, credits$

  • cName does not determine credits (Math appears twice, same credits here, but could vary in other instances)

Example 226: Register Table FDs
diagram

Analysis:

  • Combination (sNo, cNo) determines grade → $(sNo, cNo) \rightarrow grade$

  • sNo alone does not determine grade (student has multiple courses)

  • cNo alone does not determine grade (multiple students take the same course)

Example 227: Classroom Table FDs
diagram

Analysis:

  • (building, roomNo) uniquely identifies capacity and type → $(building, roomNo) \rightarrow capacity, type$

  • roomNo alone does not determine capacity (room 101 exists in both buildings with different capacities)

Example 228: Composite Keys and FDs
diagram

Analysis:

  • Composite key (orderID, productID) → quantity, price

  • orderID alone does not determine quantity or price

  • productID alone does not determine quantity or price

FDs — Key Takeaways
  • Identify superkeys: sets of attributes that uniquely identify tuples.

  • Determine FDs by checking if a value of attribute(s) consistently determines other attribute(s) across all tuples.

  • Trivial FDs always hold: $\alpha \rightarrow \beta$ is trivial if $\beta \subseteq \alpha$.

  • Non-trivial FDs indicate constraints and guide normalization.

  • Use tables to verify candidate keys and dependent attributes.

Types of Functional Dependency

Trivial Functional Dependency

Every dependent in trivial functional dependency is a subset of the determinant. If $Y$ is a subset of $X$, the functional relationship $X \rightarrow Y$ is referred to as trivial.

Example 229: Example — Employee Table

\[ \begin{array}{ccc} \text{Employee\_Id} & \text{Name} & \text{Age} \\ 1 & \text{Zayn} & 24 \\ 2 & \text{Phobe} & 34 \\ 3 & \text{Hikki} & 26 \\ 4 & \text{David} & 29 \\ \end{array} \] Given that the dependent Name is a subset of the determinant Employee_Id, Name, the functional dependency between $\{ \text{Employee\_Id, Name} \}$ and $\{ \text{Name} \}$ is trivial. Additionally, Name, Age, and Employee_Id are also trivial.

Non-Trivial Functional Dependency

The non-trivial functional dependency is opposed to the trivial one. Formally, the dependent is not a subset of the determinant. If $Y$ is not a subset of $X$, the relationship $X \rightarrow Y$ is non-trivial.

Example 230: Example — Employee Table

\[ \begin{array}{ccc} \text{Employee\_Id} & \text{Name} & \text{Age} \\ 1 & \text{Zayn} & 24 \\ 2 & \text{Phobe} & 34 \\ 3 & \text{Hikki} & 26 \\ 4 & \text{David} & 29 \\ 5 & \text{Phobe} & 24 \\ \end{array} \] Because Name (dependent) is not a subset of Employee_Id, there is a non-trivial functional dependency between Employee_Id and Name. The functional dependencies $\{ \text{Employee\_Id, Name} \} \rightarrow \{ \text{Age} \}$ are also non-trivial.

Multi-Valued Functional Dependency

Attributes in the dependent set are not reliant on each other in multi-valued dependency. If there is no functional dependency between $Y$ and $Z$, the relationship $X \rightarrow Y, Z$ is referred to as multi-valued functional dependency.

Example 231: Example — Employee Table

\[ \begin{array}{ccc} \text{Employee\_Id} & \text{Name} & \text{Age} \\ 1 & \text{Zayn} & 24 \\ 2 & \text{Phobe} & 34 \\ 3 & \text{Hikki} & 26 \\ 4 & \text{David} & 29 \\ 4 & \text{Phobe} & 24 \\ \end{array} \] Since the dependent attributes Name and Age are not functionally dependent, $\{ \text{Employee\_Id} \} \rightarrow \{ \text{Name, Age} \}$ is a multi-valued functional dependency.

Transitive Functional Dependency

Given two functional dependencies $A \rightarrow B$ and $B \rightarrow C$, $A \rightarrow C$ must also exist according to the transitivity principle. In transitive functional dependency, the dependent is indirectly reliant on the determinant.

Example 232: Example — Employee Table

\[ \begin{array}{cccc} \text{Employee\_Id} & \text{Name} & \text{Department} & \text{Street Number} \\ 1 & \text{Zayn} & \text{CD} & 11 \\ 2 & \text{Phobe} & \text{AB} & 24 \\ 3 & \text{Hikki} & \text{CD} & 11 \\ 4 & \text{David} & \text{PQ} & 71 \\ 5 & \text{Phobe} & \text{LM} & 21 \\ \end{array} \] The relationships between Employee_Id, Department, and Street Number are valid. Consequently, $\{ \text{Employee\_Id} \}$ and $\{ \text{Street Number} \}$ are both valid functional dependencies according to the axiom of transitivity.

Armstrong’s axioms (Inference rules)

Armstrong’s Axioms are a set of rules that, when applied repeatedly, generate a closure of functional dependencies.

Axiom of Reflexivity

If $B \subseteq A$, then $A \rightarrow B$. This property is trivial: every set of attributes functionally determines its subsets.

Example 233: Example — Reflexivity

Let $A = \{ \text{EmpID, Name} \}$ and $B = \{ \text{Name} \}$. Since $B \subseteq A$, by reflexivity: \[ \{ \text{EmpID, Name} \} \rightarrow \{ \text{Name} \} \] is a valid functional dependency.

Axiom of Augmentation

If $A \rightarrow B$ holds and $C$ is any attribute set, then $AC \rightarrow BC$ also holds. Adding attributes to both sides preserves the dependency.

Example 234: Example — Augmentation

If $\text{EmpID} \rightarrow \text{Name}$, then by augmentation: \[ \{ \text{EmpID, Dept} \} \rightarrow \{ \text{Name, Dept} \} \] also holds.

Axiom of Transitivity

If $A \rightarrow B$ and $B \rightarrow C$, then $A \rightarrow C$. This is similar to the transitive property in algebra.

Example 235: Example — Transitivity

If $\text{EmpID} \rightarrow \text{Dept}$ and $\text{Dept} \rightarrow \text{Manager}$, then $\text{EmpID} \rightarrow \text{Manager}$ also holds.

Union Rule

If $A \rightarrow B$ and $A \rightarrow C$, then $A \rightarrow BC$.

Example 236: Example — Union

If $\text{EmpID} \rightarrow \text{Name}$ and $\text{EmpID} \rightarrow \text{Dept}$, then $\text{EmpID} \rightarrow \text{Name, Dept}$.

Composition Rule

If $A \rightarrow B$ and $X \rightarrow Y$, then $AX \rightarrow BY$.

Example 237: Example — Composition

If $\text{EmpID} \rightarrow \text{Name}$ and $\text{DeptID} \rightarrow \text{DeptName}$, then $\{\text{EmpID, DeptID}\} \rightarrow \{\text{Name, DeptName}\}$.

Decomposition Rule

If $A \rightarrow BC$, then $A \rightarrow B$ and $A \rightarrow C$.

Example 238: Example — Decomposition

If $\text{EmpID} \rightarrow \{\text{Name, Dept}\}$, then $\text{EmpID} \rightarrow \text{Name}$ and $\text{EmpID} \rightarrow \text{Dept}$.

Pseudo Transitivity

If $A \rightarrow B$ and $BC \rightarrow D$, then $AC \rightarrow D$.

Example 239: Example — Pseudo Transitivity

If $\text{EmpID} \rightarrow \text{Dept}$ and $\{\text{Dept, Location}\} \rightarrow \text{Manager}$, then $\{\text{EmpID, Location}\} \rightarrow \text{Manager}$.

Self Determination

Every attribute set functionally determines itself: $A \rightarrow A$.

Example 240: Example — Self Determination

$\text{EmpID} \rightarrow \text{EmpID}$ is always true.

Extensivity

If $AC \rightarrow A$ and $A \rightarrow B$, then $AC \rightarrow B$. Also leads to $AC \rightarrow BC$ and $ABC \rightarrow BC$.

Example 241: Example — Extensivity

If $\{\text{EmpID, Dept}\} \rightarrow \text{EmpID}$ and $\text{EmpID} \rightarrow \text{Name}$, then $\{\text{EmpID, Dept}\} \rightarrow \text{Name}$.

Example 242: Reflexivity — MCQ

When an FD is reflexive, $Y$ is a subset of $X$ and $X$ refers to the set of attributes, then:

  1. $Y \rightarrow X$ holds

  2. $X \rightarrow Y$ holds

  3. $XY \rightarrow Z$ holds

  4. None of the above

Answer: B. $X \rightarrow Y$ holds

Explanation: When an FD is reflexive, $Y \subseteq X$, so $X \rightarrow Y$ always holds according to Armstrong's reflexivity axiom.

Example 243: Union — MCQ

If $P \rightarrow Q$ and $P \rightarrow R$, then which of these would be true?

  1. $P \rightarrow QR$

  2. $P \rightarrow Q$

  3. $P \rightarrow R$

  4. All of the above

Answer: D. All of the above

Explanation: By the union rule, if $P \rightarrow Q$ and $P \rightarrow R$, then $P \rightarrow QR$ holds. Individual dependencies also hold.

Closure of attributes & Finding Candidate Keys

Closure of an Attribute

Closure of an Attribute

The closure of an attribute (or attribute set) is the set of all attributes that can be functionally determined from it, given a set of functional dependencies.

Purpose:

  • Determine candidate keys

  • Test dependency preservation

  • Normalize relations

Algorithm to Compute $X^+$ (Closure of $X$): Corrected Closure Calculation Input: A set \(F\) of functional dependencies on a relation schema \(R\), and a set of attributes \(X \subseteq R\).

  1. $X^+ \gets X$    // Initialize closure with \(X\) itself

  2. Repeat

  3.    $\text{oldX}^+ \gets X^+$    // Snapshot current set at the start of the loop

  4.    For each functional dependency \(Y \rightarrow Z\) in \(F\):

  5.       If $X^+ \supseteq Y$, then $X^+ \gets X^+ \cup Z$    // Add new attributes

  6.    End For

  7. Until $X^+ = \text{oldX}^+$    // If no changes occurred in this pass, STOP

  8. Return $X^+$

Example 244: Closure of Single Attribute

Consider relation \(R(A,B,C,D,E,F)\) with FDs: \[ F: E \rightarrow A, \; E \rightarrow D, \; A \rightarrow C, \; A \rightarrow D, \; AE \rightarrow F, \; AG \rightarrow K \]

Find \(E^+\):

\[ \begin{aligned} E^+ & = E \\ & = EA \quad \text{(from } E \rightarrow A\text{)} \\ & = EAD \quad \text{(from } E \rightarrow D\text{)} \\ & = EADC \quad \text{(from } A \rightarrow C\text{)} \\ & = EADCF \quad \text{(from } AE \rightarrow F\text{)} \\ & = EADCF \quad \text{(from } AG \rightarrow K \text{, not added since } AG \nsubseteq E^+) \end{aligned} \]

Thus, \(E^+ = \{E, A, D, C, F\}\).

Example 245: Closure of Multiple Attributes

Consider relation \(R(A,B,C,D,E,F,G)\) with FDs: \[ F: E \rightarrow A, \; E \rightarrow D, \; A \rightarrow C, \; A \rightarrow D, \; AE \rightarrow F, \; AG \rightarrow K, \; BC \rightarrow DE, \; D \rightarrow F, \; CF \rightarrow G \]

Compute closures:

Closure of attribute A: \[ \begin{aligned} A^+ & = \{A\} \\ & = \{A, B, C\} \quad (\text{Using } A \rightarrow BC) \\ & = \{A, B, C, D, E\} \quad (\text{Using } BC \rightarrow DE) \\ & = \{A, B, C, D, E, F\} \quad (\text{Using } D \rightarrow F) \\ & = \{A, B, C, D, E, F, G\} \quad (\text{Using } CF \rightarrow G) \end{aligned} \]

Closure of attribute D: \[ D^+ = \{D, F\} \quad (\text{Using } D \rightarrow F) \]

Closure of attribute set \(\{B,C\}\): \[ \begin{aligned} \{B,C\}^+ & = \{B, C\} \\ & = \{B, C, D, E\} \quad (\text{Using } BC \rightarrow DE) \\ & = \{B, C, D, E, F\} \quad (\text{Using } D \rightarrow F) \\ & = \{B, C, D, E, F, G\} \quad (\text{Using } CF \rightarrow G) \end{aligned} \]

Thus, \(\{B,C\}^+ = \{B,C,D,E,F,G\}\).

Finding Candidate Keys

Candidate Key — Definition and Steps

A candidate key is defined as:

  • A minimal set of attributes that can uniquely identify each tuple in a relation.

  • Equivalently, a minimal superkey is a candidate key.

Steps to find candidate keys:

  1. Step 1: Find essential attributes

    • Essential attributes are not present on the RHS of any functional dependency OR Attributes that do not appear in any dependency at all.

    • Essential attributes must be in every candidate key.

  2. Step 2: Identify non-essential attributes

    • Remaining attributes that appear on RHS of some FD.

    • If essential attributes alone can determine all non-essential attributes, they form the only candidate key.

    • Otherwise, combine essential attributes with some non-essential attributes to form all possible candidate keys.

No. of Super Keys

Let $|R| = n$ (total attributes) and $CK$ be a Candidate Key of size $k$.

  • Case 1: Single Candidate Key
    The number of superkeys is given by: $N = 2^{n-k}$

  • Case 2: Two Candidate Keys ($K_1$ and $K_2$)
    Using the Principle of Inclusion-Exclusion: \[ |S_1 \cup S_2| = |S_1| + |S_2| - |S_1 \cap S_2| \] In terms of attributes: \[ N = 2^{n-|K_1|} + 2^{n-|K_2|} - 2^{n-|K_1 \cup K_2|} \]

  • Case 3: Three Candidate Keys ($K_1, K_2, K_3$)
    Applying the Principle of Inclusion-Exclusion (PIE): \[ N = \sum |S_i| - \sum |S_i \cap S_j| + |S_1 \cap S_2 \cap S_3| \] In terms of attributes: \[ N = (2^{n-|K_1|} + 2^{n-|K_2|} + 2^{n-|K_3|}) - (2^{n-|K_1 \cup K_2|} + 2^{n-|K_2 \cup K_3|} + 2^{n-|K_1 \cup K_3|}) + 2^{n-|K_1 \cup K_2 \cup K_3|} \]

  • Special Case (All attributes are Essential)
    If all $n$ attributes are essential, then the only candidate key is the set of all attributes ($k=n$): \[ N = 2^{n-n} = 2^0 = 1 \] In this case, the only superkey is the Relation $R$ itself.

Example 246: Finding Candidate Key — Simple Closure

Relation: $R(A, B, C, D, E, F)$

Functional Dependencies: \[ C \rightarrow F, \quad E \rightarrow A, \quad EC \rightarrow D, \quad A \rightarrow B \]

Step 1: Essential attributes \[ \text{Attributes not on RHS: } C, E \quad \Rightarrow \text{Essential attributes} = \{C, E\} \]

Step 2: Compute closure of essential attributes \[ \{ CE \}^+ = \{ C, E \} \xrightarrow{C \rightarrow F} \{ C, E, F \} \xrightarrow{E \rightarrow A} \{ A, C, E, F \} \xrightarrow{EC \rightarrow D} \{ A, C, D, E, F \} \xrightarrow{A \rightarrow B} \{ A, B, C, D, E, F \} \]

Conclusion: $CE$ can determine all attributes.

Candidate Key: $CE$ (only one)

Super Keys: Essential attributes = 2, Non-essential = 4

\[ \text{Number of super keys} = 2^4 = 16 \]

Example 247: Candidate Key — Another Example

Relation: $R(A, B, C, D, E)$

Functional Dependencies: \[ AB \rightarrow C, \quad C \rightarrow D, \quad B \rightarrow E \]

Step 1: Essential attributes \[ \text{Attributes not on RHS: } A, B \quad \Rightarrow \text{Essential attributes} = \{A, B\} \]

Step 2: Compute closure of essential attributes \[ \{ AB \}^+ = \{ A, B \} \xrightarrow{AB \rightarrow C} \{ A, B, C \} \xrightarrow{C \rightarrow D} \{ A, B, C, D \} \xrightarrow{B \rightarrow E} \{ A, B, C, D, E \} \]

Conclusion: $AB$ can determine all attributes.

Candidate Key: $AB$ (only one)

Super Keys: Essential = 2, Non-essential = 3 \[ \text{Number of super keys} = 2^3 = 8 \]

Example 248: Candidate Key — Multiple Attributes

Relation: $R(E, F, G, H, I, J, K, L, M, N)$

Functional Dependencies: \[ \{ E, F \} \rightarrow G, \quad F \rightarrow I, J, \quad \{ E, H \} \rightarrow K, L, \quad K \rightarrow M, \quad L \rightarrow N \]

Step 1: Essential attributes \[ \text{Attributes not on RHS: } E, F, H \quad \Rightarrow \text{Essential attributes} = \{ E, F, H \} \]

Step 2: Compute closure of essential attributes \begin{align*} \{ EFH \}^+ &= \{ E, F, H \} &&\xrightarrow{EF \rightarrow G} \{ E, F, G, H \} \\ &&\xrightarrow{F \rightarrow I, J} \{ E, F, G, H, I, J \} \\ &&\xrightarrow{EH \rightarrow K, L} \{ E, F, G, H, I, J, K, L \} \\ &&\xrightarrow{K \rightarrow M} \{ E, F, G, H, I, J, K, L, M \} \\ &&\xrightarrow{L \rightarrow N} \{ E, F, G, H, I, J, K, L, M, N \} \end{align*}

Candidate Key: $EFH$ (only one)

Super Keys: Essential = 3, Non-essential = 7 \[ \text{Number of super keys} = 2^7 = 128 \]

Example 249: Candidate Key — Optional Attributes

Relation: $R(A, B, C, D, E, H)$

Functional Dependencies: \[ A \rightarrow B, \quad BC \rightarrow D, \quad E \rightarrow C, \quad D \rightarrow A \]

Essential attributes: $E, H$

Candidate Keys: All options containing essential attributes that determine remaining attributes: \[ \text{Candidate Keys: } AEH, BEH, DEH \]

Answer: Option (D)

Canonical Cover

Equivalence of Functional Dependencies

Equivalence of Functional Dependencies

Two sets of functional dependencies $E$ and $F$ are said to be equivalent if

\[ E^+ = F^+ \]

Equivalently,

\[ E \equiv F \]

iff

  • $E$ covers $F$

  • $F$ covers $E$

Example 250

Let

\[ F = \{A \rightarrow C,\ AC \rightarrow D,\ E \rightarrow AD,\ E \rightarrow H\} \]

\[ G = \{A \rightarrow CD,\ E \rightarrow AH\} \]

Step 1: Check $F$ covers $G$

Check $A \rightarrow CD$

Compute $A^+$ using $F$

\[ A^+ = \{A\} \]

Using $A \rightarrow C$

\[ A^+ = \{A,C\} \]

Using $AC \rightarrow D$

\[ A^+ = \{A,C,D\} \]

Hence

\[ A \rightarrow CD \]

holds.

Check $E \rightarrow AH$

Compute $E^+$ using $F$

\[ E^+ = \{E\} \]

Using $E \rightarrow AD$

\[ E^+ = \{E,A,D\} \]

Using $A \rightarrow C$

\[ E^+ = \{E,A,D,C\} \]

Using $E \rightarrow H$

\[ E^+ = \{E,A,D,C,H\} \]

Hence

\[ E \rightarrow AH \]

holds.

\[ \therefore F \text{ covers } G \]

Step 2: Check $G$ covers $F$

Check $A \rightarrow C$

Compute $A^+$ using $G$

\[ A^+ = \{A\} \]

Using $A \rightarrow CD$

\[ A^+ = \{A,C,D\} \]

Hence

\[ A \rightarrow C \]

holds.

Check $AC \rightarrow D$

Since $A \rightarrow CD$

\[ AC \rightarrow D \]

holds.

Check $E \rightarrow AD$

Compute $E^+$ using $G$

\[ E^+ = \{E\} \]

Using $E \rightarrow AH$

\[ E^+ = \{E,A,H\} \]

Using $A \rightarrow CD$

\[ E^+ = \{E,A,H,C,D\} \]

Hence

\[ E \rightarrow AD \]

holds.

Check $E \rightarrow H$

Directly given.

\[ \therefore G \text{ covers } F \]

Conclusion

\[ F \equiv G \]

Hence the two sets of functional dependencies are equivalent.

Example 251

Let

\[ F = \{a \rightarrow b,\ b \rightarrow c,\ c \rightarrow d\} \]

\[ G = \{a \rightarrow bc,\ c \rightarrow d\} \] Step 1: Check if $F$ covers $G$ We check each FD in $G$ using the rules in $F$:

  • Check $a \to bc$: Compute $a^+$ using $F$: $a^+ = \{a, b, c, d\}$. Since $\{b, c\} \subseteq a^+$, $a \to bc$ is Covered.

  • Check $c \to d$: Compute $c^+$ using $F$: $c^+ = \{c, d\}$. Since $d \in c^+$, $c \to d$ is Covered.

$\therefore F$ covers $G$.

Step 2: Check if $G$ covers $F$ We check each FD in $F$ using the rules in $G$:

  • Check $a \to b$: Compute $a^+$ using $G$: $a^+ = \{a, b, c, d\}$. Since $b \in a^+$, $a \to b$ is Covered.

  • Check $b \to c$: Compute $b^+$ using $G$: $b^+ = \{b\}$. Since $c \notin b^+$, $b \to c$ is NOT Covered.

  • Check $c \to d$: Compute $c^+$ using $G$: $c^+ = \{c, d\}$. Since $d \in c^+$, $c \to d$ is Covered.

$\therefore G$ does not cover $F$ (specifically due to $b \to c$).

Example 252

Let

\[ F = \{a \rightarrow b,\; ab \rightarrow c,\; d \rightarrow ac,\; d \rightarrow e\} \]

\[ G = \{a \rightarrow bc,\; d \rightarrow ab\} \]

Step 1: Check whether $F$ covers $G$

Check $a \rightarrow bc$

Compute $a^+$ using $F$

\[ a^+ = \{a\} \]

Using $a \rightarrow b$

\[ a^+ = \{a,b\} \]

Using $ab \rightarrow c$

\[ a^+ = \{a,b,c\} \]

Hence

\[ a \rightarrow bc \]

holds.

Check $d \rightarrow ab$

Compute $d^+$ using $F$

\[ d^+ = \{d\} \]

Using $d \rightarrow ac$

\[ d^+ = \{d,a,c\} \]

Using $a \rightarrow b$

\[ d^+ = \{d,a,c,b\} \]

Using $d \rightarrow e$

\[ d^+ = \{d,a,c,b,e\} \]

Hence

\[ d \rightarrow ab \]

holds.

\[ \therefore F \text{ covers } G \]

Step 2: Check whether $G$ covers $F$

Check $a \rightarrow b$

Compute $a^+$ using $G$

\[ a^+ = \{a\} \]

Using $a \rightarrow bc$

\[ a^+ = \{a,b,c\} \]

Hence $a \rightarrow b$ holds.

Check $ab \rightarrow c$

Since $a \rightarrow bc$

\[ ab \rightarrow c \]

holds.

Check $d \rightarrow ac$

Compute $d^+$ using $G$

\[ d^+ = \{d\} \]

Using $d \rightarrow ab$

\[ d^+ = \{d,a,b\} \]

Using $a \rightarrow bc$

\[ d^+ = \{d,a,b,c\} \]

Hence $d \rightarrow ac$ holds.

Check $d \rightarrow e$

Compute $d^+$ using $G$

\[ d^+ = \{d,a,b,c\} \]

Attribute $e$ cannot be derived.

Hence

\[ d \rightarrow e \]

does not hold.

\[ \therefore G \text{ does not cover } F \]

Conclusion

\[ F \not\equiv G \]

Hence the two FD sets are not equivalent.

Example 253

Let

\[ F = \{pq \rightarrow r,\; p \rightarrow q,\; s \rightarrow pq,\; s \rightarrow t\} \]

\[ G = \{p \rightarrow qr,\; s \rightarrow pt\} \]

Step 1: Check whether $F$ covers $G$

Check $p \rightarrow qr$

Compute $p^+$ using $F$

\[ p^+ = \{p\} \]

Using $p \rightarrow q$

\[ p^+ = \{p,q\} \]

Using $pq \rightarrow r$

\[ p^+ = \{p,q,r\} \]

Hence

\[ p \rightarrow qr \]

holds.

Check $s \rightarrow pt$

Compute $s^+$ using $F$

\[ s^+ = \{s\} \]

Using $s \rightarrow pq$

\[ s^+ = \{s,p,q\} \]

Using $pq \rightarrow r$

\[ s^+ = \{s,p,q,r\} \]

Using $s \rightarrow t$

\[ s^+ = \{s,p,q,r,t\} \]

Hence

\[ s \rightarrow pt \]

holds.

\[ \therefore F \text{ covers } G \]

Step 2: Check whether $G$ covers $F$

Check $pq \rightarrow r$

Compute $pq^+$ using $G$

\[ pq^+ = \{p,q\} \]

Using $p \rightarrow qr$

\[ pq^+ = \{p,q,r\} \]

Hence

\[ pq \rightarrow r \]

holds.

Check $p \rightarrow q$

Compute $p^+$ using $G$

\[ p^+ = \{p,q,r\} \]

Hence it holds.

Check $s \rightarrow pq$

Compute $s^+$ using $G$

\[ s^+ = \{s\} \]

Using $s \rightarrow pt$

\[ s^+ = \{s,p,t\} \]

Using $p \rightarrow qr$

\[ s^+ = \{s,p,t,q,r\} \]

Hence

\[ s \rightarrow pq \]

holds.

Check $s \rightarrow t$

Directly given in $G$.

\[ \therefore G \text{ covers } F \]

Conclusion

\[ F \equiv G \]

Hence the two sets of functional dependencies are equivalent.

Minimal Cover of Functional Dependencies

Minimal Cover Procedure

The Minimal Cover for a set of FDs $E$ is a set of FDs $F$ that satisfies the property that every dependency in $E$ is in the closure $F^+$, and $F$ contains no redundancies.

Procedure:

Step 1: Ensure every functional dependency (FD) has only a single attribute on the right-hand side.

  • Example: $A \to BC$ becomes $\{ A \to B, \; A \to C \}$.

Step 2: Delete Redundant FDs Check each FD against the remaining set to see if it can be inferred.

  • Action: For an FD $A \to B$, compute $A^+$ using all other FDs in the set.

  • Decision: If $B \in A^+$, the FD is Redundant and is deleted.

Step 3: Minimize Left Side (Extraneous Attributes) For FDs with multiple attributes on the left (e.g., $AB \to C$), check if one attribute is a "passenger."

Testing if $B$ is Extraneous in $AB \to C$: Compare the closure of the survivor ($A$) before and after removing $B$ from that specific FD.

diagram
Example 254: Finding Minimal Cover

Given Relation $R(A, B, C, D)$ and $FDs = \{A \to B, C \to B, D \to ABC, AC \to D\}$.

Step 1: Standard Form (Right-side Decomposition) 1) $A \to B$
2) $C \to B$
3) $D \to A$
4) $D \to B$
5) $D \to C$
6) $AC \to D$

Step 2: Delete Redundant FDs We check each FD against the remaining set:

  • Check $A \to B$: Compute $A^+$ from $\{2, 3, 4, 5, 6\}$. $A^+ = \{A\}$. $B \notin A^+$. (Keep)

  • Check $C \to B$: Compute $C^+$ from $\{1, 3, 4, 5, 6\}$. $C^+ = \{C\}$. $B \notin C^+$. (Keep)

  • Check $D \to B$: Compute $D^+$ from $\{1, 2, 3, 5, 6\}$. $D^+ = \{D, A, C\}$ (using 3 and 5), then $\{D, A, C, B\}$ (using 1 or 2). Since $B \in D^+$, $D \to B$ is Redundant and is deleted.

  • Check $D \to A$: $D^+$ from $\{1, 2, 5, 6\}$. $D^+ = \{D, C, B\}$. $A \notin D^+$. (Keep)

  • Check $D \to C$: $D^+$ from $\{1, 2, 3, 6\}$. $D^+ = \{D, A, B\}$. $C \notin D^+$. (Keep)

Step 3: Minimize Left Side (Extraneous Attributes) Check $AC \to D$ to see if $A$ or $C$ is redundant.

diagram

Final Irreducible Set (Minimal Cover) The resulting set of FDs is: $A \to B$
$C \to B$
$D \to AC$
$AC \to D$ }

Example 255: Finding Canonical Cover

Given: $F = \{ X \to YZ, \; Y \to Z, \; X \to Y, \; XY \to Z \}$

Step 1: Standard Form (Right-side Decomposition) 1) $X \to Y$
2) $X \to Z$
3) $Y \to Z$
4) $XY \to Z$

Step 2: Delete Redundant FDs Check each FD against the remaining set to see if it can be inferred:

  • Check $X \to Y$: $X^+$ from $\{2, 3, 4\}$. $X^+ = \{X, Z\}$. $Y \notin X^+$. (Keep)

  • Check $X \to Z$: $X^+$ from $\{1, 3, 4\}$. $X^+ = \{X, Y\}$ (using $X \to Y$), then $\{X, Y, Z\}$ (using $Y \to Z$). Since $Z \in X^+$, $X \to Z$ is Redundant and is deleted.

  • Check $Y \to Z$: $Y^+$ from $\{1, 4\}$. $Y^+ = \{Y\}$. $Z \notin Y^+$. (Keep)

  • Check $XY \to Z$: $(XY)^+$ from $\{1, 3\}$. $(XY)^+ = \{X, Y, Z\}$ (using $X \to Y$ and $Y \to Z$). Since $Z \in (XY)^+$, $XY \to Z$ is Redundant and is deleted.

Updated Set: $\{ X \to Y, \; Y \to Z \}$

Step 3: Minimize Left Side (Extraneous Attributes) In the updated set $\{ X \to Y, \; Y \to Z \}$, all dependencies have only a single attribute on the left side. No further minimization is required.

Final Irreducible Set (Minimal Cover) The resulting set of FDs is: $X \to Y$
$Y \to Z$ }

Example 256: Finding Canonical Cover

Given: $F = \{ A \to BC, \; CD \to E, \; B \to D, \; E \to A \}$

Step 1: Standard Form (Right-side Decomposition) 1) $A \to B$
2) $A \to C$
3) $CD \to E$
4) $B \to D$
5) $E \to A$

Step 2: Delete Redundant FDs We check each FD against the remaining set:

  • Check $A \to B$: $A^+$ from $\{2, 3, 4, 5\}$. $A^+ = \{A, C\}$. $B \notin A^+$. (Keep)

  • Check $A \to C$: $A^+$ from $\{1, 3, 4, 5\}$. $A^+ = \{A, B, D\}$. $C \notin A^+$. (Keep)

  • Check $B \to D$: $B^+$ from $\{1, 2, 3, 5\}$. $B^+ = \{B\}$. $D \notin B^+$. (Keep)

  • Check $E \to A$: $E^+$ from $\{1, 2, 3, 4\}$. $E^+ = \{E\}$. $A \notin E^+$. (Keep)

  • Check $CD \to E$: $CD^+$ from $\{1, 2, 4, 5\}$. $CD^+ = \{C, D\}$. $E \notin CD^+$. (Keep)

Current Set: $\{ A \to B, \; A \to C, \; B \to D, \; E \to A, \; CD \to E \}$

Step 3: Minimize Left Side (Extraneous Attributes) Check $CD \to E$ to see if $C$ or $D$ is redundant.

diagram

Final Irreducible Set (Minimal Cover) The set remains unchanged as no redundancies were found. $A \to BC$
$CD \to E$
$B \to D$
$E \to A$ }

Example 257: Finding Canonical Cover - Redundancy First

Given Relation $R(A, B, C, D)$ and $FDs = \{ AB \to C, \; A \to C, \; C \to D, \; B \to D \}$

Step 1: Standard Form (Right-side Decomposition) 1) $AB \to C$
2) $A \to C$
3) $C \to D$
4) $B \to D$

Step 2: Delete Redundant FDs Check each FD against the remaining set to see if it can be inferred:

  • Check $AB \to C$: Compute $(AB)^+$ using $\{2, 3, 4\}$. $(AB)^+ = \{A, B, C, D\}$. Since $C \in (AB)^+$, $AB \to C$ is Redundant and is deleted.

  • Check $A \to C$: Compute $A^+$ using $\{3, 4\}$. $A^+ = \{A\}$. $C \notin A^+$. (Keep)

  • Check $C \to D$: Compute $C^+$ using $\{2, 4\}$. $C^+ = \{C\}$. $D \notin C^+$. (Keep)

  • Check $B \to D$: Compute $B^+$ using $\{2, 3\}$. $B^+ = \{B\}$. $D \notin B^+$. (Keep)

Updated Set: $\{ A \to C, \; C \to D, \; B \to D \}$

Step 3: Minimize Left Side (Extraneous Attributes) We examine the FDs in the updated set for multi-attribute left sides:

  • $A \to C$: Single attribute LHS. No check needed.

  • $C \to D$: Single attribute LHS. No check needed.

  • $B \to D$: Single attribute LHS. No check needed.

Note: Since the only multi-attribute FD ($AB \to C$) was removed in Step 2, no further minimization is required.

Final Irreducible Set (Minimal Cover) The resulting set of FDs is: $A \to C$
$C \to D$
$B \to D$ }

Example 258: Canonical Cover: Step 3 is Mandatory

Given Relation $R(A, B, C, D)$ and $F = \{ A \to B, \; B \to C, \; AB \to D \}$.

Step 1: Standard Form (RHS Decomposition) 1) $A \to B$
2) $B \to C$
3) $AB \to D$

Step 2: Delete Redundant FDs Check if any entire FD can be inferred from the others:

  • Check $AB \to D$: $(AB)^+$ from $\{A \to B, B \to C\}$. $(AB)^+ = \{A, B, C\}$. Since $D \notin (AB)^+$, $AB \to D$ is NOT Redundant. It survives Step 2.

Step 3: Minimize Left Side (Extraneous Attributes) We check $AB \to D$ to see if $B$ is extraneous.

diagram

Note: After removing $B$, the FD $AB \to D$ simplifies to $A \to D$.

Final Irreducible Set (Minimal Cover) $A \to B$
$B \to C$
$A \to D$ }

Decomposition

Decomposition — Definition

Decomposition is the process of breaking a relation \(R\) into two or more sub-relations \(R_1, R_2, \dots\).

Properties of good decomposition:

  1. Lossless Decomposition: Joining the decomposed relations gives back the original relation; no information is lost.

  2. Dependency Preservation: All functional dependencies in the original relation can be enforced by the decomposed relations.

Lossless/Lossy Join Decomposition

Lossless Join Decomposition

Consider a relation \(R\) which is decomposed into sub-relations \(R_1, R_2, \ldots, R_n\).

This decomposition is called lossless join decomposition when the join of the sub-relations results in the same relation \(R\) that was decomposed.

For lossless join decomposition, we always have: \[ R_1 \bowtie R_2 \bowtie R_3 \ldots \bowtie R_n = R \] where \(\bowtie\) is the natural join operator.

Example 259: Lossless Join Decomposition

Consider the relation \(R(A, B, C)\):

diagram

Decompose \(R\) into \(R_1(A, B)\) and \(R_2(B, C)\):

\(R_1(A, B)\):

diagram

\(R_2(B, C)\):

diagram

Performing the natural join \(R_1 \bowtie R_2\) gives:

diagram

This is the same as the original relation \(R\), hence the decomposition is lossless.

Note on Lossless Join Decomposition

Lossless join decomposition is also known as non-additive join decomposition because no extraneous tuples appear after joining the sub-relations.

Lossy Join Decomposition

Consider a relation \(R\) which is decomposed into sub-relations \(R_1, R_2, \ldots, R_n\).

This decomposition is called lossy join decomposition when the join of the sub-relations does not result in the same relation \(R\).

For lossy join decomposition: \[ R_1 \bowtie R_2 \bowtie R_3 \ldots \bowtie R_n \supseteq R \] where \(\bowtie\) is the natural join operator. Some extraneous tuples appear in the join result.

Example 260: Lossy Join Decomposition

Consider the relation \(R(A, B, C)\):

diagram

Decompose \(R\) into \(R_1(A, C)\) and \(R_2(B, C)\):

\(R_1(A, C)\):

diagram

\(R_2(B, C)\):

diagram

Performing the natural join \(R_1 \bowtie R_2\) gives:

diagram

This relation is not the same as \(R\) and contains extraneous tuples. Hence, the decomposition is lossy.

Note on Lossy Join Decomposition

Lossy join decomposition is also known as careless decomposition because extraneous tuples make identification of original tuples difficult.

Determining Whether Decomposition Is Lossless Or Lossy

Consider a relation \(R\) decomposed into two sub-relations \(R_1\) and \(R_2\):

  1. Condition 1: Union of both sub-relations must contain all attributes of \(R\): \[ R_1 \cup R_2 = R \]

  2. Condition 2: Intersection of both sub-relations must not be null: \[ R_1 \cap R_2 \neq \emptyset \]

  3. Condition 3: Intersection of both sub-relations must be a super key of \(R_1\), \(R_2\), or both: \[ R_1 \cap R_2 = \text{Super key of } R_1 \text{ or } R_2 \]

If all three conditions are satisfied, the decomposition is lossless. If any condition fails, the decomposition is lossy.

Example 261: Lossy Decomposition Verification

Consider \(R(A, B, C, D)\) with functional dependencies \(A \rightarrow B\) and \(C \rightarrow D\). Decompose into \(R_1(A, B)\) and \(R_2(C, D)\).

Solution:

  • Condition-01: \(R_1 \cup R_2 = \{A, B, C, D\} = R\) \(\rightarrow\) satisfied

  • Condition-02: \(R_1 \cap R_2 = \emptyset\) \(\rightarrow\) fails

  • Condition-03: Not checked as Condition-02 failed

Hence, decomposition is lossy.

The Chase Algorithm

The Chase Algorithm

To determine if a decomposition $\{R_1, R_2, \dots, R_n\}$ is lossless:

  • Initialize: Build a tableau (Rows: $R_i$, Cols: Attributes).

  • Fill: Use real symbols ($a, b, c, \dots$) if attribute is present in $R_i$; otherwise use dummies ($a_i, b_i, c_i, \dots$).

  • Equate: If two rows match on an FD's LHS, equate their RHS.

    • Note: Always promote a dummy to a real symbol if possible.

  • Converge: Stop when no more changes can be made.

Any row is all real symbols $\implies$ Lossless
Otherwise $\implies$ Lossy

Example 262: Lossless Case: Chain Dependency

Consider $R(A, B, C, D)$ with FDs: $A \rightarrow B, B \rightarrow C, C \rightarrow D$. Decomposed into $R_1(A, B), R_2(B, C), R_3(C, D)$.

Step 1: Initial Tableau

diagram

Step 2: Apply $B \rightarrow C$
Rows $R_1$ and $R_2$ match on $B$ ($b$). Promote $c_1$ in $R_1$ to real symbol $c$.

diagram

Step 3: Apply $C \rightarrow D$
Now $R_1$ and $R_3$ match on $C$ ($c$). Promote $d_1$ in $R_1$ to real symbol $d$.

diagram

Row 1 is all real symbols $\implies$ Lossless.

Example 263: Lossy Case: Disconnected Attributes

Consider $R(A, B, C, D)$ with FDs: $A \rightarrow B, C \rightarrow D$. Decomposed into $R_1(A, B), R_2(B, C), R_3(C, D)$.

Step 1: Initial Tableau

diagram

Step 2: Apply $C \rightarrow D$
$R_2$ and $R_3$ match on $C$ ($c$). Promote $d_2$ in $R_2$ to $d$. Step 3: Apply $A \rightarrow B$
No rows match on $A$. No further changes possible. Since no row is $(a, b, c, d)$, it is Lossy.

Example 264: Lossless Case: Converging FDs

$R(A, B, C)$ with $A \rightarrow B, B \rightarrow A$. Decomposed into $R_1(A, C), R_2(B, C)$.

Initial Tableau:

diagram

Execution: No rows match on $A$ or $B$. However, if we added $C \rightarrow B$: Rows $R_1, R_2$ match on $C$. Promote $b_1 \rightarrow b$. Now $R_1$ is $(a, b, c) \implies$ Lossless.

Dependency Preserving Decomposition

Definition

A decomposition of a relation \(R\) into sub-relations \(R_1, R_2, \dots, R_n\) is called dependency preserving if all functional dependencies of \(R\) satisfy at least one of the following:

  1. The dependency is fully contained in one of the sub-relations \(R_i\), or

  2. The dependency can be derived from the FDs of the sub-relations without performing any joins.

In other words, all constraints of the original relation can be enforced locally in the sub-relations.

Why Dependency Preservation Matters
  • Ensures data integrity after decomposition.

  • Avoids expensive joins for enforcing constraints.

  • Desired in normalization (3NF or BCNF) to combine lossless join and dependency preservation.

Step-by-Step Method to Check Dependency Preservation

Suppose a relation \(R\) with functional dependencies \(F\) is decomposed into sub-relations \(R_1, R_2, \dots, R_n\). To check if the decomposition is dependency preserving:

  1. Find the functional dependencies \(F_i\) that hold in each sub-relation \(R_i\).

  2. Compute \(F' = F_1 \cup F_2 \cup \dots \cup F_n\).

  3. Compare \(F'\) with the original dependency set \(F\):

    • If all dependencies in \(F\) are in \(F'\) or derivable from \(F'\), the decomposition is dependency preserving.

    • If any dependency in \(F\) is missing and cannot be derived, the decomposition is not dependency preserving.

Example 265: Simple Dependency Preserving Decomposition

Let \(R(A, B, C, D)\) with FD set: \[ F = \{A \rightarrow B, A \rightarrow C, C \rightarrow D\} \]

Decompose \(R\) into: \[ R_1(A, B, C), \quad R_2(C, D) \]

Step 1: Find FDs in sub-relations

  • \(F_1 = \{A \rightarrow B, A \rightarrow C\}\) in \(R_1\)

  • \(F_2 = \{C \rightarrow D\}\) in \(R_2\)

Step 2: Combine FDs: \[ F' = F_1 \cup F_2 = \{A \rightarrow B, A \rightarrow C, C \rightarrow D\} = F \]

Conclusion: All original FDs are preserved. Hence, the decomposition is dependency preserving.

Example 266: Non-Dependency Preserving Decomposition

Let \(R(P, Q, R, S)\) with FD set: \[ F = \{PQ \rightarrow R, R \rightarrow S, S \rightarrow P\} \]

Decompose \(R\) into: \[ R_1(P, Q, R), \quad R_2(R, S) \]

Step 1: Find FDs in sub-relations

  • \(F_1 = \{PQ \rightarrow R, R \rightarrow P\}\) in \(R_1\)

  • \(F_2 = \{R \rightarrow S\}\) in \(R_2\)

Step 2: Combine FDs: \[ F' = F_1 \cup F_2 = \{PQ \rightarrow R, R \rightarrow S, R \rightarrow P\} \]

Step 3: Check original FDs

  • \(PQ \rightarrow R\) → present in \(F'\)

  • \(R \rightarrow S\) → present in \(F'\)

  • \(S \rightarrow P\) → missing, cannot be derived from \(F'\)

Conclusion: Not all original FDs are preserved. Hence, the decomposition is not dependency preserving.

Example 267: Dependency Preserving Decomposition - Example 3

Consider relation \(R(A, B, C, D, E)\) with functional dependencies: \[ F = \{A \rightarrow B, B \rightarrow C, C \rightarrow D, D \rightarrow E\} \]

Decompose \(R\) into: \[ R_1(A, B, C), \quad R_2(C, D, E) \]

Step 1: Find FDs in sub-relations

  • \(F_1 = \{A \rightarrow B, B \rightarrow C\}\) in \(R_1\)

  • \(F_2 = \{C \rightarrow D, D \rightarrow E\}\) in \(R_2\)

Step 2: Combine FDs: \[ F' = F_1 \cup F_2 = \{A \rightarrow B, B \rightarrow C, C \rightarrow D, D \rightarrow E\} = F \]

Step 3: Check all original FDs: All are present in \(F'\).

Conclusion: The decomposition is dependency preserving.

Example 268: Non-Dependency Preserving Decomposition - Example 4

Consider relation \(R(P, Q, R, S, T)\) with functional dependencies: \[ F = \{P \rightarrow Q, Q \rightarrow R, R \rightarrow S, S \rightarrow T, T \rightarrow P\} \]

Decompose \(R\) into: \[ R_1(P, Q, R), \quad R_2(R, S, T) \]

Step 1: Find FDs in sub-relations

  • \(F_1 = \{P \rightarrow Q, Q \rightarrow R\}\) in \(R_1\)

  • \(F_2 = \{R \rightarrow S, S \rightarrow T\}\) in \(R_2\)

Step 2: Combine FDs: \[ F' = F_1 \cup F_2 = \{P \rightarrow Q, Q \rightarrow R, R \rightarrow S, S \rightarrow T\} \]

Step 3: Check original FDs: The dependency \(T \rightarrow P\) is missing and cannot be derived from \(F'\).

Conclusion: The decomposition is not dependency preserving.

Normal Forms

Introduction to Normalization

The main reason for normalizing relations is to remove anomalies in the database. Failure to eliminate anomalies can lead to data redundancy, data inconsistency, and other integrity problems as the database grows.

Normalization consists of a series of guidelines that help in creating a well-structured database.

Data Modification Anomalies

Data modification anomalies can be categorized into three types:

  • Insertion Anomaly: Occurs when one cannot insert a new tuple into a relation due to lack of required data.

  • Deletion Anomaly: Occurs when the deletion of data unintentionally results in loss of other important data.

  • Update Anomaly: Occurs when updating a single data value requires multiple rows to be updated.

Definitions of Normal Forms

The standard normal forms in database design are defined as follows:

  • First Normal Form (1NF): A relation is in 1NF if all attributes contain atomic (indivisible) values.

  • Second Normal Form (2NF): A relation is in 2NF if it is in 1NF and all non-key attributes are fully functionally dependent on the candidate key.

  • Third Normal Form (3NF): A relation is in 3NF if it is in 2NF and has no transitive dependencies (i.e., non-key attributes depend only on candidate keys).

  • Boyce-Codd Normal Form (BCNF): A relation is in BCNF if it is in 3NF and for every functional dependency \(X \rightarrow Y\), \(X\) is a superkey.

  • Fourth Normal Form (4NF): A relation is in 4NF if it is in BCNF and does not contain any multi-valued dependencies.

  • Fifth Normal Form (5NF or Project-Join Normal Form): A relation is in 5NF if it is in 4NF and every join dependency is implied by the candidate keys.

diagram

First Normal Form (1NF)

Concept of 1NF

A relation is said to be in First Normal Form (1NF) if:

  1. Each attribute of every tuple contains only an atomic value, i.e., indivisible value.

  2. Multi-valued attributes are not allowed; a single cell cannot contain a set, list, or nested table.

  3. Attributes can be null, but must not be non-atomic (e.g., a list of values).

OR

A relation is in 1NF if the value of every attribute in each tuple is either single-valued or null.

Notes on 1NF
  • By default, every relation in a relational database is considered to be in 1NF, because atomicity is part of the definition of a relation.

  • 1NF is the first step in normalization, and all higher normal forms assume the relation is already in 1NF.

Example 269: 1NF - Step-by-Step

Problem: Check if the following relation is in 1NF and convert it if necessary.

diagram

Analysis:

  • The Subjects attribute contains multiple values for some students.

  • This violates the atomicity requirement of 1NF.

Solution: Convert to 1NF Rewrite the relation so that each cell contains a single value:

diagram

Conclusion: The above relation is now in 1NF because each attribute contains atomic values only.

Example 270: 1NF

Problem: Consider a relation storing employee skills:

diagram

Analysis:

  • The Skills attribute contains multiple values for some employees.

  • This violates the 1NF requirement of atomic values.

Solution: Convert to 1NF

diagram

Conclusion: Each cell now contains a single atomic value, so the relation is in 1NF.

Second Normal Form (2NF)

Partial Dependency

A partial dependency occurs when a non-prime attribute is functionally dependent on a part (subset) of a candidate key rather than the whole key.

Formal Definition: Let \(A \rightarrow B\) be a functional dependency in relation \(R\). It is a partial dependency if:

  • \(A\) is a proper subset of some candidate key, and

  • \(B\) is a non-prime attribute.

Note: - To avoid partial dependency, an incomplete candidate key must not determine any non-prime attribute. - An incomplete candidate key can determine prime attributes without violating 2NF.

Definition of 2NF

A relation \(R\) is in Second Normal Form (2NF) if and only if:

  1. \(R\) is already in 1NF.

  2. There are no partial dependencies in \(R\).

Procedure to Decompose a Relation into 2NF

Steps to Achieve 2NF

To decompose a relation \(R\) into Second Normal Form (2NF), follow these steps:

  1. Ensure 1NF: Verify that \(R\) is already in First Normal Form (1NF), i.e., all attributes contain atomic values.

  2. Identify Candidate Keys: Determine all candidate keys of \(R\). Identify prime attributes (attributes in any candidate key) and non-prime attributes (attributes not in any candidate key).

  3. Identify Partial Dependencies: Find all functional dependencies where a non-prime attribute is dependent on a part (subset) of a candidate key. These are partial dependencies.

  4. Create New Relations for Partial Dependencies: For each partial dependency \(X \rightarrow Y\), create a separate relation containing:

    • The determinant \(X\) (subset of candidate key)

    • All attributes functionally dependent on \(X\) (\(Y\))

  5. Retain Remaining Attributes: Create a relation containing:

    • All candidate key attributes

    • Remaining non-prime attributes not included in the new relations

  6. Verify 2NF: Check that in each resulting relation:

    • No non-prime attribute is partially dependent on any candidate key.

    • Each relation is in 1NF.

Result: The original relation \(R\) is now decomposed into a set of relations that are in 2NF.

Example 271: Procedure Illustration

Consider relation $R(A, B, C, D, E)$ with functional dependencies: \[ A \rightarrow B, \quad B \rightarrow E, \quad C \rightarrow D \]

Step 1: Identify Candidate Key
$(AC)^+ = \{A, C, B, E, D\}$. Candidate key = AC.
Prime attributes = $\{A, C\}$; Non-prime = $\{B, D, E\}$.

Step 2: Identify Partial Dependencies (Prime $\rightarrow$ Non-Prime)
- $A \rightarrow B$: Partial Dependency ($A \subset AC$). - $C \rightarrow D$: Partial Dependency ($C \subset AC$). - $B \rightarrow E$: NOT a partial dependency (Non-prime $\rightarrow$ Non-prime).

Step 3: Create New Relations for Partial Dependencies
- $R_1(A, B, E)$: Handles partial key $A$. $E$ moves here because $B \rightarrow E$ must follow $B$. - $R_2(C, D)$: Handles partial key $C$.

Step 4: Retain the Full Candidate Key
- $R_3(A, C)$: To act as the bridge/link.

Conclusion: Decomposition $\{R_1, R_2, R_3\}$ is in 2NF.

Example 272: Relation already in 2NF

Consider the relation $R(V, W, X, Y, Z)$ with functional dependencies: \[ VW \rightarrow XY, \quad Y \rightarrow V, \quad WX \rightarrow YZ \]

Step 1: Identify Candidate Keys
Candidate keys = VW, WX, WY.
Prime attributes = $\{V, W, X, Y\}$; Non-prime = $\{Z\}$.

Step 2: Identify Partial Dependencies
Check if any non-prime attribute depends on a proper subset of a key:
- $Z$ depends on $WX$ (Full Key).
- No non-prime attribute depends on $V, W, X,$ or $Y$ individually.

Conclusion: No partial dependency exists. Relation is in 2NF.

Example 273: Non-Prime dependencies

Consider relation $R(A, B, C, D, E)$ with functional dependencies: \[ A \rightarrow B, \quad B \rightarrow E, \quad C \rightarrow D \]

Step 1: Analysis
Candidate key = AC. Prime = $\{A, C\}$; Non-prime = $\{B, D, E\}$.

Step 2: Identify Violations
- $A \rightarrow B$: Partial Dependency ($A$ is prime, $B$ is non-prime). - $B \rightarrow E$: Transitive Dependency (Non-prime $\rightarrow$ Non-prime). Not a 2NF violation, but must be preserved.

Step 3: Decomposition (Lossless & DP)
- $R_1(A, B, E)$ (Fixes $A \rightarrow B$ and preserves $B \rightarrow E$). - $R_2(C, D)$ (Fixes $C \rightarrow D$). - $R_3(A, C)$ (Bridge table for the Full Key).

Conclusion: Each sub-relation is now in 2NF.

Example 274: Complex Relation

Consider $R(A, B, C, D, E, F, G, H, I, J)$ with functional dependencies: \[ AB \rightarrow C, \quad AD \rightarrow GH, \quad BD \rightarrow EF, \quad A \rightarrow I, \quad H \rightarrow J \]

Step 1: Analysis
Candidate key = ABD.
Prime = $\{A, B, D\}$; Non-prime = $\{C, E, F, G, H, I, J\}$.

Step 2: Identify Partial Dependencies
- $AB \rightarrow C, \ AD \rightarrow GH, \ BD \rightarrow EF, \ A \rightarrow I$ are Partial ($AB, AD, BD, A \subset ABD$). - $H \rightarrow J$ is Transitive (Non-prime $\rightarrow$ Non-prime).

Step 3: Create New Relations
- $R_1(A, B, C)$ - $R_2(A, D, G, H, J)$: $J$ moves here with $H$ to preserve dependency $H \rightarrow J$. - $R_3(B, D, E, F)$ - $R_4(A, I)$ - $R_5(A, B, D)$: The Full Key Bridge.

Conclusion: This decomposition is Lossless, Dependency Preserving, and in 2NF.

Third Normal Form (3NF)

Transitive Dependency

A transitive dependency $A \rightarrow B$ exists if and only if:

  • $A$ is not a super key, and

  • $B$ is a non-prime attribute.

NOTE: Transitive dependency must not exist for non-prime attributes. Transitive dependency can exist for prime attributes.

Definition of 3NF

A relation is in Third Normal Form (3NF) if and only if:

  1. The relation is already in 2NF, and

  2. No non-prime attribute is transitively dependent on any candidate key.

Alternative Definition of 3NF

A relation $R$ is in 3NF if for every non-trivial functional dependency $A \rightarrow B$:

  • $A$ is a super key, or

  • $B$ is a prime attribute.

Procedure to Decompose a Relation into 3NF

To decompose a relation into 3NF, follow these steps:

  1. Identify all candidate keys of the relation.

  2. Identify prime attributes (attributes that are part of any candidate key) and non-prime attributes.

  3. Examine each functional dependency $A \rightarrow B$:

    • If $A$ is not a super key and $B$ is a non-prime attribute, it is a transitive dependency.

  4. For each transitive dependency, create a separate relation containing the determinant and the dependent attribute(s).

  5. Remove the transitive dependencies from the original relation.

  6. Repeat until no relation has transitive dependencies, ensuring all resulting relations are in 3NF.

Example 275: 3NF - Stepwise Example 1: Relation already in 3NF

Consider relation $R(A, B, C, D, E)$ with functional dependencies: \[ A \rightarrow BC, \quad CD \rightarrow E, \quad B \rightarrow D, \quad E \rightarrow A \]

Step 1: Identify candidate keys

Check which attribute sets determine all other attributes: \[ \text{Candidate keys: } A, E, CD, BC \]

Step 2: Identify prime and non-prime attributes

  • Prime attributes = $\{A, B, C, D, E\}$ (all part of some candidate key)

  • Non-prime attributes = $\{\}$ (none)

Step 3: Check for transitive dependency

Transitive dependency exists if $A \rightarrow B$ (A not super key) and $B$ is non-prime. Here:

  • No non-prime attributes exist.

  • Therefore, no transitive dependency exists.

Step 4: Decomposition

Not required, as the relation has no transitive dependencies.

Step 5: Remove transitive dependencies

Not applicable.

Step 6: Verify 3NF

All non-prime attributes (none) are directly dependent on candidate keys.

Conclusion: Relation is in 3NF.

Example 276: 3NF - Stepwise Example 2: Relation not in 3NF

Consider relation $R(A, B, C, D)$ with functional dependencies: \[ AB \rightarrow CD, \quad A \rightarrow B, \quad B \rightarrow C \]

Step 1: Identify candidate keys

- $AB$ determines $CD$ - $A$ alone does not determine all attributes - $B$ alone does not determine all attributes

\[ \text{Candidate key: } AB \]

Step 2: Identify prime and non-prime attributes

  • Prime attributes = $\{A, B\}$

  • Non-prime attributes = $\{C, D\}$

Step 3: Check for transitive dependency

- $A \rightarrow B$ (A is subset of candidate key AB) and $B \rightarrow C$ - $C$ is non-prime → transitive dependency exists ($A \rightarrow C$ indirectly)

Step 4: Decompose relation

Create separate relations for transitive dependencies:

  • $R_1(A, B)$ (key $A$)

  • $R_2(B, C, D)$ (key $B$)

Step 5: Remove transitive dependencies

- Now, $C$ and $D$ are directly dependent on $B$ in $R_2$ - $B$ is fully dependent on $A$ in $R_1$

Step 6: Verify 3NF

- $R_1(A, B)$: $A$ is super key → 3NF satisfied - $R_2(B, C, D)$: $B$ is super key → 3NF satisfied

Conclusion: Original relation violated 3NF, decomposition produces 3NF relations.

Example 277: 3NF - Stepwise Example 3: Complex Relation

Consider relation $R(A, B, C, D, E)$ with functional dependencies: \[ A \rightarrow B, \quad B \rightarrow E, \quad C \rightarrow D \]

Step 1: Identify candidate keys

- $A$ determines $B$, $B$ determines $E$ → $A$ can determine $B$ and $E$ - $C$ determines $D$ - To cover all attributes: candidate keys = $A, C$

Step 2: Identify prime and non-prime attributes

- Prime attributes = $\{A, C\}$ - Non-prime attributes = $\{B, D, E\}$

Step 3: Check for transitive dependency

- $A \rightarrow B$ and $B \rightarrow E$ → $A \rightarrow E$ (transitive) - $E$ is non-prime → violates 3NF

Step 4: Decompose relation

- $R_1(A, B, E)$ with key $A$ - $R_2(C, D)$ with key $C$

Step 5: Remove transitive dependencies

- $R_1$: $B$ and $E$ are now fully dependent on $A$ - $R_2$: no transitive dependencies

Step 6: Verify 3NF

- $R_1(A, B, E)$: $A$ is super key → 3NF satisfied - $R_2(C, D)$: $C$ is super key → 3NF satisfied

Conclusion: Decomposition successfully converts relation into 3NF.

Boyce-Codd Normal Form (BCNF)

A relation is in BCNF if and only if:

  1. The relation is already in 3NF.

  2. For every non-trivial functional dependency \(A \rightarrow B\), \(A\) is a super key of the relation.

Procedure to Decompose a Relation into BCNF

To decompose a relation \(R\) into BCNF:

  1. Identify all candidate keys of \(R\).

  2. Check each functional dependency \(A \rightarrow B\):

    • If \(A\) is a super key, it satisfies BCNF.

    • If \(A\) is not a super key, BCNF is violated.

  3. For each violating dependency \(A \rightarrow B\), decompose \(R\) into:

    • \(R_1(A, B)\) — containing the violating dependency.

    • \(R_2(R - B)\) — the remaining attributes.

  4. Repeat steps 1–3 for all decomposed relations until all relations satisfy BCNF.

Example 278: BCNF - Example 1: Relation Already in BCNF

Consider a relation \( R (A, B, C) \) with functional dependencies: \[ A \rightarrow B, \quad B \rightarrow C, \quad C \rightarrow A \]

Step 1: Identify candidate keys: \(A, B, C\)

Step 2: Check BCNF condition: Each determinant (\(A, B, C\)) is a candidate key.

Conclusion: The relation already satisfies BCNF.

Example 279: BCNF - Example 2: Relation Not in BCNF

Consider a relation \(R(A, B, C)\) with functional dependencies: \[ AB \rightarrow C, \quad C \rightarrow B \]

Step 1: Identify candidate keys: \((AB)^+ = ABC\), \((AC)^+ = ABC\) Candidate keys: \(AB, AC\) Prime attributes: \(A, B, C\) Non-prime attributes: None

Step 2: Check BCNF condition:

  • \(AB \rightarrow C\) is fine (AB is a super key)

  • \(C \rightarrow B\) violates BCNF because \(C\) is not a super key

Step 3: Decompose violating relation:

  • \(R_1(C, B)\) with key \(C\)

  • \(R_2(A, C)\) with key \(AC\)

Step 4: Check BCNF for new relations: Both \(R_1\) and \(R_2\) now satisfy BCNF.

Conclusion: Original relation decomposed into BCNF: \[ R_1(C, B), \quad R_2(A, C) \]

Example 280: BCNF - Example 3: Real Data Decomposition

Original relation: \[ R(A, B, C) \] \[ \begin{array}{|c|c|c|} \hline A & B & C \\ \hline a & 1 & x \\ b & 2 & y \\ c & 2 & z \\ c & 3 & w \\ d & 3 & w \\ e & 3 & w \\ \hline \end{array} \]

Functional dependencies: \(AB \rightarrow C, C \rightarrow B\)

Step 1: Candidate keys: \(AB, AC\)

Step 2: BCNF Violation: \(C \rightarrow B\) (C not a super key)

Step 3: Decomposition: \[ R_1(C, B) = \begin{array}{|c|c|} \hline C & B \\ \hline x & 1 \\ y & 2 \\ z & 2 \\ w & 3 \\ \hline \end{array} \] \[ R_2(A, C) = \begin{array}{|c|c|} \hline A & C \\ \hline a & x \\ b & y \\ c & z \\ c & w \\ d & w \\ e & w \\ \hline \end{array} \]

Step 4: Check BCNF: Both \(R_1\) and \(R_2\) satisfy BCNF.

Conclusion: Decomposition removes redundancy and ensures BCNF.

Multi-valued Dependency and Fourth Normal Form (4NF)

The Fourth Normal Form (4NF) is satisfied if and only if:

  1. The relation is in BCNF.

  2. The relation contains no non-trivial multi-valued dependencies (MVDs) other than a candidate key.

Multi-valued Dependency (MVD)

A multi-valued dependency (MVD) in a relation \(R\) occurs when, for a single value of attribute \(A\), there can be multiple independent values of attribute \(B\), such that the presence of \(B\) values is independent of other attributes in \(R\).

Notation: \(A \twoheadrightarrow B\)

Example: If a student can have multiple phone numbers and multiple courses, then: \[ \text{SID} \twoheadrightarrow \text{Phone}, \quad \text{SID} \twoheadrightarrow \text{Course} \]

Here, the phone numbers and courses are independent of each other, causing a multi-valued dependency.

Procedure to Decompose into 4NF

To decompose a relation \(R\) into 4NF:

  1. Ensure that the relation is already in BCNF.

  2. Identify all multi-valued dependencies \(A \twoheadrightarrow B\).

  3. For each MVD that violates 4NF (i.e., \(A\) is not a super key):

    • Create a new relation \(R_1(A, B)\) for the MVD.

    • Create another relation \(R_2(R - B)\) for the remaining attributes.

  4. Repeat until all relations satisfy 4NF.

Example 281: 4NF - Example 1: Student-Course Database

Consider the following database tables:

Table R1 (Students):

diagram

Table R2 (Courses):

diagram

Step 1: Cross-product causes MVDs:

diagram

Step 2: Identify multi-valued dependencies:

  • \( \text{SID} \twoheadrightarrow \text{CID} \)

  • \( \text{SID} \twoheadrightarrow \text{CNAME} \)

Step 3: Check 4NF condition: SID is not a super key for the combined table. Hence, the relation violates 4NF.

Step 4: Decomposition into 4NF:

  • \(R_1(SID, CID)\)

  • \(R_2(SID, CNAME)\)

  • \(R_3(SID, SNAME)\) (to maintain student info)

Step 5: Check 4NF for new relations: All decomposed relations now satisfy 4NF.

Join Dependency and Fifth Normal Form (5NF)

A relation \(R\) is in Fifth Normal Form (5NF) if and only if:

  1. The relation is already in 4NF.

  2. Every join dependency in \(R\) is implied by the candidate keys.

  3. The relation cannot be further decomposed into smaller relations without losing the lossless join property.

Lossless Join Property

A decomposition of a relation is said to have a lossless join if, after decomposing the relation into two or more relations, performing a natural join on these decomposed relations reconstructs exactly the original relation without generating any spurious tuples.

Procedure to Decompose into 5NF

To check and decompose a relation \(R\) into 5NF:

  1. Ensure that the relation is already in 4NF.

  2. Identify all join dependencies (JD) in the relation.

  3. For each join dependency \(JD: R_1 \Join R_2 \Join \dots \Join R_n = R\):

    • Check if the decomposition is implied by the candidate keys.

    • If not, decompose \(R\) into smaller relations such that each decomposition satisfies the lossless join property.

  4. Repeat until all join dependencies are satisfied by the candidate keys.

Example 282: 5NF - Example: Company-Agent-Product Schema

Consider the relation \(ACP(Agent, Company, Product)\) representing which agent sells which product for which company.

Table ACP:

diagram

Step 1: Identify join dependency: The relation has a natural join dependency among: \[ (Agent, Company),\quad (Agent, Product),\quad (Company, Product) \]

Step 2: Decompose into 5NF:

  • \(R_1(Agent, Company)\)

    diagram
  • \(R_2(Agent, Product)\)

    diagram
  • \(R_3(Company, Product)\)

    diagram

Step 3: Check lossless join: The natural join of \(R_1, R_2, R_3\) over the common attributes reconstructs the original table \(ACP\) exactly, without generating spurious tuples.

Step 4: Conclusion: All redundancies are eliminated, and the relation now satisfies 5NF. No further non-loss decompositions are possible.