SlideShare a Scribd company logo
DataBase Management
System
Subject Instructor :Dr. Amit Khare
Functional Dependencies
❖Users probably won’t understand that term “Functional Dependency”,
important to ask right question.
❖If you known a particular employee number, can you establish other
information, such as name?
❖If you can determine that the name is functionally dependent on the employee
number.
2
Functional Dependencies cont…
❖Another Question: Do you know the number of the department to which the
employee is assign?.
❖If you can then we can say department no is functionally dependent on
employee number.
❖If a employee can be assigned to more than one department, you would not the
know department number. So department no is not functionally dependent on
employee number.
3
Functional Dependencies cont…
❖Functional dependency concern the dependence of the value of one
attributes or set of attributes on those of another attribute or set of
attributes.
❖A FD is a property of the semantics or meaning of the attributes in a
relation.
❖Semantics indicate how attributes relate to one another and specify the
FDs between attributes.
4
Functional Dependencies cont…
❖A functional dependency is defined as a constraint between two sets of
attributes in a relation from a database.
❖Given a relation R, a set of attributes X in R , is said to functionally
determine another attribute Y, also in R, (written X → Y) if and only if each
X value is associated with at most one Y value.
5
Functional Dependencies cont…
❖X is the determinant set and Y is the dependent attribute. Thus, given a
tuple and the values of the attributes in X, one can determine the
corresponding value of the Y attribute.
❖Left hand side of the FD is called determinant whereas that of the right
side is called dependent.
6
Functional Dependencies cont…
❖Example: Employee
Note: Name is functionally dependent on SSN because an employee’s name
can be uniquely determined from their SSN. Name does not determine
SSN, because more than one employee can have the same name..
7
Functional Dependencies cont…
❖Example: Employee and Project
❖SSN -> ENAME
❖PNUMBER ->{PNAME, PLOCATION}
❖{SSS, PNUMBER} -> HOURS
SSN PNUMBER HOURS ENAME PNAME PLOCATION
8
Keys
❖ Whereas a key is a set of attributes that uniquely identifies an entire tuple,
a functional dependency allows us to express constraints that uniquely
identify the values of certain attributes.
❖However, a candidate key is always a determinant, but a determinant
doesn’t need to be a key.
9
Full Functional Dependency (FDD)
❖ Minimal set of attributes in a determinant of a FD.
❖Other words the set of attributes Y will be fully functionally dependent on
the set of attributes X,
⮚ Y is functionally dependent on X.
⮚ Y is not functionally dependent on any subset of X.
10
Full Functional Dependency cont…
❖ Example
Emp_id, Project_no, Project_budget -> Yr_spent_by_emp_on_project.
❖In this Emp_id and Project_no is sufficient set of attribute to determines
the value of right hand side. So there is no need of Project-budget. FDD is
Emp_id, Project_no-> Yr_spent_by_emp_on_project
11
Full Functional Dependency cont…
❖A FD X -> Y is a fully functional dependency if removal of any attribute A
from X, means that the dependency does not hold any more: i.e. for any
attribute A Ɛ X.
❖Example: {SSN, Pnumber} -> Hours.
❖We can not remove any attribute from determinant side.
12
Closure (F+)
❖ Let a relation R have some functional dependencies F specified.
❖ The closure of F (usually written as F+) is the set of all functional dependencies that may be
logically derived from F.
❖ Often F is the set of most obvious and important functional dependencies and F+, the closure,
is the set of all the functional dependencies including F and those that can be deduced from F.
❖ The closure is important and may, for example, be needed in finding one or more candidate
keys of the relation.
13
Closure (F+)
❖Example: FD is given:
SSN->{ename, bdate, address, dnumber}
Dnumber-> dname, dmgr_ssn
Now we can infer from F are the following:
SSN -> Dname, dmgr_sssn
14
Axioms (Inference Rules)
❖Before we can determine the closure of the relation, we need a set of rules.
❖Developed by Armstrong in 1974, there are six rules (axioms) that all
possible functional dependencies may be derived from them.
15
Axioms (Inference Rules) cont…
❖Reflexivity Rule :- If X is a set of attributes and Y is a subset of X, then X →
Y holds.
Example: AB->A.
❖Augmentation Rule :- If X → Y holds and W is a set of attributes, then WX →
WY holds.
Example: AB->C, ABD->CD 16
Axioms (Inference Rules) cont…
❖Transitivity Rule :- If X → Y and Y → Z holds,
then X → Z holds.
Example: A → BC (GIVEN) find BC->B and A->B
BC → B (Using Rule 1, since B ⊆ BC)
A → B (Using Rule 3)
17
Derived Theorems from Axioms
❖Union Rule :- If X → Y and X → Z holds,
then X → YZ holds.
❖Decomposition Rule :-If X → YZ holds, then
X → Y and X → Z.
❖Pseudotransitivity Rule :- If X → Y and WY → Z hold then WX → Z.
18
Derived Theorems from Axioms
❖Composition – If A->B and X->Y holds, then AX ->BY holds.
❖Self Determination Rule - A → A is a self determination rule.
❖Note: These are not commutative as well as associative. i.e. if X → Y then
Y → X (not possible)
19
Exercise
❖Consider relation E = (P, Q, R, S, T, U) having set of Functional
Dependencies (FD).
❖P → Q , P → R, QR → S , Q → T, R → U, PR → U
❖Calculate some members of Axioms are as follows,
❖ P → T
❖ PR → S
❖QR → SU
❖PR → SU 20
Exercise (Solution)
❖Given FD’s are:
P → Q , P → R, QR → S , Q → T, R → U, PR → U
1. P → T
In the above FD set, P → Q and Q → T
Using Transitive Rule: If P → Q and Q → T, then P → T.
2. PR → S
In the above FD set, P → Q and QR → S.
Using Pseudo Transitivity Rule: If P → Q and QR → S,
then PR → S. 21
Exercise (Solution)
❖Given FD’s are:
P → Q , P → R, QR → S , Q → T, R → U, PR → U
3. QR → SU
In above FD set, QR → S and QR → U
Using Union Rule: If QR → S and QR → U, then QR → SU.
4. PR → SU
Using Pseudo Transitivity Rule:
If PR → S and PR → U, then PR → SU.
22
Exercise (Home Work)
❖Consider a relational scheme R with attributes A,B,C,D,F and the FDs A →
BC, B → E, CD → EF. Prove that functional dependency AD → F holds in R.
❖Let set of FD's are given F={A->B, C->X, BX->Z}. Prove or disprove that AC-
>Z.
❖Let F={A->B, C->D, C IS SUBSET OF B}. Prove or disprove that A->C.
23
Points to Compute Closure
❖First start with result: First we assign the result same as the value of the
closure which we want to compute.
❖Inner Loop: We now go to the inner loop as many times as the FD’s are
given.
❖Find Subset: If we find that the left hand side is the subset of the closure,
which we want to compute , add those attributes to the result.
24
Points to Compute Closure
❖Nested Inner Loop: Now we go to the inner loop many times as the left
hand side is the subset of the result.
❖Stop Inner loop: If left hand side is not the subset of the result, we stop
going round to the inner loop.
❖Result: Final result is generated.
25
Example: Compute Closure
❖Let R={A,B,C,D,E,F} and FDs {A->BC, E->CF, B->E, CD->EF}. Now compute
the closure {AB}+.
❖Solution: 1. Start with result: {AB} so
AB->AB {all attributes are determined by itself.}
2. We now go to inner loop four times because of fours FDs.
(I) Iteration I: Inner Loop Iteration (I) We have AB-> AB now take FD A-
>BC. Check left hand side is the subset of the result {AB}.
26
Example: Compute Closure
A->BC and AB->AB
Means A is subset of AB. If yes then include B and C
into result. So new result set is {ABC}
Note: Include only those attributes which are not present in result set.
Inner Loop Iteration II: After first iteration we have result set {ABC}. Now
take E->CF. Find left hand side is subset of result set =🡺 NO.
So result set remain unchanged {ABC}.
27
Example: Compute Closure
Inner Loop Iteration III: Result set {ABC}. Now take B->E.
Check left side is subset of Result set: YES
Include E into result set. So new result set is: {ABCE}.
Inner Loop Iteration IV: Result set {ABCE}. Now take CD->EF.
Check left side is subset of Result set: NO
Result set remain unchanged: {ABCE}.
28
Example: Compute Closure
II. Iteration II: After Iteration I we have result set {ABCE}. Now we will
compute inner loop again four times:
Inner loop Iteration I: {ABCE} result set. Now take A->BE. Check left side is
subset: YES. Result set{ABCE}.
Inner loop Iteration II: {ABCE} result set. Now take E->CF. Check left side is
subset: YES. Result set{ABCEF}.
29
Example: Compute Closure
Inner loop Iteration III: {ABCEF} result set. Now take B->E. Check left side is
subset: YES. Result set no changed. {ABCEF}.
Inner loop Iteration IV: {ABCEF} result set. Now take CD->EF. Check left side
is subset: YES. Result set no changed. {ABCEF}.
III. Iteration III: Result set {ABCEF}. Now Computer inner loop four time. No
changes in result set.
30
Example: Compute Closure
IV. Iteration IV: Result set {ABCEF}. Now Computer inner loop four time. No
changes in result set.
So the whole process terminates with :
AB+ = {ABCEF}.
Exercise I : Let R {A,B,C,D,E} AND FDs AB->C, A->D, D->E, AC->B. Compute
AB+, A+, B+, D+.
Solutions: AB+= {ABCDE}, A+={ADE}, B+={B}, D+={DE}.
31
Example: Compute Closure
Exercise II : Let R {A,B,C,G,H,I} AND FDs A->B, A->C, CG->H, CG->I, B->H.
Compute AG+
Solutions: AG+= ABCGHI
32
Trivial and Non-Trivial FD
If a functional dependency X->Y holds true where Y
is a subset of X then this dependency is called trivial
Functional dependency.
Example: {Student_Id, Student_Name} -> Student_Id
is a trivial functional dependency as Student_Id is a
subset of {Student_Id, Student_Name}.
33
Trivial and Non-Trivial FD
If a functional dependency X->Y holds true where Y
is not a subset of X then this dependency is called
non trivial Functional dependency.
Example: Employee Table:
emp_id -> emp_name ,
emp_id -> emp_address
34
Trivial and Non-Trivial FD
If a functional dependency X->Y holds true where Y
is not a subset of X then this dependency is called
non trivial Functional dependency.
Example: Employee Table:
emp_id -> emp_name ,
emp_id -> emp_address
35
Cover and Equivalence of FD’s
❖ Set of functional dependencies F is said to cover another set of functional
dependencies G, if every FD in G is also in F+; that is, if every
dependency in G can be inferred from F; alternatively, we can say that G
is covered by F.
36
Cover and Equivalence of FD’s
❖ Two sets of functional dependencies G and F are equivalent if G+ = F+.
Therefore, equivalence means that every FD in G can be inferred from F,
and every FD in F can be inferred from G; that is, G is equivalent to F, if
both the conditions—G covers F and F covers G—hold.
37
Cover and Equivalence of FD’s
Example: F = {A → C, AC → D, E → AD, E → H} and G = {A → CD, E → AH}.
❖ Take Set F and Check G is covered from F or not.
❖ A+= ACD, E+=ADCH
❖ Hence, both A → CD and E → AH are covered.
❖ G is derived from F. Hence G is covered by F.
38
Cover and Equivalence of FD’s
Example: F = {A → C, AC → D, E → AD, E → H} and G = {A → CD, E → AH}.
❖ Take Set G and Check F is covered from G or not.
❖ (A)+ = {ACD} (AC)+ = {ACD} (E)+ = {EAHCD}
Hence F = {A → C, AC → D, E → AD, E → H} is covered.
F is derived from G. Hence F is covered from G.
So F is cover by G and G is cover by F, we can say F and G are equivalent.
39
Determining Candidate Key
1. Compute Closure of each of attributes. i.e. A+, B+.
2. If any attribute is candidate key then do not create any candidate key
using it. Because its subset not allow to make another attribute as a
candidate key.
3. Any attribute is called a candidate key of any relation, if attribute closure
is equal to the relation. For Example: if R{A,B,C,D,E} then A is a candidate
key, if A+={A,B,C,D,E}.
40
Determining Candidate Key cont…
Example: Given R{A,B,C,D} And FDs F={AB->C, C->D, D->A}. List all the
candidate keys.
Solution: 1. compute A+={A} // not a candidate key because A+ can not
determines all A, B, C, D.
2. B+=B //not a candidate key.
3. C+=CDA // not a candidate key.
4. D+=DA // not a candidate key.
5. AB+=ABCD //AB is a candidate key. 41
Determining Candidate Key cont…
So any combination of AB does not form other candidate key.
6. AC+=ACD // not a candidate key.
7. AD+=AD //not a candidate key.
8. BC+=BCDA // candidate key. Combination not allowed.
9. BD+=ABCD //candidate key.
10. CD+=CDA //not a candidate key.
42
Determining Candidate Key cont…
List of candidate keys { AB, BC, BD}.
Example 2: Given R {A,B,C,D,E}. List all candidates keys of R for a given FD’s
{A->BC, CD->E, B->D, E->A}.
Result: {A, E, BC, CD}.
Example 3: R{ABCD} , FD’s ABC->D, D->A.
Result: {ABC, BCD}.
43
Non-redundant Covers
❖ A set F, of FDs is non-redundant if there is no proper subset F’ of F, with
F’ = F. If such an F ’ exists, F is redundant. F is a non-redundant cover for
G, if F is a cover for G and F is non-redundant.
❖ A functional dependency in the set, is redundant if it can be derived from
the other functional dependencies in the set.
❖ We can remove some FD which are redundant to make the whole FD’s
non redundant.
44
Steps to detect redundant FD’s
A redundant FD can be detected using the following
steps:
1. Start with a set of F, of functional dependencies (FDs).
2. Remove an FD, f and create a set of FDs F' = F - f .
3. Test whether f can be derived from the FDs in F';
4. If f can be derived, it is redundant , and hence F' = F. Otherwise replace f
into F'; so that now F' = F + f.
45
Steps to detect redundant FD’s conti…
5: Repeat steps 2 to 4 for all FDs in F.
Example: F={Z -> A B -> X AX -> Y ZB -> Y }
Step I: F’=F-f 🡺 F’={B->X AX->Y ZB->Y}
Step II: Check Z-> A derive from F’. //NO we can not derive. So Z->A is not
redundant.
Repeat Step: check for B->X //not redundant.
Repeat Step: check for AX->Y //not redundant.
Repeat Step: check for ZB->Y. // redundant. 46
Steps to detect redundant FD’s conti…
❖ Z -> A by augmentation rule will yield ZB -> AB.
❖ B -> X and AX -> Y by pseudo-transitivity rule will yield AB -> Y.
❖ ZB -> AB and AB -> Y by transitivity rule will yield
ZB -> Y.
So ZB->Y redundant.
47
Steps to detect redundant FD’s conti…
Example 2: F = {A -> B, C -> D, BD -> E, AC -> E}
❖ Find out whether a FD f : AC -> E is redundant or not.
❖ Find out whether a FD f : BD -> E is redundant or not.
❖ AC->E redundant.
❖ BD->E non redundant.
Example 3: R{XYZWPQ} F🡺{X->YZ, ZW->P, P->Z, W->XPQ, XYQ->YW, WQ-
>YZ}. Find non redundant.
Sol: {X->YZ, P->Z, W->XPQ, XYQ->YW} 48
Irreducible/ minimal set/ canonical cover
❖ A canonical cover of F is a “minimal” set of functional dependencies
equivalent to F, having no redundant dependencies or redundant parts of
dependencies.
❖ Canonical cover of any functional dependency is denoted by Fc.
❖ Canonical cover Fc for F is a set of dependencies such that F logically
implies all dependencies in Fc and Fc logically implies all dependencies in F.
So Fc must have the following properties:
49
Irreducible/ minimal set/ canonical cover
❖No functional dependency in Fc contains an extraneous attribute.
❖Each left side of a functional dependency in Fc is unique. That is there are no
two dependencies X1->Y1 and X2->Y2 in Fc such that X1=X2.
50
Irreducible/ minimal set/ canonical cover
❖ Sets of functional dependencies may have redundant dependencies that can
be inferred from the others.
❖ Eg: A → C is redundant in: {A → B, B → C, A → C}.
❖ Parts of a functional dependency may be redundant .
❖ E.g. on RHS: {A → B, B → C, A → CD} can be simplified to {A → B, B → C, A →
D}
❖ E.g. on LHS: {A → B, B → C, AC → D} can be simplified to {A → B, B → C, A →
D}
51
Extraneous Attributes
❖ Consider F, and a functional dependency, A 🡺B.
❖ “Extraneous”: Are there any attributes in A or B that can be safely removed,
without changing thFe constraints implied by F.
Testing if an Attribute is Extraneous:
❖ Consider a set F of functional dependencies and the functional dependency
α→β in F.
52
Extraneous Attributes
❖ To test if attribute A ∈ α is extraneous in α.
⮚ Compute ({ α} – A)+ using the dependencies in F.
⮚ Check ({ α} – A )+ contains A; if it does, A is extraneous.
❖ To test if attribute A ∈ β is extraneous in β
⮚ compute α+ using only the dependencies in F’ = (F – {α→β})
∪ {α →(β – A)},
⮚ check that α+ contains A; if it does, A is extraneous.
53
Canonical Cover
❖ A canonical cover for F is a set of dependencies Fc such that
I. F logically implies all dependencies in Fc, and
II. Fc logically implies all dependencies in F, and
III. No functional dependency in Fc contains an extraneous attribute, and
IV. Each left side of functional dependency in Fc is unique.
54
Canonical Cover cont…
❖ Find the minimal cover or irreducible set from the following functional
dependencies : AB → CD, BC → D
Step 1 : Union Simplification : H={AB → C , AB → D, BC → D}.
Step 2 : Removal of Redundant set of FDs –
I. First take AB🡺C, check it is essential or nor. So we compute AB+ in set J={AB🡺D, BC🡺D)
and we get (AB)+ = {ABD}. as (AB)+ will not determine C, So AB → C is non redundant or
essential and remain in H.
II. Now take AB🡺D, So we compute AB+ in set J={AB🡺C, BC🡺D) and we get (AB)+ = {ABCD}.
As (AB)+ will determine D, So AB → D is redundant or inessential and remove from H.
55
Canonical Cover cont…
III. Now we get H={AB→C, BC→D}. Now we take BC🡺D, check it is essential or nor. So we
compute BC+ in set J={AB🡺C) and we get (BC)+ = {BC}. As (BC)+ will not determine D, So
BC → D is non redundant or essential and remain in H.
Step 3: LHS Simplification or Removal of Extraneous Attributes. FDs remained after
step 2, AB→C and BC→D. First we
take AB → C.
I. Remove A from AB → C, and find B+ from J={BC🡺D}. B+ = {B} ⇒ A is Non Redundant.
II. Now drop B from AB🡺C and find A+ from j={BC🡺D}. A+={A}. B is non redundant.
56
Canonical Cover cont…
Step 3 conti… : Now we take BC → D.
I. Remove B from BC → D, and find C+ from J={AB🡺C}. C+ = {C} ⇒ B is Non Redundant.
II. Now drop C from BC🡺D and find B+ from j={AB🡺C}. B+={B}. C is non redundant.
Apply step 2 again if we find any redundant attribute, otherwise skip. So Finally, Irreducible
set will be AB→C, BC→D.
Example2: F={A🡺BC, B🡺C, A🡺B, AB🡺C}. Compute Fc for R{ABC}.
Sol: A🡺B B🡺C.
57
Canonical Cover cont…
Example: F={V🡺W, VW🡺 X, Y🡺VXZ}. Compute Fc for R{VWXYZ}.
Sol:
Example: R = {A,B,C,D,E,F,G,H} , F = {AC→G, D→EG, BC→D, CG→BD, ACD→B, CE→AG}Find the
canonical cover of F.
Example: F={A🡺BC, CD🡺E, B🡺D, E🡺A}. Compute Fc for R{ABCDE}.
Sol: AD🡺CF, C🡺B, B🡺E.
Example: F={ABCD → E, E → D , AC → D, A → B). Compute Fc for R{ABCDE}.
Sol: AC → E, E → D, A → B.
58
Decomposition
❖Functional Decomposition is the process of breaking down the functions of an
organization into progressive greater levels of details.
❖The decomposition of a relation scheme R consists of replacing the relation
schema by two or more relation schemas that each contain a subset of the
attributes of R and together include all attributes in R.
59
Decomposition conti…
❖Decomposition helps in eliminating some of the problems of bad design
such as redundancy, inconsistencies and anomalies.
❖Using the functional dependency the design algorithms decompose the
universal relation schema R into a set of relation schemas (Projection in
relational algebra.).
60
Decomposition conti…
❖R1 = projection of R on A1, ..., An, B1, ..., Bm
❖R2 = projection of R on A1, ..., An, C1, ..., Cp
❖A1, ..., An ∪ B1, ..., Bm ∪ C1, ..., Cp = all attributes
❖R1 and R2 may (/not) be reassembled to produce original R.
R(A1, ..., An, B1, ..., Bm, C1, ..., Cp)
R1(A1, ..., An, B1, ..., Bm) R2(A1, ..., An, C1, ..., Cp)
61
Decomposition conti…
❖We must make sure that each attributes in R will appear in at least one
relation schema Ri, in the decomposition, so that no attribute are lost;
❖This is called the Attribute Preservation condition of a decomposition.
62
Decomposition conti…
63
Lossy Decomposition
❖We should take care some desirable properties while doing
decomposition. If we do the careless decomposition, then it will lead to a
bad design again.
❖Consider a Schema relation which has many attributes and results into
redundancy. Let us apply Decomposition:
64
Lossy Decomposition conti…
65
Lossy Decomposition conti…
❖Now let’s apply Parts ⋈ Supplier to above relation.
66
Lossy Decomposition conti…
❖In above example some information is lost during retrieval of original
relation or table.
❖Let R be the relational schema with instance r is decomposed
into R1,R2,….,Rn with instances r1,r2,..,rn.
❖If r1 ⋈ r2 ⋈ ……. ⋈ rn ⊃ r , then it is called Lossy Join Decomposition. i.e. if
the original relation is the proper subset of natural joins of all the
decompositions, then it is said to be Lossy Join Decomposition.
67
Lossless Decomposition
❖A relational table decomposed into two or more smaller tables, in such a
way that designer can capture the precise content of the original table by
joining the decomposed parts. This is called lossless-join.
❖Let R be the relational schema with instance r is decomposed into
R1,R2,….,Rn with instance r1,r2,…..,rn.
❖If r1 ⋈ r2 ⋈ ……. ⋈ rn = r , then it is called Lossless Join Decomposition.
68
Lossless Decomposition conti…
❖If we decompose a relation R into relations R1 and R2,
❖Decomposition is lossy if R1 ⋈ R2 ⊃ R
❖Decomposition is lossless if R1 ⋈ R2 = R
69
Lossless Decomposition conti…
70
Lossless Decomposition conti…
S# P# Sname City
3 301 Smith London
5 500 Nick NY
2 20 Steve Boston
5 400 Nick NY
5 301 Nick NY
S# P# QTY
3 301 20
5 500 50
2 20 10
5 400 40
5 301 10
71
To check for lossless join
❖Union of Attributes of R1 and R2 must be equal to attribute of R. Each
attribute of R must be either in R1 or in R2.
Att(R1) U Att(R2) = Att(R)
❖Intersection of Attributes of R1 and R2 must not be NULL. i.e. Att(R1) ∩
Att(R2) ≠ Φ
❖Common attribute must be a key for at least one relation (R1 or R2)
Att(R1) ∩ Att(R2) -> (R1) or
Att(R1) ∩ Att(R2) -> (R2)
72
Find Lossless or Lossy
❖Example 1: Given R(ABCDE) having following FD’s AB→C, C→D, B→E, D =
{ABC, CDE} Check whether decomposition is lossless or lossy.
Solution: I. D={ABC, CDE} check R1 U R2=R TRUE.
II. R1∩R2 = C
III. C+ = {CD} is not a super key of any table.
Give R is Lossy join decomposition.
73
Find Lossless or Lossy
❖Example 2: If above relation with same FD set is decomposed into D =
{ABCD, BE}. Check whether decomposition is lossless or lossy.
❖Solution: Now common attribute is B
B+ = BE (super key for 2nd table)
hence lossless join decomposition
74
Dependency Preservation Property
❖The decomposition of relation R with FDs F into R1 and R2 with FDs f1
and f2 respectively, is said to be dependency preserving if.
F={f1 U f2} or F+={f1 U f2}+.
❖Example: R=(A, B, C), F= { A->B, B->C } decomposition of R: R1=(A, B)
R2=(B, C). Does this decomposition preserve the given dependencies?
75
Dependency Preservation Property
❖In R1 the following dependencies hold: F1={A->B, A->A, B->B, AB->AB}
❖In R2 the following dependencies hold: F2= {B->B, C->C, B->C, BC->BC}
❖F’= F1’ U F2’ = {A->B, B->C, only non-trivial dependencies}
❖In F’ all the original dependencies occur, so this decomposition preserves
dependencies.
76
Dependency Preservation Property
❖Example 2 : R=(A, B, C), F={A->B, B->C} Decomposition of R: R1=(A, C)
R2=(B, C). Does this decomposition preserve the given dependencies?
❖Solution: In R1 the following dependencies hold: F1={A->A, A->C, C->C,
AC->AC}
❖In R2 the following dependencies hold: F2={B->B, B->C, C->C, BC->BC}
❖F’={F1 U F2} => {A->C, B->C} i.e. not equal to F. So this decomposition not
dependency preserving.
77
Dependency Preservation Property
❖Example 3: Let R (A, B, C, D) be a relational schema with the following
functional dependencies: A → B, B → C, C → D and D → B. The
decomposition of R into (A, B), (B, C), (B, D). The relation is dependency
preserving or not?
❖Solution: Dependency Preserving.
78
Normalization
❖Normalization is the process of minimizing redundancy from a relation or set of
relations.
❖Redundancy in relation may cause insertion, deletion and updating anomalies.
So, it helps to minimize the redundancy in relations.
❖Normal forms are used to eliminate or reduce redundancy in database tables.
79
Normalization cont…
❖Normalization is a process of decomposing a set of relations with
anomalies to produce smaller and well structured relations that contain
minimum or no redundancy.
❖It is a formal process of deciding which attribute should be grouped
together in a relation.
80
Normalization cont…
❖ However during normalization, it is ensured that a normalized schema:
⮚ Does not lose any information present in the original un-normalized schema.
⮚ Preserves dependencies present in the original schema.
❖ The process of normalization was first proposed by E. F. Codd.
❖ Normalization is a bottom-up design technique for relational database.
❖ It is difficult to use in large database design.
81
Normalization cont…
❖A Normal form is a state of relation that results from applying simple
rules, regarding functional dependencies (FD’s) to that relation.
❖The normal form are used to ensure that various types of anomalies and
inconsistencies are not introduced into the database.
82
Anomalies without Normalization
❖Anomalies refers to the problems occurred after poorly planned and un-
normalized databases.
❖Lets consider a schema:
SID Sname CID Cname FEE
S1 A C1 C 5k
S2 A C1 C 5k
S1 A C2 C 10k
S3 B C2 C 10k
S3 B C3 JAVA 15k
Primary Key: (SID, CID)
83
Types of Anomalies
❖Three types of anomalies are:
⮚ Insertion Anomaly
⮚ Deletion Anomaly
⮚ Update / Modification Anomaly
❖Insertion Anomaly: In above schema if new course is introduced C4, but no
student is there who is having C4 subject.
❖Because of insertion of some data, It is forced to insert some other dummy data.
84
Insertion Anomaly
85
Insertion Anomaly cont…
❖Suppose if we want to know the number of students, then answer will be,
4 (S1,S2,S3, xx), which is not correct.
❖Deletion Anomaly:
⮚Deletion of S3 student cause the deletion of course JAVA.
⮚Because of deletion of some data forced to delete some other useful data.
86
Update Anomaly
❖ If there is updation in the fee from 5000 to 7000, then we have to update
FEE column in all the rows, else data will become inconsistent.
87
Solutions To Anomalies
❖Decomposition of Tables – Schema Refinement by normalization process.
88
Normal Forms
❖Initially E. F. Codd proposed three normal forms namely 1NF, 2NF and
3NF. Subsequently BCNF was jointly introduced by R. Boyce and E. F.
Codd. Later the normal forms 4 NF and 5 NF were produced.
1 NF 2NF 3NF BCNF 4NF 5NF
89
Normal Forms
Table with Multivalued attributes
First Normal Form
Second Normal Form
Third Normal Form
Boyce - Codd Normal Form
Fifth Normal Form
Fourth Normal Form
Remove Multivalued
attributes
Remove Partial
Dependencies
Remove Transitive
Dependencies
Remove resulting anomalies
from partial Dependencies
Remove Multivalued
Dependencies
Remove Join Dependencies
90
First Normal Form (1 NF)
❖A relation is in first Normal Form if and only if all underlying domains
contain atomic values only. In other words, a relation doesn’t have
Multivalued attributes.
❖Every tuple in the relational schema contains only one value of each
attribute and no repeating groups.
91
First Normal Form (1 NF) conti…
❖For example: consider Student relation
SID Sname Cname
S1 A C,C++
S2 B C++,DB
S3 A DB
SID Sname Cname
S1 A C
S1 A C++
S2 B C++
S2 B DB
S3 A DB
Remove
Multivalued
Attribute
92
First Normal Form (1 NF) conti…
❖Another Example: Create a database which stores my friends name and
their top three favorite artists. And FID is a primary key of the database.
93
First Normal Form (1 NF) conti…
❖Now convert into 1 NF because having Multivalued attribute favoriteartist.
Now we have 02 alternative way to convert into 1NF.
❖ First we can set number of favoriteartist values means he/she can enter
only 02 or 03 values for favoriteartist attribute.
94
First Normal Form (1 NF) conti…
FID FNAME favoriteartist1 favoriteartist2 favoriteartist3
1 Shrihari Akon The Corrs Robbie
2 Arvind Enigma Chicane Twania
95
First Normal Form (1 NF) conti…
❖But it is not a proper solution because we can not fixed attributes(
Multivalued attribute). So now we decompose the relation:
96
Second Normal Form (2 NF)
❖Relation R is in Second Normal Form (2NF) only if :
⮚R should be in 1NF and
⮚R should not contain any Partial Dependency.
❖Partial Dependency: If proper subset of candidate key determines non-
prime attribute, it is called partial dependency.
❖Suppose a relation R(A,B,C,D) and FD’s=>(AB🡺D, B🡺C), AB is a candidate
key.
97
Second Normal Form (2 NF)
❖In this example AB is candidate key and B is a proper subset of AB. C is a
non-prime attribute.
❖AB is candidate key means possible values for AB are
❖Means A or B individual can be null. Suppose B is null in that situation B🡺C
not valid. (B can not determines C).
A B
Null A
A Null
A B
98
Second Normal Form (2 NF)
❖So this database are not in second normal form.
❖We can convert into 2NF by decomposition of R:
❖R1
❖R2
A B D
Candidate Key: (A,B)
B C
Candidate Key: (B)
99
Second Normal Form (2 NF)
❖Now R1 and R2 both are in 2NF.
❖Note: If candidate key contains a single attribute, the test need not to
applied at all.
100
Third Normal Form (3 NF)
❖Let R be the relational schema, R is in 3NF only if :
⮚R should be in 2NF.
⮚R should not contain transitive dependencies.
❖Transitive dependencies: Let R be a relational Schema and X,Y,Z be the
attribute sets over R.
❖If X is functionally determines Y (X → Y) and Y is functionally determines Z
(Y → Z) then X is transitive determines Z (X → Z).
101
Third Normal Form (3 NF)
❖Example: Suppose a relation R(A,B,C,D) with following dependencies: AB🡺C, C🡺
D.
❖Now first we need to find out candidate key so we can say AB is candidate key.
AB+🡺 ABCD. So {A,B} are prime attribute and {C,D} are non-prime attributes.
❖Now check given relation R in second normal or not.
❖No Partial dependency exist because partial dependencies says every non-prime
attribute not depends on part of candidate key.
102
Third Normal Form (3 NF)
❖AB🡺C and C🡺D are in second normal form but not in 3NF because transitive
dependency exist.
❖But what will be the problem due to transitive dependency?
❖Now in this case AB 🡺 C and C🡺D. So AB🡺D with the help of C.
❖Means C is promising that I will find the value of D for AB.
❖But what will be happens when C becomes NULL because C is non- prime
attribute.
103
Third Normal Form (3 NF)
❖If C becomes null then we are unable to find D.
❖So need to overcomes this problem or convert relation into 3 NF.
❖For converting 3NF we will make C as a candidate key in decomposed
relation.
❖R1{A,B,C} because C is fully functional dependent on candidate key.
❖R2{C,D} now C is key in this Relation.
104
Boyce Codd Normal Form(BCNF)
❖Before understand BCNF we just quick review of 2 NF and 3 NF.
❖In 2 NF we talk about
❖In 3 NF we talk about
❖If we talk about all the combination then we missed :
105
Boyce Codd Normal Form(BCNF)
❖Let R be the relational schema, R is in BCNF only if :
⮚R should be in 3NF.
⮚Every Functional Dependency will have a Super-key on the LHS or all determinants
are the super-keys.
❖Example: F = {A → BCD, BC → AD, D → B} of R{ABCD}.
❖Now find candidate keys: A, BC, DC.
106
Boyce Codd Normal Form(BCNF)
❖A → BCD // In BCNF.
❖BC → AD // IN BCNF.
❖D → B // not in BCNF because of D is not a super key.
❖So we need to decompose the relation :
❖R1{D B}
❖R2{ADC}
107
Acknowledgement and Disclaimer
❖This presentation is the culmination of content extracted from a variety of sources namely
lecture notes, presentations, books and websites. In many cases, the identity of the original
contributor is not available with the author. The author wish to take this opportunity to
thank individual contributors of these extracts.
❖The author wishes to record that this presentation is solely used for education purpose and
copyright violation if any, is unintentional. The author is willing to remove any such extract
from the presentation with immediate effect.
❖The materials available at referred sites are not maintained by Acropolis Institute and we
are not responsible for the contents thereof.
❖All trademarks, service marks, and trade names used in this presentation are the marks of
the respective owner(s).
Dr Kamal Kumar Sethi
Professor & Head, IT
Acropolis Institute(AITR), Indore
kamalsethi@acropolis.in
9 July 2020 108
kamalsethi@acropolis.in
Q&A
9 July 2020 109
kamalsethi@acropolis.in
THANKS
9 July 2020 110
kamalsethi@acropolis.in

