Professional Documents
Culture Documents
March 27, 2024 Department of CSE EID 301 & Database Management Systems 1
Module IV
To resolve these problems we need to refine the logical database tables by applying some
normalization to get the exact tables. This refinement is called as Normalization.
March 27, 2024 Department of CSE EID 301 & Database Management Systems 3
Normalization involves building structures like tables(starting from identifying
columns associated in the tables , it is called bottom-up approach).
Normalization eliminates the duplicate data and makes insert, delete and update
operations much more efficient in terms of performance and space requirement to
store the data.
Before they are physically stored in database the tables are normalized/refined first.
Storing the same information redundantly i.e., more than one place within a
database may lead to several problems.
1. Redundant Storage: same information is stored repeatedly
2. Update Anomalies: If one copy of such repeated data is updated, an
inconsistency is created unless all copies are similarly updated.
3. Insertion Anomalies: it may not be possible to store certain information
unless some other, unrelated, information is stored as well.
4. Deletion Anomalies: It may not be possible to delete certain information
without losing some other, unrelated, information as well
Rating Hrly_wages
8 10
5 7
• Armstrong’s Axioms:
– Reflexivity: If X⊇ Y, then X->Y
– Augmentation: If X-> Y, then XZ->YZ for any Z
– Transitivity: If X -> Y and Y-> Z, then X -> Z
• These are sound and complete inference rules for FDs!
March 27, 2024 Department of CSE EID 301 &Database Management Systems: 23
Armstrong’s Axioms are sound, in that they generate only FDs in when
applied to a set of FDs. They are also complete, in that repeated
application of these rules will generate all FDs in the closure .
March 27, 2024 Department of CSE EID 301 &Database Management Systems: 24
Trivial Functional Dependency:
FDs are said to be TFD if they are satisfied by all the relations
Example:
Consider a relation schema ABC with FDs A->B and B->C.
In a trivial FD, the right side contains only attributes that also appear on the left
side, such dependencies always hold due to reflexivity.
Using reflexivity, we can generate all trivial dependencies which are of the form:
X->Y, where Y ⊆ X(every element of Y is in X), X ⊆ ABC, and Y ⊆ ABC.
From transitivity , we get A->C.
From Augmentation, we get the non trivial dependencies :
AC->BC, AB->AC,AB->BC
March 27, 2024 Department of Biotechnology, GIT Course Code and 25
Course Title:
Example1:
Suppose we are given a relation with attributes A, B,C,D,E,F and the functional
dependencies(FDs)
A → BC
B→E
CD → EF
Solution:
A → BC (given)
A → B and A → C (decomposition)
AD → CD ( augmentation)
CD → EF (given)
AD → EF (Transitivity)
AD → E, AD → F (decomposition)
26
Closure of a set of FDs contd.
Example2:
Several additional FDs hold in the closure of the set of given FDs.
• From JP → C, C → CSJDPQV and transitivity, we infer JP → CSJDPQV
• From SD → P and augmentation, we infer SDJ → JP
• From SDJ → JP, JP → CSJDPQV, and transitivity, we infer SDJ → CSJDPQV
We can infer several additional FDs that are in the closure by using augmentation or
decomposition.
• For example, from C → CSJDPQV, using decomposition, we can infer:
• C → C, C → S, C → J, C → D, and so forth.
• Finally we have a number of FDs from the reflexivity rule.
Department of computer science and engineering, GST Course Code
March 27, 2024 28
19ECS333 Course Title: Database management systems
Attribute Closure
The algorithm for computing the attribute closure of a set X of attributes is shown
below:
closure=X;
repeat until there is no change:{
if there is an FD U → V in F such that U ⊆ closure,
then set closure = closure U V
}
29
Closure of a set of FDs:
Example1: Find the closure of
30
March 27, 2024 Department of Biotechnology, GIT Course Code and 31
Course Title:
Example2:
A → BC
E → CF
B→E
CD→ EF
Find the closure of
Solution:
= { A, B, C, E, F}
44
March 27, 2024 45
March 27, 2024 46
March 27, 2024 47
March 27, 2024 Department of Biotechnology, GIT Course Code and 48
Course Title:
49
Third Normal Form:
• A table is said to be in 3NF iff
i) It should be in 2NF
ii) It should not have transitive dependency.
Note:
X A, any one condition satisfied
i) Trivial Functional Dependency.
ii) LHS should be a super key or candidate key.
iii) RHS should be a part of candidate key.
BCNF:
i)Trivial Functional Dependency.
ii) LHS should be a super key or candidate key.
50
March 27, 2024 Department of Biotechnology, GIT Course Code and 51
Course Title:
March 27, 2024 52
March 27, 2024 Department of Biotechnology, GIT Course Code and 53
Course Title:
Third Normal Form:
54
55
March 27, 2024 56
March 27, 2024 Department of Biotechnology, GIT Course Code and 57
Course Title:
Boyce-Codd normal form (BCNF) :
58
Fourth Normal Form:
• A table is said to be in 4NF iff
i) It should satisfy BCNF
ii) It should not have Multi-valued dependency.
R( A,B,C,D,E)
FD’s
A ->B
D->E
Find all the possible candidate keys
= {A, C, D,B, E}
So ACD is candidate key
BCNF:
i)Trivial Functional Dependency.
ii) LHS should be a super key or candidate
March 27, 2024
key.
Department of Biotechnology, GIT Course Code and 66
Course Title:
Problems on Normal Forms: In which Normal Form the table is
in?
• R(ABCDE)
• FDs: {A->BCDE, BC->ACE, D->E}
• R(ABCDE)
• FDs: {AB->CDE, D->A}
1) lossless join Decomposition:Let R be a relation.Let R be decomposed into R1 and R2.The decomposition is saidto
be lossless join decomposition if after joining the decomposed table we get back our original instance as in R.
3 conditions needs to be satisfied for lossless join decomposition:
i) attribute(R1) U attribute(R2)=attribute(R). i.e after joining the decomposed relations the number of attributes
should be the same as attributes of R before decomposition.
ii) attribute(R1) ∩ attribute(R2 ≠ Φ : i.e at least one attribute has to be there in the decomposed relations.
iii) attribute(R1) U attribute(R2)=attribute(R1)
or
attribute(R1) U attribute(R2)=attribute(R2)
Or BOTH
i.e. the common attribute should be either a Super key or a candidate key in either R1 or R2 or both.
Let R be a relation schema that is decomposed into two schemas with attribute sets
X and Y, and let F be a set of FDs over R. The projection of F on X is the set of
FDs in the closure F + (not just F !) that involve only attributes in X. We will denote
the projection of F on attributes X as FX . Note that a dependency U → V in F + is
in FX only if all the attributes in U and V are in X.
The decomposition of relation schema R with FDs F into schemas with attribute sets
X and Y is dependency-preserving if (FX ∪ FY )+ = F +.
What ever dependencies exited before decomposition in R, the same FDs must be preserved in either of the
decomposed relations, then we say dependency preserving property is maintained.
Let R be the original FD,and F be the set of FDs over R.
R is decomposed into R1 with F1 FDs and R2 with F2 Fds.
The decomposition is said to be dependency preserving,iff the following holds good.
F1 U F2 ≡ F
Let F1 U F2 =G
Then G ≡ F
We say that G is equivalent to F, iff
G Covers F
And
F covers G
March 27, 2024 Department of Biotechnology, GIT Course Code and 70
Course Title:
Problems on Lossless join decomposition
1)R(ABCDE)
AB->CDE, D->A
• 2)R(ABCDE)
• A->BCDE, BC->ACE, D->E
• R(ABCDE)
• 11213
• 22213
• 31636
• 42857
• 53957
• 1)R1(ABC), R2(DE): lossy decomposition
• 2)R1(ABC), R2(CD) : lossy
• 3)R1ABC) R2(CDE):Lossless join Decomposition
• 4)R1(ABC), R2(ABDE): Lossless join Decomposition
• 5)R1(AB), R2(BCDE):lossy decomposition
• 6)R1(AB), R2(CD), R3(DE):lossy decomposition
March 27, 2024 Department of Biotechnology, GIT Course Code and 71
Course Title:
Problems on Dependency Preserving decomposition
1)R(ABCDE)
• Fds:{A->B,B->C,C->D,D->A}
• R is decomposed to R1(ABC) and R2(CDE).
• Is the decomposition Dependency Preserving decomposition?
ANSWER: it is Dependency Preserving decomposition—already discussed in class
2) 1)R(ABCDE)
• Fds:{A->BCD,B->AE,BC->AED,D->E,C->DE}
• R1(AB), R2(BC), R3(CDE)
• ANSWER: : it is Dependency Preserving decomposition—already discussed in class
R( A,B,C,D)
FD’s
A->B
B->C
C ->A
Find all the possible candidate keys
75
Therefore the candidate keys are { DA, DB, DE, DF }
Number of candidate keys = 4 76