Normal Forms
Normal Forms
in/gorakhpur/sites/default/
files/Gorakhpur/Alevel_1_DBMS_24Apr2020_AV.pdf
https://minigranth.in/dbms-tutorial/closure-of-functional-dependency
Example 1
Consider a relation R(A,B,C,D,E,F)
Solution
The closure of E or E+ is as follows −
E+ = E
=EA {for E->A add A}
=EAD {for E->D add D}
=EADC {for A->C add C}
=EADC {for A->D D already added}
=EADCF {for AE->F add F}
=EADCF {for AG->K don’t add k AG ⊄ D+)
Example 2
Let the relation R(A,B,C,D,E,F)
Solution
The closure for B is as follows −
B+ = {B,C,A,D,E}
Closure is used to find the candidate keys of R and compute F +
For example,
R(A,B,C,D,E,F) WHERE F:A->BC, B->D, C->DE, BC->F. Then, find the candidate
keys of R.
Solution
A+= {A,B,C,D,E,F}={R}=>A is a candidate key
B+= {B,D} => B is not a candidate key
C+= {C,D,E} => C is not a candidate key
BC+= {B,C,D,E,F} => BC is not a candidate key
Closure of F (F+): F+ is the set of all FDs that can be inferred/ derived from F.
Using Armstrong Axioms repeatedly on F, we can compute all the FDs.
Example
R(A,B,C,D,E) AND F: A->B,B->C, C->D, A->E. Find the closure of F
Solution
A+= {A,B,C,D,E}
B+= {B,C,D}
C+= {C,D}
F+= {A->A, A->B, A->C, A->D, A->E, B->B, B->C, B->D, C->C, C->D}
Step-1 : Add the attributes which are present on Left Hand Side in
the original functional dependency.
Step-2 : Now, add the attributes present on the Right Hand Side of
the functional dependency.
Step-3 : With the help of attributes present on Right Hand Side, check the
other attributes that can be derived from the other given functional
dependencies. Repeat this process until all the possible attributes which
can be derived are added in the closure.
Decomposition in DBMS involves dividing a table into multiple tables, aiming to eradicate
redundancy, inconsistencies, and anomalies. This process, represented as {X1, X2,……Xn},
ensures dependency preservation and losslessness. When a relational model's relation lacks
appropriate normal form, decomposition becomes necessary to address issues like information
loss, anomalies, and redundancy, ultimately enhancing the overall design quality and efficiency
of the database.
We can follow certain rules to ensure that the decomposition is a lossless join
decomposition Let’s say we have a relation R and we decomposed it into R1 and R2, then the
rules are:
1. The union of attributes of both the sub relations R1 and R2 must contain all the attributes
of original relation R.
R1 ∪ R2 = R
2. The intersection of attributes of both the sub relations R1 and R2 must not be null, i.e.,
there should be some attributes that are present in both R1 and R2.
R1 ∩ R2 ≠ ∅
3. The intersection of attributes of both the sub relations R1 and R2 must be the superkey of
R1 or R2, or both R1 and R2.
R1 ∩ R2 = Super key of R1 or R2
Let’s see an example of a lossless join decomposition. Suppose we have the following relation
EmployeeProjectDetail as:
<EmployeeProjectDetail>
Now, we decompose this relation into EmployeeProject and ProjectDetail relations as:
<EmployeeProject>
<ProjectDetail>
Project_ID Project_Name
P03 Project103
P01 Project101
P04 Project104
P02 Project102
Now, let’s see if this is a lossless join decomposition by evaluating the rules discussed above:
<EmployeeProject ∪ ProjectDetail>
EmployeeProject ∪ ProjectDetail relation and it is the same as the original relation. So the first
As we can see all the attributes of EmployeeProject and ProjectDetail are in
condition holds.
<EmployeeProject ∩ ProjectDetail>
Project_ID
P03
P01
P04
P02
As we can see this is not null, so the the second condition holds as well. Also
the EmployeeProject ∩ ProjectDetail = Project_Id. This is the super key of the ProjectDetail
relation, so the third condition holds as well.
Now, since all three conditions hold for our decomposition, this is a lossless join
decomposition.
<EmployeeProject>
<ProjectDetail>
Project_ID Project_Name
P03 Project103
P01 Project101
P04 Project104
P02 Project102
Now, the intersection EmployeeProject ∩ ProjectDetail is null. Therefore there is no way for us
to map a project to its employees. Thus this is a lossy decomposition.
Dependency Preserving
The second property of lossless decomposition is dependency preservation which says that after
decomposing a relation R into R1 and R2, all dependencies of the original relation R must be
present either in R1 or R2 or they must be derivable using the combination of functional
dependencies present in R1 and R2.
<EmployeeProjectDetail>
Now, after decomposing the relation into EmployeeProject and ProjectDetail as:
<EmployeeProject>
<ProjectDetail>
Project_ID Project_Name
P03 Project103
P01 Project101
P04 Project104
P02 Project102
As we can see that all FDs in EmployeeProjectDetail are either part of the EmployeeProject or
the ProjectDetail, So this decomposition is dependency preserving.
Conclusion
Decomposition is the process of breaking an original relation into multiple sub relations.
Decomposition helps to remove anomalies, redundancy, and other problems in a DBMS.
Decomposition can be lossy or lossless.
An ideal decomposition should be lossless join decomposition and dependency preserving.