More Related Content

What's hot

Dbms normalization
Dbms normalizationDbms normalization
Dbms normalization
Pratik Devmurari
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Oum Saokosal
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
Sakshi Jaiswal
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
Kabindra Koirala
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER ModelChapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
Kunal Anand
 
Functional Dependency
Functional DependencyFunctional Dependency
Functional Dependency
Alaanoor94
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalizationdaxesh chauhan
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)
Oum Saokosal
 
Decomposition methods in DBMS
Decomposition methods in DBMSDecomposition methods in DBMS
Decomposition methods in DBMS
soniyagoyal3
 
Joins in dbms and types
Joins in dbms and typesJoins in dbms and types
Joins in dbms and types
university of Gujrat, pakistan
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
Drishti Bhalla
 
Normalization
NormalizationNormalization
Normalization
meet darji
 
joins in database
 joins in database joins in database
joins in database
Sultan Arshad
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMSkoolkampus
 
Normalization
NormalizationNormalization
Normalization
Sakshi Jaiswal
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Biplap Bhattarai
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
madhav bansal
 

What's hot (20)

Dbms normalization
Dbms normalizationDbms normalization
Dbms normalization
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER ModelChapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
 
Functional Dependency
Functional DependencyFunctional Dependency
Functional Dependency
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)
 
Decomposition methods in DBMS
Decomposition methods in DBMSDecomposition methods in DBMS
Decomposition methods in DBMS
 
Joins in dbms and types
Joins in dbms and typesJoins in dbms and types
Joins in dbms and types
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
 
Normalization
NormalizationNormalization
Normalization
 
joins in database
 joins in database joins in database
joins in database
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
Normalization
NormalizationNormalization
Normalization
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Bcnf
BcnfBcnf
Bcnf
 

Similar to DBMS Unit 3.pptx

DBMS FDs and Normalization.pptx
DBMS FDs and Normalization.pptxDBMS FDs and Normalization.pptx
DBMS FDs and Normalization.pptx
SakshamLal3
 
MODULE 4 -Normalization_1.ppt
MODULE 4 -Normalization_1.pptMODULE 4 -Normalization_1.ppt
MODULE 4 -Normalization_1.ppt
BelkinAntony1
 
Data normalization
Data normalizationData normalization
Normalization
NormalizationNormalization
Normalization
Dabbal Singh Mahara
 
Assignment#16
Assignment#16Assignment#16
Assignment#16
Sunita Milind Dol
 
Normalization.pdf
Normalization.pdfNormalization.pdf
Normalization.pdf
abhijose1
 
UNIT 2 -PPT.pptx
UNIT 2 -PPT.pptxUNIT 2 -PPT.pptx
UNIT 2 -PPT.pptx
hemamalinikrishnan2
 
Relational Algebra & Calculus
Relational Algebra & CalculusRelational Algebra & Calculus
Relational Algebra & Calculus
Abdullah Khosa
 
Database Management System [DBMS]
Database Management System [DBMS]Database Management System [DBMS]
Database Management System [DBMS]
Shalabh Chaudhary
 
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS7. Relational Database Design in DBMS
7. Relational Database Design in DBMSkoolkampus
 
DBMS 11 | Design Theory [Normalization 1]
DBMS 11 | Design Theory [Normalization 1]DBMS 11 | Design Theory [Normalization 1]
DBMS 11 | Design Theory [Normalization 1]
Mohammad Imam Hossain
 
DBMS.ppt
DBMS.pptDBMS.ppt
DBMS.ppt
SRIDHAMCH
 
Database normalization
Database normalizationDatabase normalization
Database normalization
VARSHAKUMARI49
 
DBMS-Normalization.ppt
DBMS-Normalization.pptDBMS-Normalization.ppt
DBMS-Normalization.ppt
KalpanaThakre2
 

Similar to DBMS Unit 3.pptx (20)

DBMS FDs and Normalization.pptx
DBMS FDs and Normalization.pptxDBMS FDs and Normalization.pptx
DBMS FDs and Normalization.pptx
 
MODULE 4 -Normalization_1.ppt
MODULE 4 -Normalization_1.pptMODULE 4 -Normalization_1.ppt
MODULE 4 -Normalization_1.ppt
 
Data normalization
Data normalizationData normalization
Data normalization
 
Normalization
NormalizationNormalization
Normalization
 
test
testtest
test
 
Cs501 fd nf
Cs501 fd nfCs501 fd nf
Cs501 fd nf
 
Assignment#16
Assignment#16Assignment#16
Assignment#16
 
18560 lecture6
18560 lecture618560 lecture6
18560 lecture6
 
Unit05 dbms
Unit05 dbmsUnit05 dbms
Unit05 dbms
 
Normalization.pdf
Normalization.pdfNormalization.pdf
Normalization.pdf
 
6 normalization
6 normalization6 normalization
6 normalization
 
Normalization
NormalizationNormalization
Normalization
 
UNIT 2 -PPT.pptx
UNIT 2 -PPT.pptxUNIT 2 -PPT.pptx
UNIT 2 -PPT.pptx
 
Relational Algebra & Calculus
Relational Algebra & CalculusRelational Algebra & Calculus
Relational Algebra & Calculus
 
Database Management System [DBMS]
Database Management System [DBMS]Database Management System [DBMS]
Database Management System [DBMS]
 
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS7. Relational Database Design in DBMS
7. Relational Database Design in DBMS
 
DBMS 11 | Design Theory [Normalization 1]
DBMS 11 | Design Theory [Normalization 1]DBMS 11 | Design Theory [Normalization 1]
DBMS 11 | Design Theory [Normalization 1]
 
DBMS.ppt
DBMS.pptDBMS.ppt
DBMS.ppt
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
DBMS-Normalization.ppt
DBMS-Normalization.pptDBMS-Normalization.ppt
DBMS-Normalization.ppt
 

Recently uploaded

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

DBMS Unit 3.pptx

  • 2. Functional Dependencies ❖Users probably won’t understand that term “Functional Dependency”, important to ask right question. ❖If you known a particular employee number, can you establish other information, such as name? ❖If you can determine that the name is functionally dependent on the employee number. 2
  • 3. Functional Dependencies cont… ❖Another Question: Do you know the number of the department to which the employee is assign?. ❖If you can then we can say department no is functionally dependent on employee number. ❖If a employee can be assigned to more than one department, you would not the know department number. So department no is not functionally dependent on employee number. 3
  • 4. Functional Dependencies cont… ❖Functional dependency concern the dependence of the value of one attributes or set of attributes on those of another attribute or set of attributes. ❖A FD is a property of the semantics or meaning of the attributes in a relation. ❖Semantics indicate how attributes relate to one another and specify the FDs between attributes. 4
  • 5. Functional Dependencies cont… ❖A functional dependency is defined as a constraint between two sets of attributes in a relation from a database. ❖Given a relation R, a set of attributes X in R , is said to functionally determine another attribute Y, also in R, (written X → Y) if and only if each X value is associated with at most one Y value. 5
  • 6. Functional Dependencies cont… ❖X is the determinant set and Y is the dependent attribute. Thus, given a tuple and the values of the attributes in X, one can determine the corresponding value of the Y attribute. ❖Left hand side of the FD is called determinant whereas that of the right side is called dependent. 6
  • 7. Functional Dependencies cont… ❖Example: Employee Note: Name is functionally dependent on SSN because an employee’s name can be uniquely determined from their SSN. Name does not determine SSN, because more than one employee can have the same name.. 7
  • 8. Functional Dependencies cont… ❖Example: Employee and Project ❖SSN -> ENAME ❖PNUMBER ->{PNAME, PLOCATION} ❖{SSS, PNUMBER} -> HOURS SSN PNUMBER HOURS ENAME PNAME PLOCATION 8
  • 9. Keys ❖ Whereas a key is a set of attributes that uniquely identifies an entire tuple, a functional dependency allows us to express constraints that uniquely identify the values of certain attributes. ❖However, a candidate key is always a determinant, but a determinant doesn’t need to be a key. 9
  • 10. Full Functional Dependency (FDD) ❖ Minimal set of attributes in a determinant of a FD. ❖Other words the set of attributes Y will be fully functionally dependent on the set of attributes X, ⮚ Y is functionally dependent on X. ⮚ Y is not functionally dependent on any subset of X. 10
  • 11. Full Functional Dependency cont… ❖ Example Emp_id, Project_no, Project_budget -> Yr_spent_by_emp_on_project. ❖In this Emp_id and Project_no is sufficient set of attribute to determines the value of right hand side. So there is no need of Project-budget. FDD is Emp_id, Project_no-> Yr_spent_by_emp_on_project 11
  • 12. Full Functional Dependency cont… ❖A FD X -> Y is a fully functional dependency if removal of any attribute A from X, means that the dependency does not hold any more: i.e. for any attribute A Ɛ X. ❖Example: {SSN, Pnumber} -> Hours. ❖We can not remove any attribute from determinant side. 12
  • 13. Closure (F+) ❖ Let a relation R have some functional dependencies F specified. ❖ The closure of F (usually written as F+) is the set of all functional dependencies that may be logically derived from F. ❖ Often F is the set of most obvious and important functional dependencies and F+, the closure, is the set of all the functional dependencies including F and those that can be deduced from F. ❖ The closure is important and may, for example, be needed in finding one or more candidate keys of the relation. 13
  • 14. Closure (F+) ❖Example: FD is given: SSN->{ename, bdate, address, dnumber} Dnumber-> dname, dmgr_ssn Now we can infer from F are the following: SSN -> Dname, dmgr_sssn 14
  • 15. Axioms (Inference Rules) ❖Before we can determine the closure of the relation, we need a set of rules. ❖Developed by Armstrong in 1974, there are six rules (axioms) that all possible functional dependencies may be derived from them. 15
  • 16. Axioms (Inference Rules) cont… ❖Reflexivity Rule :- If X is a set of attributes and Y is a subset of X, then X → Y holds. Example: AB->A. ❖Augmentation Rule :- If X → Y holds and W is a set of attributes, then WX → WY holds. Example: AB->C, ABD->CD 16
  • 17. Axioms (Inference Rules) cont… ❖Transitivity Rule :- If X → Y and Y → Z holds, then X → Z holds. Example: A → BC (GIVEN) find BC->B and A->B BC → B (Using Rule 1, since B ⊆ BC) A → B (Using Rule 3) 17
  • 18. Derived Theorems from Axioms ❖Union Rule :- If X → Y and X → Z holds, then X → YZ holds. ❖Decomposition Rule :-If X → YZ holds, then X → Y and X → Z. ❖Pseudotransitivity Rule :- If X → Y and WY → Z hold then WX → Z. 18
  • 19. Derived Theorems from Axioms ❖Composition – If A->B and X->Y holds, then AX ->BY holds. ❖Self Determination Rule - A → A is a self determination rule. ❖Note: These are not commutative as well as associative. i.e. if X → Y then Y → X (not possible) 19
  • 20. Exercise ❖Consider relation E = (P, Q, R, S, T, U) having set of Functional Dependencies (FD). ❖P → Q , P → R, QR → S , Q → T, R → U, PR → U ❖Calculate some members of Axioms are as follows, ❖ P → T ❖ PR → S ❖QR → SU ❖PR → SU 20
  • 21. Exercise (Solution) ❖Given FD’s are: P → Q , P → R, QR → S , Q → T, R → U, PR → U 1. P → T In the above FD set, P → Q and Q → T Using Transitive Rule: If P → Q and Q → T, then P → T. 2. PR → S In the above FD set, P → Q and QR → S. Using Pseudo Transitivity Rule: If P → Q and QR → S, then PR → S. 21
  • 22. Exercise (Solution) ❖Given FD’s are: P → Q , P → R, QR → S , Q → T, R → U, PR → U 3. QR → SU In above FD set, QR → S and QR → U Using Union Rule: If QR → S and QR → U, then QR → SU. 4. PR → SU Using Pseudo Transitivity Rule: If PR → S and PR → U, then PR → SU. 22
  • 23. Exercise (Home Work) ❖Consider a relational scheme R with attributes A,B,C,D,F and the FDs A → BC, B → E, CD → EF. Prove that functional dependency AD → F holds in R. ❖Let set of FD's are given F={A->B, C->X, BX->Z}. Prove or disprove that AC- >Z. ❖Let F={A->B, C->D, C IS SUBSET OF B}. Prove or disprove that A->C. 23
  • 24. Points to Compute Closure ❖First start with result: First we assign the result same as the value of the closure which we want to compute. ❖Inner Loop: We now go to the inner loop as many times as the FD’s are given. ❖Find Subset: If we find that the left hand side is the subset of the closure, which we want to compute , add those attributes to the result. 24
  • 25. Points to Compute Closure ❖Nested Inner Loop: Now we go to the inner loop many times as the left hand side is the subset of the result. ❖Stop Inner loop: If left hand side is not the subset of the result, we stop going round to the inner loop. ❖Result: Final result is generated. 25
  • 26. Example: Compute Closure ❖Let R={A,B,C,D,E,F} and FDs {A->BC, E->CF, B->E, CD->EF}. Now compute the closure {AB}+. ❖Solution: 1. Start with result: {AB} so AB->AB {all attributes are determined by itself.} 2. We now go to inner loop four times because of fours FDs. (I) Iteration I: Inner Loop Iteration (I) We have AB-> AB now take FD A- >BC. Check left hand side is the subset of the result {AB}. 26
  • 27. Example: Compute Closure A->BC and AB->AB Means A is subset of AB. If yes then include B and C into result. So new result set is {ABC} Note: Include only those attributes which are not present in result set. Inner Loop Iteration II: After first iteration we have result set {ABC}. Now take E->CF. Find left hand side is subset of result set =🡺 NO. So result set remain unchanged {ABC}. 27
  • 28. Example: Compute Closure Inner Loop Iteration III: Result set {ABC}. Now take B->E. Check left side is subset of Result set: YES Include E into result set. So new result set is: {ABCE}. Inner Loop Iteration IV: Result set {ABCE}. Now take CD->EF. Check left side is subset of Result set: NO Result set remain unchanged: {ABCE}. 28
  • 29. Example: Compute Closure II. Iteration II: After Iteration I we have result set {ABCE}. Now we will compute inner loop again four times: Inner loop Iteration I: {ABCE} result set. Now take A->BE. Check left side is subset: YES. Result set{ABCE}. Inner loop Iteration II: {ABCE} result set. Now take E->CF. Check left side is subset: YES. Result set{ABCEF}. 29
  • 30. Example: Compute Closure Inner loop Iteration III: {ABCEF} result set. Now take B->E. Check left side is subset: YES. Result set no changed. {ABCEF}. Inner loop Iteration IV: {ABCEF} result set. Now take CD->EF. Check left side is subset: YES. Result set no changed. {ABCEF}. III. Iteration III: Result set {ABCEF}. Now Computer inner loop four time. No changes in result set. 30
  • 31. Example: Compute Closure IV. Iteration IV: Result set {ABCEF}. Now Computer inner loop four time. No changes in result set. So the whole process terminates with : AB+ = {ABCEF}. Exercise I : Let R {A,B,C,D,E} AND FDs AB->C, A->D, D->E, AC->B. Compute AB+, A+, B+, D+. Solutions: AB+= {ABCDE}, A+={ADE}, B+={B}, D+={DE}. 31
  • 32. Example: Compute Closure Exercise II : Let R {A,B,C,G,H,I} AND FDs A->B, A->C, CG->H, CG->I, B->H. Compute AG+ Solutions: AG+= ABCGHI 32
  • 33. Trivial and Non-Trivial FD If a functional dependency X->Y holds true where Y is a subset of X then this dependency is called trivial Functional dependency. Example: {Student_Id, Student_Name} -> Student_Id is a trivial functional dependency as Student_Id is a subset of {Student_Id, Student_Name}. 33
  • 34. Trivial and Non-Trivial FD If a functional dependency X->Y holds true where Y is not a subset of X then this dependency is called non trivial Functional dependency. Example: Employee Table: emp_id -> emp_name , emp_id -> emp_address 34
  • 35. Trivial and Non-Trivial FD If a functional dependency X->Y holds true where Y is not a subset of X then this dependency is called non trivial Functional dependency. Example: Employee Table: emp_id -> emp_name , emp_id -> emp_address 35
  • 36. Cover and Equivalence of FD’s ❖ Set of functional dependencies F is said to cover another set of functional dependencies G, if every FD in G is also in F+; that is, if every dependency in G can be inferred from F; alternatively, we can say that G is covered by F. 36
  • 37. Cover and Equivalence of FD’s ❖ Two sets of functional dependencies G and F are equivalent if G+ = F+. Therefore, equivalence means that every FD in G can be inferred from F, and every FD in F can be inferred from G; that is, G is equivalent to F, if both the conditions—G covers F and F covers G—hold. 37
  • 38. Cover and Equivalence of FD’s Example: F = {A → C, AC → D, E → AD, E → H} and G = {A → CD, E → AH}. ❖ Take Set F and Check G is covered from F or not. ❖ A+= ACD, E+=ADCH ❖ Hence, both A → CD and E → AH are covered. ❖ G is derived from F. Hence G is covered by F. 38
  • 39. Cover and Equivalence of FD’s Example: F = {A → C, AC → D, E → AD, E → H} and G = {A → CD, E → AH}. ❖ Take Set G and Check F is covered from G or not. ❖ (A)+ = {ACD} (AC)+ = {ACD} (E)+ = {EAHCD} Hence F = {A → C, AC → D, E → AD, E → H} is covered. F is derived from G. Hence F is covered from G. So F is cover by G and G is cover by F, we can say F and G are equivalent. 39
  • 40. Determining Candidate Key 1. Compute Closure of each of attributes. i.e. A+, B+. 2. If any attribute is candidate key then do not create any candidate key using it. Because its subset not allow to make another attribute as a candidate key. 3. Any attribute is called a candidate key of any relation, if attribute closure is equal to the relation. For Example: if R{A,B,C,D,E} then A is a candidate key, if A+={A,B,C,D,E}. 40
  • 41. Determining Candidate Key cont… Example: Given R{A,B,C,D} And FDs F={AB->C, C->D, D->A}. List all the candidate keys. Solution: 1. compute A+={A} // not a candidate key because A+ can not determines all A, B, C, D. 2. B+=B //not a candidate key. 3. C+=CDA // not a candidate key. 4. D+=DA // not a candidate key. 5. AB+=ABCD //AB is a candidate key. 41
  • 42. Determining Candidate Key cont… So any combination of AB does not form other candidate key. 6. AC+=ACD // not a candidate key. 7. AD+=AD //not a candidate key. 8. BC+=BCDA // candidate key. Combination not allowed. 9. BD+=ABCD //candidate key. 10. CD+=CDA //not a candidate key. 42
  • 43. Determining Candidate Key cont… List of candidate keys { AB, BC, BD}. Example 2: Given R {A,B,C,D,E}. List all candidates keys of R for a given FD’s {A->BC, CD->E, B->D, E->A}. Result: {A, E, BC, CD}. Example 3: R{ABCD} , FD’s ABC->D, D->A. Result: {ABC, BCD}. 43
  • 44. Non-redundant Covers ❖ A set F, of FDs is non-redundant if there is no proper subset F’ of F, with F’ = F. If such an F ’ exists, F is redundant. F is a non-redundant cover for G, if F is a cover for G and F is non-redundant. ❖ A functional dependency in the set, is redundant if it can be derived from the other functional dependencies in the set. ❖ We can remove some FD which are redundant to make the whole FD’s non redundant. 44
  • 45. Steps to detect redundant FD’s A redundant FD can be detected using the following steps: 1. Start with a set of F, of functional dependencies (FDs). 2. Remove an FD, f and create a set of FDs F' = F - f . 3. Test whether f can be derived from the FDs in F'; 4. If f can be derived, it is redundant , and hence F' = F. Otherwise replace f into F'; so that now F' = F + f. 45
  • 46. Steps to detect redundant FD’s conti… 5: Repeat steps 2 to 4 for all FDs in F. Example: F={Z -> A B -> X AX -> Y ZB -> Y } Step I: F’=F-f 🡺 F’={B->X AX->Y ZB->Y} Step II: Check Z-> A derive from F’. //NO we can not derive. So Z->A is not redundant. Repeat Step: check for B->X //not redundant. Repeat Step: check for AX->Y //not redundant. Repeat Step: check for ZB->Y. // redundant. 46
  • 47. Steps to detect redundant FD’s conti… ❖ Z -> A by augmentation rule will yield ZB -> AB. ❖ B -> X and AX -> Y by pseudo-transitivity rule will yield AB -> Y. ❖ ZB -> AB and AB -> Y by transitivity rule will yield ZB -> Y. So ZB->Y redundant. 47
  • 48. Steps to detect redundant FD’s conti… Example 2: F = {A -> B, C -> D, BD -> E, AC -> E} ❖ Find out whether a FD f : AC -> E is redundant or not. ❖ Find out whether a FD f : BD -> E is redundant or not. ❖ AC->E redundant. ❖ BD->E non redundant. Example 3: R{XYZWPQ} F🡺{X->YZ, ZW->P, P->Z, W->XPQ, XYQ->YW, WQ- >YZ}. Find non redundant. Sol: {X->YZ, P->Z, W->XPQ, XYQ->YW} 48
  • 49. Irreducible/ minimal set/ canonical cover ❖ A canonical cover of F is a “minimal” set of functional dependencies equivalent to F, having no redundant dependencies or redundant parts of dependencies. ❖ Canonical cover of any functional dependency is denoted by Fc. ❖ Canonical cover Fc for F is a set of dependencies such that F logically implies all dependencies in Fc and Fc logically implies all dependencies in F. So Fc must have the following properties: 49
  • 50. Irreducible/ minimal set/ canonical cover ❖No functional dependency in Fc contains an extraneous attribute. ❖Each left side of a functional dependency in Fc is unique. That is there are no two dependencies X1->Y1 and X2->Y2 in Fc such that X1=X2. 50
  • 51. Irreducible/ minimal set/ canonical cover ❖ Sets of functional dependencies may have redundant dependencies that can be inferred from the others. ❖ Eg: A → C is redundant in: {A → B, B → C, A → C}. ❖ Parts of a functional dependency may be redundant . ❖ E.g. on RHS: {A → B, B → C, A → CD} can be simplified to {A → B, B → C, A → D} ❖ E.g. on LHS: {A → B, B → C, AC → D} can be simplified to {A → B, B → C, A → D} 51
  • 52. Extraneous Attributes ❖ Consider F, and a functional dependency, A 🡺B. ❖ “Extraneous”: Are there any attributes in A or B that can be safely removed, without changing thFe constraints implied by F. Testing if an Attribute is Extraneous: ❖ Consider a set F of functional dependencies and the functional dependency α→β in F. 52
  • 53. Extraneous Attributes ❖ To test if attribute A ∈ α is extraneous in α. ⮚ Compute ({ α} – A)+ using the dependencies in F. ⮚ Check ({ α} – A )+ contains A; if it does, A is extraneous. ❖ To test if attribute A ∈ β is extraneous in β ⮚ compute α+ using only the dependencies in F’ = (F – {α→β}) ∪ {α →(β – A)}, ⮚ check that α+ contains A; if it does, A is extraneous. 53
  • 54. Canonical Cover ❖ A canonical cover for F is a set of dependencies Fc such that I. F logically implies all dependencies in Fc, and II. Fc logically implies all dependencies in F, and III. No functional dependency in Fc contains an extraneous attribute, and IV. Each left side of functional dependency in Fc is unique. 54
  • 55. Canonical Cover cont… ❖ Find the minimal cover or irreducible set from the following functional dependencies : AB → CD, BC → D Step 1 : Union Simplification : H={AB → C , AB → D, BC → D}. Step 2 : Removal of Redundant set of FDs – I. First take AB🡺C, check it is essential or nor. So we compute AB+ in set J={AB🡺D, BC🡺D) and we get (AB)+ = {ABD}. as (AB)+ will not determine C, So AB → C is non redundant or essential and remain in H. II. Now take AB🡺D, So we compute AB+ in set J={AB🡺C, BC🡺D) and we get (AB)+ = {ABCD}. As (AB)+ will determine D, So AB → D is redundant or inessential and remove from H. 55
  • 56. Canonical Cover cont… III. Now we get H={AB→C, BC→D}. Now we take BC🡺D, check it is essential or nor. So we compute BC+ in set J={AB🡺C) and we get (BC)+ = {BC}. As (BC)+ will not determine D, So BC → D is non redundant or essential and remain in H. Step 3: LHS Simplification or Removal of Extraneous Attributes. FDs remained after step 2, AB→C and BC→D. First we take AB → C. I. Remove A from AB → C, and find B+ from J={BC🡺D}. B+ = {B} ⇒ A is Non Redundant. II. Now drop B from AB🡺C and find A+ from j={BC🡺D}. A+={A}. B is non redundant. 56
  • 57. Canonical Cover cont… Step 3 conti… : Now we take BC → D. I. Remove B from BC → D, and find C+ from J={AB🡺C}. C+ = {C} ⇒ B is Non Redundant. II. Now drop C from BC🡺D and find B+ from j={AB🡺C}. B+={B}. C is non redundant. Apply step 2 again if we find any redundant attribute, otherwise skip. So Finally, Irreducible set will be AB→C, BC→D. Example2: F={A🡺BC, B🡺C, A🡺B, AB🡺C}. Compute Fc for R{ABC}. Sol: A🡺B B🡺C. 57
  • 58. Canonical Cover cont… Example: F={V🡺W, VW🡺 X, Y🡺VXZ}. Compute Fc for R{VWXYZ}. Sol: Example: R = {A,B,C,D,E,F,G,H} , F = {AC→G, D→EG, BC→D, CG→BD, ACD→B, CE→AG}Find the canonical cover of F. Example: F={A🡺BC, CD🡺E, B🡺D, E🡺A}. Compute Fc for R{ABCDE}. Sol: AD🡺CF, C🡺B, B🡺E. Example: F={ABCD → E, E → D , AC → D, A → B). Compute Fc for R{ABCDE}. Sol: AC → E, E → D, A → B. 58
  • 59. Decomposition ❖Functional Decomposition is the process of breaking down the functions of an organization into progressive greater levels of details. ❖The decomposition of a relation scheme R consists of replacing the relation schema by two or more relation schemas that each contain a subset of the attributes of R and together include all attributes in R. 59
  • 60. Decomposition conti… ❖Decomposition helps in eliminating some of the problems of bad design such as redundancy, inconsistencies and anomalies. ❖Using the functional dependency the design algorithms decompose the universal relation schema R into a set of relation schemas (Projection in relational algebra.). 60
  • 61. Decomposition conti… ❖R1 = projection of R on A1, ..., An, B1, ..., Bm ❖R2 = projection of R on A1, ..., An, C1, ..., Cp ❖A1, ..., An ∪ B1, ..., Bm ∪ C1, ..., Cp = all attributes ❖R1 and R2 may (/not) be reassembled to produce original R. R(A1, ..., An, B1, ..., Bm, C1, ..., Cp) R1(A1, ..., An, B1, ..., Bm) R2(A1, ..., An, C1, ..., Cp) 61
  • 62. Decomposition conti… ❖We must make sure that each attributes in R will appear in at least one relation schema Ri, in the decomposition, so that no attribute are lost; ❖This is called the Attribute Preservation condition of a decomposition. 62
  • 64. Lossy Decomposition ❖We should take care some desirable properties while doing decomposition. If we do the careless decomposition, then it will lead to a bad design again. ❖Consider a Schema relation which has many attributes and results into redundancy. Let us apply Decomposition: 64
  • 66. Lossy Decomposition conti… ❖Now let’s apply Parts ⋈ Supplier to above relation. 66
  • 67. Lossy Decomposition conti… ❖In above example some information is lost during retrieval of original relation or table. ❖Let R be the relational schema with instance r is decomposed into R1,R2,….,Rn with instances r1,r2,..,rn. ❖If r1 ⋈ r2 ⋈ ……. ⋈ rn ⊃ r , then it is called Lossy Join Decomposition. i.e. if the original relation is the proper subset of natural joins of all the decompositions, then it is said to be Lossy Join Decomposition. 67
  • 68. Lossless Decomposition ❖A relational table decomposed into two or more smaller tables, in such a way that designer can capture the precise content of the original table by joining the decomposed parts. This is called lossless-join. ❖Let R be the relational schema with instance r is decomposed into R1,R2,….,Rn with instance r1,r2,…..,rn. ❖If r1 ⋈ r2 ⋈ ……. ⋈ rn = r , then it is called Lossless Join Decomposition. 68
  • 69. Lossless Decomposition conti… ❖If we decompose a relation R into relations R1 and R2, ❖Decomposition is lossy if R1 ⋈ R2 ⊃ R ❖Decomposition is lossless if R1 ⋈ R2 = R 69
  • 71. Lossless Decomposition conti… S# P# Sname City 3 301 Smith London 5 500 Nick NY 2 20 Steve Boston 5 400 Nick NY 5 301 Nick NY S# P# QTY 3 301 20 5 500 50 2 20 10 5 400 40 5 301 10 71
  • 72. To check for lossless join ❖Union of Attributes of R1 and R2 must be equal to attribute of R. Each attribute of R must be either in R1 or in R2. Att(R1) U Att(R2) = Att(R) ❖Intersection of Attributes of R1 and R2 must not be NULL. i.e. Att(R1) ∩ Att(R2) ≠ Φ ❖Common attribute must be a key for at least one relation (R1 or R2) Att(R1) ∩ Att(R2) -> (R1) or Att(R1) ∩ Att(R2) -> (R2) 72
  • 73. Find Lossless or Lossy ❖Example 1: Given R(ABCDE) having following FD’s AB→C, C→D, B→E, D = {ABC, CDE} Check whether decomposition is lossless or lossy. Solution: I. D={ABC, CDE} check R1 U R2=R TRUE. II. R1∩R2 = C III. C+ = {CD} is not a super key of any table. Give R is Lossy join decomposition. 73
  • 74. Find Lossless or Lossy ❖Example 2: If above relation with same FD set is decomposed into D = {ABCD, BE}. Check whether decomposition is lossless or lossy. ❖Solution: Now common attribute is B B+ = BE (super key for 2nd table) hence lossless join decomposition 74
  • 75. Dependency Preservation Property ❖The decomposition of relation R with FDs F into R1 and R2 with FDs f1 and f2 respectively, is said to be dependency preserving if. F={f1 U f2} or F+={f1 U f2}+. ❖Example: R=(A, B, C), F= { A->B, B->C } decomposition of R: R1=(A, B) R2=(B, C). Does this decomposition preserve the given dependencies? 75
  • 76. Dependency Preservation Property ❖In R1 the following dependencies hold: F1={A->B, A->A, B->B, AB->AB} ❖In R2 the following dependencies hold: F2= {B->B, C->C, B->C, BC->BC} ❖F’= F1’ U F2’ = {A->B, B->C, only non-trivial dependencies} ❖In F’ all the original dependencies occur, so this decomposition preserves dependencies. 76
  • 77. Dependency Preservation Property ❖Example 2 : R=(A, B, C), F={A->B, B->C} Decomposition of R: R1=(A, C) R2=(B, C). Does this decomposition preserve the given dependencies? ❖Solution: In R1 the following dependencies hold: F1={A->A, A->C, C->C, AC->AC} ❖In R2 the following dependencies hold: F2={B->B, B->C, C->C, BC->BC} ❖F’={F1 U F2} => {A->C, B->C} i.e. not equal to F. So this decomposition not dependency preserving. 77
  • 78. Dependency Preservation Property ❖Example 3: Let R (A, B, C, D) be a relational schema with the following functional dependencies: A → B, B → C, C → D and D → B. The decomposition of R into (A, B), (B, C), (B, D). The relation is dependency preserving or not? ❖Solution: Dependency Preserving. 78
  • 79. Normalization ❖Normalization is the process of minimizing redundancy from a relation or set of relations. ❖Redundancy in relation may cause insertion, deletion and updating anomalies. So, it helps to minimize the redundancy in relations. ❖Normal forms are used to eliminate or reduce redundancy in database tables. 79
  • 80. Normalization cont… ❖Normalization is a process of decomposing a set of relations with anomalies to produce smaller and well structured relations that contain minimum or no redundancy. ❖It is a formal process of deciding which attribute should be grouped together in a relation. 80
  • 81. Normalization cont… ❖ However during normalization, it is ensured that a normalized schema: ⮚ Does not lose any information present in the original un-normalized schema. ⮚ Preserves dependencies present in the original schema. ❖ The process of normalization was first proposed by E. F. Codd. ❖ Normalization is a bottom-up design technique for relational database. ❖ It is difficult to use in large database design. 81
  • 82. Normalization cont… ❖A Normal form is a state of relation that results from applying simple rules, regarding functional dependencies (FD’s) to that relation. ❖The normal form are used to ensure that various types of anomalies and inconsistencies are not introduced into the database. 82
  • 83. Anomalies without Normalization ❖Anomalies refers to the problems occurred after poorly planned and un- normalized databases. ❖Lets consider a schema: SID Sname CID Cname FEE S1 A C1 C 5k S2 A C1 C 5k S1 A C2 C 10k S3 B C2 C 10k S3 B C3 JAVA 15k Primary Key: (SID, CID) 83
  • 84. Types of Anomalies ❖Three types of anomalies are: ⮚ Insertion Anomaly ⮚ Deletion Anomaly ⮚ Update / Modification Anomaly ❖Insertion Anomaly: In above schema if new course is introduced C4, but no student is there who is having C4 subject. ❖Because of insertion of some data, It is forced to insert some other dummy data. 84
  • 86. Insertion Anomaly cont… ❖Suppose if we want to know the number of students, then answer will be, 4 (S1,S2,S3, xx), which is not correct. ❖Deletion Anomaly: ⮚Deletion of S3 student cause the deletion of course JAVA. ⮚Because of deletion of some data forced to delete some other useful data. 86
  • 87. Update Anomaly ❖ If there is updation in the fee from 5000 to 7000, then we have to update FEE column in all the rows, else data will become inconsistent. 87
  • 88. Solutions To Anomalies ❖Decomposition of Tables – Schema Refinement by normalization process. 88
  • 89. Normal Forms ❖Initially E. F. Codd proposed three normal forms namely 1NF, 2NF and 3NF. Subsequently BCNF was jointly introduced by R. Boyce and E. F. Codd. Later the normal forms 4 NF and 5 NF were produced. 1 NF 2NF 3NF BCNF 4NF 5NF 89
  • 90. Normal Forms Table with Multivalued attributes First Normal Form Second Normal Form Third Normal Form Boyce - Codd Normal Form Fifth Normal Form Fourth Normal Form Remove Multivalued attributes Remove Partial Dependencies Remove Transitive Dependencies Remove resulting anomalies from partial Dependencies Remove Multivalued Dependencies Remove Join Dependencies 90
  • 91. First Normal Form (1 NF) ❖A relation is in first Normal Form if and only if all underlying domains contain atomic values only. In other words, a relation doesn’t have Multivalued attributes. ❖Every tuple in the relational schema contains only one value of each attribute and no repeating groups. 91
  • 92. First Normal Form (1 NF) conti… ❖For example: consider Student relation SID Sname Cname S1 A C,C++ S2 B C++,DB S3 A DB SID Sname Cname S1 A C S1 A C++ S2 B C++ S2 B DB S3 A DB Remove Multivalued Attribute 92
  • 93. First Normal Form (1 NF) conti… ❖Another Example: Create a database which stores my friends name and their top three favorite artists. And FID is a primary key of the database. 93
  • 94. First Normal Form (1 NF) conti… ❖Now convert into 1 NF because having Multivalued attribute favoriteartist. Now we have 02 alternative way to convert into 1NF. ❖ First we can set number of favoriteartist values means he/she can enter only 02 or 03 values for favoriteartist attribute. 94
  • 95. First Normal Form (1 NF) conti… FID FNAME favoriteartist1 favoriteartist2 favoriteartist3 1 Shrihari Akon The Corrs Robbie 2 Arvind Enigma Chicane Twania 95
  • 96. First Normal Form (1 NF) conti… ❖But it is not a proper solution because we can not fixed attributes( Multivalued attribute). So now we decompose the relation: 96
  • 97. Second Normal Form (2 NF) ❖Relation R is in Second Normal Form (2NF) only if : ⮚R should be in 1NF and ⮚R should not contain any Partial Dependency. ❖Partial Dependency: If proper subset of candidate key determines non- prime attribute, it is called partial dependency. ❖Suppose a relation R(A,B,C,D) and FD’s=>(AB🡺D, B🡺C), AB is a candidate key. 97
  • 98. Second Normal Form (2 NF) ❖In this example AB is candidate key and B is a proper subset of AB. C is a non-prime attribute. ❖AB is candidate key means possible values for AB are ❖Means A or B individual can be null. Suppose B is null in that situation B🡺C not valid. (B can not determines C). A B Null A A Null A B 98
  • 99. Second Normal Form (2 NF) ❖So this database are not in second normal form. ❖We can convert into 2NF by decomposition of R: ❖R1 ❖R2 A B D Candidate Key: (A,B) B C Candidate Key: (B) 99
  • 100. Second Normal Form (2 NF) ❖Now R1 and R2 both are in 2NF. ❖Note: If candidate key contains a single attribute, the test need not to applied at all. 100
  • 101. Third Normal Form (3 NF) ❖Let R be the relational schema, R is in 3NF only if : ⮚R should be in 2NF. ⮚R should not contain transitive dependencies. ❖Transitive dependencies: Let R be a relational Schema and X,Y,Z be the attribute sets over R. ❖If X is functionally determines Y (X → Y) and Y is functionally determines Z (Y → Z) then X is transitive determines Z (X → Z). 101
  • 102. Third Normal Form (3 NF) ❖Example: Suppose a relation R(A,B,C,D) with following dependencies: AB🡺C, C🡺 D. ❖Now first we need to find out candidate key so we can say AB is candidate key. AB+🡺 ABCD. So {A,B} are prime attribute and {C,D} are non-prime attributes. ❖Now check given relation R in second normal or not. ❖No Partial dependency exist because partial dependencies says every non-prime attribute not depends on part of candidate key. 102
  • 103. Third Normal Form (3 NF) ❖AB🡺C and C🡺D are in second normal form but not in 3NF because transitive dependency exist. ❖But what will be the problem due to transitive dependency? ❖Now in this case AB 🡺 C and C🡺D. So AB🡺D with the help of C. ❖Means C is promising that I will find the value of D for AB. ❖But what will be happens when C becomes NULL because C is non- prime attribute. 103
  • 104. Third Normal Form (3 NF) ❖If C becomes null then we are unable to find D. ❖So need to overcomes this problem or convert relation into 3 NF. ❖For converting 3NF we will make C as a candidate key in decomposed relation. ❖R1{A,B,C} because C is fully functional dependent on candidate key. ❖R2{C,D} now C is key in this Relation. 104
  • 105. Boyce Codd Normal Form(BCNF) ❖Before understand BCNF we just quick review of 2 NF and 3 NF. ❖In 2 NF we talk about ❖In 3 NF we talk about ❖If we talk about all the combination then we missed : 105
  • 106. Boyce Codd Normal Form(BCNF) ❖Let R be the relational schema, R is in BCNF only if : ⮚R should be in 3NF. ⮚Every Functional Dependency will have a Super-key on the LHS or all determinants are the super-keys. ❖Example: F = {A → BCD, BC → AD, D → B} of R{ABCD}. ❖Now find candidate keys: A, BC, DC. 106
  • 107. Boyce Codd Normal Form(BCNF) ❖A → BCD // In BCNF. ❖BC → AD // IN BCNF. ❖D → B // not in BCNF because of D is not a super key. ❖So we need to decompose the relation : ❖R1{D B} ❖R2{ADC} 107
  • 108. Acknowledgement and Disclaimer ❖This presentation is the culmination of content extracted from a variety of sources namely lecture notes, presentations, books and websites. In many cases, the identity of the original contributor is not available with the author. The author wish to take this opportunity to thank individual contributors of these extracts. ❖The author wishes to record that this presentation is solely used for education purpose and copyright violation if any, is unintentional. The author is willing to remove any such extract from the presentation with immediate effect. ❖The materials available at referred sites are not maintained by Acropolis Institute and we are not responsible for the contents thereof. ❖All trademarks, service marks, and trade names used in this presentation are the marks of the respective owner(s). Dr Kamal Kumar Sethi Professor & Head, IT Acropolis Institute(AITR), Indore kamalsethi@acropolis.in 9 July 2020 108 kamalsethi@acropolis.in
  • 109. Q&A 9 July 2020 109 kamalsethi@acropolis.in
  • 110. THANKS 9 July 2020 110 kamalsethi@acropolis.in