SlideShare a Scribd company logo
Learning Resource
On
Database Management Systems
Chapter-8
Relational Database Design
Prepared By:
Kunal Anand, Asst. Professor
SCE, KIIT, DU, Bhubaneswar-24
Chapter Outcome:
• After the completion of this chapter, the students
will be able to:
– Identify the problems associated with bad database
design
– Explain Functional Dependency
– List different types of dependencies
– Explain Armstrong Inference Axioms
– Determine closure of attribute / attribute set
– Determine closure of FDs
– Determine equivalence of FDs
– Identify redundant FDs
– Determine Canonical or Minimal Cover
16 March 2021 2
Organization of this Chapter:
• Introduction to Database Design
• Problems encountered with bad design
• Functional Dependency Theory
• Armstrong Inference Axioms
• Closure of Attributes/Attribute Set
• Closure of a Set of Functional Dependency
• Equivalence of FDs
• Redundancy of FDs
• Canonical Cover
16 March 2021 3
Introduction to Database Design
• The goal of relational database design is to generate a set of
relational schemas that allow us to store information without
unnecessary redundancy, yet it allows us to retrieve
information easily.
• First, fully characterize the data requirements of the
prospective database users, which usually involves in textual
descriptions.
• Next, choose ER model to translate these requirements into a
conceptual schema of the database.
• In the logical design phase, map the high level conceptual
schema onto the implementation data model of the database
system that will be used. The implementation data model is
typically the Relational data model.
16 March 2021 4
contd..
• Finally, use the resulting system specific database schema in
the subsequent physical design phase, in which the physical
features of the database are specified.
• Database design may be performed using following two
approaches:
– Bottom-up approach: It is also known as design by synthesis. It
considers the basic relationship among individual attributes to
construct the schemas. It suffers from a problem of finding large
number of binary relationship among the attributes as the starting
point, that is extremely difficult to achieve.
– Top-down approach: It is also known as design by analysis. It
starts with a number of grouping of attributes into relations that
exists naturally e.g. Invoice, or a form, or a report. The relations are
then analyzed individually and collectively, leading to further
decomposition and until all desirable properties are met.
16 March 2021 5
Bad Database Design/Concepts of Anomalies
• Problems that can occur in poorly planned, un-normalized
databases where all the data is stored in one table.
• These anomalies affect the process of inserting, deleting and
updating data in the relations. The intension of relational
database theory is to eliminate anomalies from occurring in a
database. Consider the student database.
16 March 2021 6
Name Course Phone_no Major Prof Grade
Mahesh 353 1234 Comp sc Alok A
Nitish 329 2435 Chemistry Pratap B
Mahesh 328 1234 Comp sc Samuel B
Harish 456 4665 Physics James A
Pranshu 293 4437 Decision sc Sachin C
Prateek 491 8788 Math Saurav B
Prateek 356 8788 Math Sunil In prog
Mahesh 492 1234 Comp sc Paresh In prog
Sumit 379 4575 English Rakesh C
contd..
• Insertion Anomaly: It is the anomaly in which the user cannot
insert an attribute about an entity until he/she has an additional
attribute about another entity.
– Ex: Suppose a new prof has joined but not assigned with a
course. Now, We cannot record the new prof details in our
database due to non assignment of the course to him.
• Deletion Anomaly: It is the anomaly in which the deletion of
attributes about an entity, automatically deletes the attributes
of another entity.
– Ex: If we want to delete the information about course 293,
automatically the information of prof Sachin will be
deleted which is not our interest
16 March 2021 7
contd..
• Updation Anomaly:
– It is the anomaly in which the modification in the value of
specific attribute requires modification in all records in
which that value occurs.
– In other words, the same data can be expressed in multiple
rows. Therefore, updates to the table may result in logical
inconsistencies.
– Ex: If the updation to the phone_no of Mahesh is done in a
single row only, then the updation process will put the
database in an inconsistent state so that the phone_no of
Mahesh will give conflicting answers
16 March 2021 8
Functional Dependency (FD)
• Functional Dependency is the building block of normalization
principles.
• Attribute(s) A in a relation schema R functionally determines
another attribute(s) B in R, if for a given value a1 of A; there is
a single, specific value b1 of B i.e. if t1 and t2 are two tuples in
the relation R where t1(A) = t2(A), then we must have t1(B) =
t2(B).
• The symbolic expression of this FD is:
– A→B;
– where A (LHS of FD) is known as the determinant and
B (RHS of FD) is known as the dependent
• The functional dependency is a relationship that exists
between two attributes. It typically exists between the primary
key and non-key attribute within a table.
16 March 2021 9
contd..
• From Student schema, we can infer that Name→Phone_no
because all tuples of Student with a given Name value also
have the same Phone_no value.
• Likewise, it can also be inferred that Prof→Grade. At the
same time, notice that Grade does not determine Prof i.e.
Grade → Prof does not hold true.
• When the determinant or dependent in an FD is a composite
attribute, the constituent atomic attributes are enclosed by
braces as shown in the following example:
– {Name, Course}→Phone_no
16 March 2021 10
contd..
• FD is a constraint between two sets of attributes in a relation
from a database.
• Steps for Checking FD: ( A → B)
1. You must check the value of A , if all the values of A are
unique then FD holds good.
2. If all values of B are same then also FD holds good.
3. If two same values of A , we get two different values of B ,
then FD doesnot holds good.
16 March 2021 11
Example-1
Testing of Functional Dependency: (FD Holds Good or
NOT)
1. A -> BC (holds Good)
2. DE ->C (holds good)
3. C -> DE (not holds good)
4.BC -> A (holds good)
Q. which of the above option is correct (FD holds good.)
16 March 2021 12
A B C D E
a 2 3 4 5
2 a 3 4 5
a 2 3 6 5
a 2 3 6 6
Example-2
Testing of Functional Dependency: (FD Holds Good or
NOT)
1. XY -> Z && Z->Y
2. YZ ->X && Y->Z (Good)
3. YZ ->X && X-> Z
4.XZ -> Y && Y ->Z
Q. which of the above option is correct (FD holds good.)
16 March 2021 13
X Y Z
1 4 2
1 5 3
1 6 3
3 2 2
Example-3
Testing of Functional Dependency: (FD Holds Good or
NOT)
1. A -> B && BC -> A
2. C -> B && CA->B
3. B ->C && AB-> C (Good)
4.A -> C && BC ->A
Q. which of the above option is correct (FD holds good.)
16 March 2021 14
A B C
1 2 4
3 5 4
3 7 2
Trivial vs Non-Trivial FD
• Trivial FDs:
– A functional dependency X→Y is a trivial functional dependency, if
Y is a subset or equal of X.
– For example, {Name, Course}→Course. If two records have the
same values on both the Name and Course attributes, then they
obviously have the same Course. Again, A→A is a trivial FD as
here the dependent is equal to determinant.
– Trivial dependencies hold for all relation instances
• Non-Trivial FDs:
– A functional dependency X→Y is called as non-trivial type if
Y∩X =Φ
– For example, Prof→Grade as Grade is not a subset of Prof.
– Non-trivial FDs are given implicitly in the form of constraints when
designing a database.
16 March 2021 15
Multivalued Dependency
 Multivalued dependency occurs when there are more than one independent
multivalued attributes in a table.
 Example: Consider a bike manufacture company, which produces two
colors (Black and white) in each model every year.
bike_model mfg_year color
M1001 2007 Black
M1001 2007 Red
M2012 2008 Black
M2012 2008 Red
M2222 2009 Black
M2222 2009 Red
• Here columns mfg_year and color are independent of each other and
dependent on bike_model.
• In this case these two columns are said to be multivalued dependent on
bike_model. These dependencies can be represented like this:
bike_model ->> mfg_year; bike_model ->> color
16 March 2021 16
Transitive Dependency
 A functional dependency is said to be transitive if it is
indirectly formed by two functional dependencies.
 For e.g. X → Z is a transitive dependency if the following three
functional dependencies hold true:
 X→Y
 Y does not →X
 Y→Z
Note: A transitive dependency can only occur in a relation of
three of more attributes. This dependency helps us normalizing
the database in 3NF (3rd Normal Form).
16 March 2021 17
Armstrong’s InferenceAxioms
 It was proposed by William Armstrong.
 The inference axioms or rules allow users to infer the FDs that
are satisfied by a relation.
 Let R(X, Y, Z, W); where X, Y, Z, and W are arbitrary subsets
of the set of attributes of a universal relation schema R.
 The three fundamental inference rules are:
 Reflexivity Rule:
 If Y is a subset of X, then X→Y (Trivial FDs).
 Ex:{Name, Course}→Course
16 March 2021 18
contd..
 Augmentation Rule:
 If X→Y, then {X, Z}→{Y, Z}.
 Ex: Prof→Grade, therefore {Prof, Major}→{Grade,
Major}
 Adding an attribute to the both sides of a FD does not
change the basic dependency.
 Transitivity Rule:
 If X→Y and Y→Z, then X→Z.
 Ex: Course→Name and Name→Phone_no functional
dependencies are present, therefore
Course→Phone_no
16 March 2021 19
Contd..
 The four secondary inference rules are:
 Union or Additive Rule:
 If X→Y and X→Z, then X→{Y, Z}.
 Ex: Prof→Grade and Prof→Course FDs are
present; therefore, Prof→{Grade, Course}
 Decomposition Rule:
 If X→{Y, Z}, then X→Y and X→Z.
 Ex: if Prof→{Grade, Course}, then this FD can
be decomposed as Prof→Grade and
Prof→Course
16 March 2021 20
contd..
 Composition Rule:
 If X→Y and Z→W, then {X, Z}→{Y,W}.
 Ex: if Prof→Grade and Name→Phone_no, then
the FDs can be composed as {Prof,
Name}→{Grade, Phone_no}
 Pseudotransitivity Rule:
 If X→Y and {Y, W}→Z, then {X,W}→Z.
 Ex: if Prof→Grade and {Grade, Major}→Course,
then the FD {Prof, Major}→Course is valid
16 March 2021 21
An Example
 Example: Consider relation E = (P, Q, R, S, T, U) having set
of Functional Dependencies (FD).
P → Q P → R
QR → S Q → T
QR → U PR → U
So, some members of Axioms are as follows,
1. P → T (Transitivity Rule)
2. PR → S (Pseudo Transitivity Rule)
3. QR → SU (Union Rule)
4. PR → SU (Pseudo transitivity and Union Rule)
16 March 2021 22
Logical Implication
 Given a relation schema R and a set of functional
dependencies F.
 Let FD X→Y is not in F.
 F can be said to logically imply X→Y; if for every relation r
on the relation schema R that satisfies the FD in F, the relation
r also satisfies X→Y
 F logically implies X→Y is written as: F|=X→Y
 Let R = (A, B, C, D) and F = {A→B,
A→C, BC→D} F|=A→D; Given F =
{A→B, C→D} with C⊆B, show that
F|=A→D
16 March 2021 23
Closure of Attribute Set
 Attribute Closure of an attribute set 'A' can be defined as a set
of attributes which can be functionally defined from it.
 Denoted by A+.
Closure set means directly or indirectly which attribute we
found.
Ex-1: R(A,B,C) and the dependencies are A→ B and
B→C. Find (A)+ ?
Ans :
(A)+ = A
= AB (A-> B)
= ABC ( A -> C; Using Transitivity)
16 March 2021 24
contd..
• Ex-2: R(ABCDEF) and the dependencies are{ A- > B , C->
DE, AC ->F, D ->AF, E ->CF}. Find (D)+ and (DE)+.
• Ans :
(D)+ = D (Using Trivial property)
= ADF (Using D->AF)
= ABDF (Using A->B)
(DE) + = DE (Using Trivial property)
= ADEF (Using D-> AF)
= ACDEF (Using E-> CF)
= ABCDEF (Using A->B)
16 March 2021 25
Exercise
• Consider the relation R(A,B,C,D,E,F) and set of FDs
S={AB->C, BC->AD, D->E, CF->B}. Find (AB)+.
– Ans: (A,B,C,D,E)
• Consider the relation R(A,B,C,D,E,F,G) and set of FDs
S={A->B, BC->DE, AEG->G}. Find (AC)+.
– Ans: (A,C,B,D,E)
• Consider the relation R(A,B,C,D,E) and set of FDs
S={A->BC, CD->E, B->D, E->A}. Find (B)+.
– Ans: (B,D)
• Consider the relation R(A,B,C,D,E,F,G,H) and set of FDs
S={A->BC, CD->E, E->C, D->AEH, ABH->BD, DH->BC,
AEG->G}. Is BCD->H a valid FD?
– Ans: Yes, BCD->H is a valid FD.
16 March 2021 26
Closure of set of Attributes
 Given a set of attributes X and a set of functional dependencies
F, then the closure of the set of attributes X under F, denoted
as X +, is the set of attributes A that can be derived from X by
applying the Armstrong’s Inference Axioms to the functional
dependencies of F.
 The closure of X is always a non empty set.
 Consider the relation R = (A, B, C, D) and the
dependencies F = {A→C, B→D}, then the closure of set of
attributes is
{A}+ = {A, C},
{B}+ = {B, D},
{C}+={C},
{D}+={D},
16 March 2021 27
contd..
{A, B}+ = {A, B, C, D},
{A, C}+ = {A, C},
{A, D}+ = {A, C, D},
{B, C}+ = {B, C, D},
{B, D}+ = {B, D},
{C, D}+ = {C, D},
{A, B, C}+ = {A, B, C, D},
{A, B, D}+ = {A, B, C, D},
{A,C, D}+ = {A, C, D}
{B, C, D}+ = {B, C, D},
{A, B, C, D}+ = {A, B, C, D}
16 March 2021 28
contd..
 Uses of Attribute Closure:
 Testing for key :
 To test whether X is a key or not, X + is computed.
 X is a key or super key iff X + contains all the
attributes of R.
 X is a candidate key if none of its subsets is a key.
 Testing functional dependencies: To check whether a
functional dependency X→Y holds or not, just check if
Y⊆ X +
• Given R=(A, B, C, D) and F={AB→C, B→D, D→B}, find
the candidate keys of the relation. How many candidate
keys are in this relation? (Ans: 2 C.K; AB and AD)
16 March 2021 29
Closure of a Set of Functional Dependencies
 Given a set F of FDs for a relation schema R, we define F+,
the closure of F, to be the set of F as well as all FDs that are
logically implied by F.
 To generate all FDs that can be derived from F, the steps are:
 First, apply the inference axioms to all single attributes
and use the FDs of F whenever it is applicable.
 Second, apply the inference axioms to all combinations of
two attributes and use the functional dependencies of F
whenever it is applicable.
 Next apply the inference axioms to all combinations of
three attributes and use the FDs of F when necessary.
 Proceed in this manner for as many different attributes as
there are in F.
16 March 2021 30
An Example
 Let R=(A, B, C) and F={A→B, B→C}. Find the closure of
F. Also, find the SK and CK.
Ans:
S-1: When all the three attributes are excluded then we will
have only Φ->Φ i.e. 1 FD.
S-2: When only Ais included then, (A)+ =(A,B,C) i.e. 2^3=8 FDs
can exist which is as below:
A->A; A->B; A->C
A->AB; A->BC; A->AC
A->ABC; A->Φ
A is a super key as it determines all attributes of R.
S-3: When only B is included then, (B)+ = (B,C) i.e. 2^2=4
FDs can exist which is as below:
B->B; B->BC
B->C; B-> Φ
16 March 2021 31
contd..
S-4: When only C is included then, (C)+ = (C) i.e. 2^1=2 FDs
can exist which is as below:
C->C; C-> Φ
S-5: When only (AB) is included then, (AB)+ = (ABC) i.e. 2^3=8
FDs can exist which is as below:
AB->A; AB->B; AB->C
AB->AB; AB->BC; AB->AC
AB->ABC; AB->Φ
AB is a super key as it determines all attributes of R.
S-6: When only (BC) is included then, (BC)+ = (BC) i.e. 2^2=4
FDs can exist which is as below:
BC->B; BC->C
BC->BC; BC->Φ
16 March 2021 32
S-7: When only (AC) is included then, (AC)+ = (ABC) i.e.
2^3=8 number of FDs can exist qhich is as below:
AC->A; AC->B; AC->C
AC->AB; AC->BC; AC->AC
AC->ABC; AC->Φ
AC is a super key as it determines all attributes of R.
S-8: When only (ABC) is included then, (ABC)+ = (ABC) i.e.
2^3=8 number of FDs can exist qhich is as below:
ABC->A; ABC->B; ABC->C
ABC->AB; ABC->BC; ABC->AC
ABC->ABC; ABC->Φ
ABC is a super key as it determines all attributes of R.
S-9: F+ ={43 number of FDs}
SK= {A, AB, AC, ABC}; CK={A}
16 March 2021 33
Equivalence of Functional Dependency
• For a given relation R, if F and G are two sets of FDs then
When F +=G+, then the FD sets F and G are equivalent.
• This can also be derived from the closure set of attributes.
• Ex: Consider the relation R(A,C,D,E,H) and the set of FDs
are F={A->C, AC->D, E->AD, E->H} and G={A->CD,
E->AH}. Determine if F and G are equivalent.
Ans:
S-1: Find the closure of LHS of F using FDs of G
(A)+ = (ACD); (AC)+ = (ACD); (E)+ = (EAHCD)
Hence, F⊆G
S-2: Find the closure of LHS of G using FDs of F
(A)+ = (ACD); (E)+ = (EADHC); Hence, G⊆F
Hence, the set of FDs F and G are equivalent.
16 March 2021 34
Redundant Functional Dependencies
 A FD in the set F is redundant if it can be derived from the
other FDs in the set. A redundant FD can be detected using the
following steps:
• Step 1: Start with a set of S of FDs
• Step 2: Remove an FD f and create a set of FDs S' = S - f .
• Step 3: Test whether f can be derived from the FDs in S'; by
using the set of Armstrong's axioms and derived rules.
• Step 4: If f can be so derived, it is redundant , and hence S'
= S. Otherwise replace f into S'; so that now S' = S + f.
• Step 5: Repeat steps 2 to 4 for all FDs in S.
16 March 2021 35
An Example
 For example, suppose the following set of FDs is given in the
algorithm:
Z -> A; B -> X; AX -> Y; ZB -> Y
 Now, the dependency ZB -> Y can be derived from other FDs
in the set, it can be shown to be redundant.
 The following argument can be given:
 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.
16 March 2021 36
Canonical Cover/ Minimal Cover
 Canonical Cover / Minimal Cover: For a given set F of FDs,
a canonical cover, denoted by Fc , is a set of FDs where the
following conditions are satisfied:
 F and Fc are equivalent
 Every FD of Fc is simple i.e. the RHS of every FD of Fc
has only one attribute
 No FD in Fc is redundant
 The determinant or LHS of every FD in Fc is irreducible
 Since it is a reduced version, it is also called as Irreducible set.
 As canonical cover contains the FDs without any redundancy,
therefore finding the key of the relation becomes efficient.
16 March 2021 37
contd..
 Sometimes FD Sets are not able to reduce if the set has
following properties,
1. The RHS set of FD holds only one attribute.
2. The LHS set of FD cannot be reduced, it changes the
entire content of the set.
3. Reducing any FD may change the content of the set.
 A set of FDs with the above three properties are also called as
Canonical or Minimal.
16 March 2021 38
How to find Canonical Cover?
• Step-01:
– Write the given set of FDs in such a way that each FD
contains exactly one attribute on its right side.
• Step-02:
– Consider each FD one by one from the set obtained in Step-
01. Determine whether it is essential or non-essential.
– To determine whether a FD is essential or not, compute the
closure of its left side:
• Once by considering that the particular FD is present in
the set.
• Once by considering that the particular FD is not
present in the set.
16 March 2021 39
• Step-2 (contd..)
– Case-1:
• If results come out to be same,It means that the presence
or absence of that FD does not create any difference.
• Thus, it is non-essential. Eliminate that FD from the set.
• Do not consider it while checking the essentiality of
other FDs.
– Case-2:
• If results come out to be different, It means that the
presence or absence of that FD creates a difference.
• Thus, it is essential. Do not eliminate that FD from the
set.
• Mark that FD as essential.
•
16 March 2021 40
contd..
Step-03:
– Consider the newly obtained set of FDs after performing
Step-02 and check if there is any FD that contains more
than one attribute on its left side.
– Then following two cases are possible-
• Case-01: No
– There exists no FD containing more than one
attribute on its left side.
– In this case, the set obtained in Step-02 is the
canonical cover.
16 March 2021 41
• Case-02: Yes
– There exists at least one FD containing more than
one attribute on its left side.
– In this case, consider all such FD one by one.
– Check if their left side can be reduced.
– Use the following steps to perform a check-
» Consider a FD and compute the closure of all the
possible subsets of the left side of that FDs.
» If any of the subsets produce the same closure
result as produced by the entire left side, then
replace the left side with that subset.
» After this step is complete, the set obtained is the
canonical cover.
16 March 2021 42
An Example
 Consider a relation R(WXYZ) and a set of FDs X-> W,
WZ ->XY, Y->WXZ. Find the canonical Cover or Minimal
cover.
Ans:
Step-1: The right side should contain single attribute.
X->W; WZ->X; WZ->Y; Y->W; Y->X; Y->Z
Step-2 : Find out Closure
X->W
X+ = XW (When X->W is considered)
X + = X (When X->W is not considered)
Clearly, the two results are different. Thus, we conclude
that X → W is essential and can not be eliminated.
16 March 2021 43
contd..
Step-2 (contd..)
• For WZ → X:
Considering WZ → X, (WZ)+ = { W , X , Y , Z }
Ignoring WZ → X, (WZ)+ = { W , X , Y , Z }
• Now, Clearly, the two results are same. Thus, we
conclude that WZ → X is non-essential and can be
eliminated.
• Eliminating WZ → X, our set of functional dependencies
reduces to-
X → W; WZ → Y; Y → W; Y → X; Y → Z
Now, we will consider this reduced set in further checks.
16 March 2021 44
Step-2 (contd..)
• For WZ → Y:
Considering WZ → Y, (WZ)+ = { W , X , Y , Z }
Ignoring WZ → Y, (WZ)+ = { W , Z }
Now, Clearly, the two results are different. Thus,
we conclude that WZ → Y is essential and can not
be eliminated.
• For Y → W:
Considering Y → W, (Y)+ = { W , X , Y , Z }
Ignoring Y → W, (Y)+ = { W , X , Y , Z }
Now, Clearly the two results are same. Thus, the
FD Y->W is not essential and hence can be
eliminated. Eliminating Y → W, our set of
functional dependencies reduces to-
X → W; WZ → Y; Y → X; Y → Z
16 March 2021 45
contd..
Step-2 (contd..)
• For Y → X:
Considering Y → X, (Y)+ = { W , X , Y , Z }
Ignoring Y → X, (Y)+ = { Y , Z }
Now, Clearly, the two results are different. Thus, we
conclude that Y → X is essential and can not be
eliminated.
• For Y → Z:
Considering Y → Z, (Y)+ = { W , X , Y , Z }
Ignoring Y → Z, (Y)+ = { W , X , Y }
Now, Clearly, the two results are different. Thus, we
conclude that Y → Z is essential and can not be
eliminated.
16 March 2021 46
contd..
Step-03: Consider the FD having more than one attribute on their
left side. Check if their left side can be reduced.
• In our set,
– Only WZ → Y contains more than one attribute on its left
side.
– Considering WZ → Y, (WZ)+ = { W , X , Y , Z }
– Now, Consider all the possible subsets of WZ and check if
the closure result of any subset matches to the closure
result of WZ.
• (W)+ = { W }
• (Z)+ = { Z }
16 March 2021 47
contd..
Step-4:
– Clearly, None of the subsets have the same closure result
same as that of the entire left side.
– Thus, we conclude that we can not write WZ → Y as W →
Y or Z → Y.
– Thus, set of FDs obtained in step-02 is the canonical cover.
• Finally, the canonical cover is-
X → W; WZ → Y; Y → X; Y → Z
16 March 2021 48
Ad

Recommended

ER-Model-ER Diagram
ER-Model-ER Diagram
Saranya Natarajan
 
Chapter-6 Relational Algebra
Chapter-6 Relational Algebra
Kunal Anand
 
Object Based Databases
Object Based Databases
Farzad Nozarian
 
Relational data model
Relational data model
Dr. SURBHI SAROHA
 
Object Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UML
Malek Sumaiya
 
Normalization in RDBMS
Normalization in RDBMS
JananiSelvaraj10
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
Kunal Anand
 
deadlock handling
deadlock handling
Suraj Kumar
 
DBMS Unit - 6 - Transaction Management
DBMS Unit - 6 - Transaction Management
Gyanmanjari Institute Of Technology
 
Lecture 11 - distributed database
Lecture 11 - distributed database
HoneySah
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
Transaction states and properties
Transaction states and properties
Chetan Mahawar
 
Domain model Refinement
Domain model Refinement
Anjan Kumar
 
DBMS PPT
DBMS PPT
Prabhu Goyal
 
Serializability
Serializability
Pyingkodi Maran
 
DBMS Canonical cover
DBMS Canonical cover
Saurabh Tandel
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
Kunal Anand
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
Kunal Anand
 
Normalization
Normalization
Salman Memon
 
Computer Organization
Computer Organization
Selvaraj Seerangan
 
Lock based protocols
Lock based protocols
ChethanMp7
 
Joins in dbms and types
Joins in dbms and types
university of Gujrat, pakistan
 
3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
Functional dependency and normalization
Functional dependency and normalization
University of Potsdam
 
Normalization
Normalization
ochesing
 
Distributed Database Management System
Distributed Database Management System
AAKANKSHA JAIN
 
Data abstraction in DBMS
Data abstraction in DBMS
Papan Sarkar
 
Decomposition using Functional Dependency
Decomposition using Functional Dependency
Raj Naik
 
Normalization
Normalization
Dabbal Singh Mahara
 
DBMS 3.pdf
DBMS 3.pdf
NithishReddy90
 

More Related Content

What's hot (20)

DBMS Unit - 6 - Transaction Management
DBMS Unit - 6 - Transaction Management
Gyanmanjari Institute Of Technology
 
Lecture 11 - distributed database
Lecture 11 - distributed database
HoneySah
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
Transaction states and properties
Transaction states and properties
Chetan Mahawar
 
Domain model Refinement
Domain model Refinement
Anjan Kumar
 
DBMS PPT
DBMS PPT
Prabhu Goyal
 
Serializability
Serializability
Pyingkodi Maran
 
DBMS Canonical cover
DBMS Canonical cover
Saurabh Tandel
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
Kunal Anand
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
Kunal Anand
 
Normalization
Normalization
Salman Memon
 
Computer Organization
Computer Organization
Selvaraj Seerangan
 
Lock based protocols
Lock based protocols
ChethanMp7
 
Joins in dbms and types
Joins in dbms and types
university of Gujrat, pakistan
 
3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
Functional dependency and normalization
Functional dependency and normalization
University of Potsdam
 
Normalization
Normalization
ochesing
 
Distributed Database Management System
Distributed Database Management System
AAKANKSHA JAIN
 
Data abstraction in DBMS
Data abstraction in DBMS
Papan Sarkar
 
Decomposition using Functional Dependency
Decomposition using Functional Dependency
Raj Naik
 
Lecture 11 - distributed database
Lecture 11 - distributed database
HoneySah
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
Transaction states and properties
Transaction states and properties
Chetan Mahawar
 
Domain model Refinement
Domain model Refinement
Anjan Kumar
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
Kunal Anand
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
Kunal Anand
 
Lock based protocols
Lock based protocols
ChethanMp7
 
3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
Functional dependency and normalization
Functional dependency and normalization
University of Potsdam
 
Normalization
Normalization
ochesing
 
Distributed Database Management System
Distributed Database Management System
AAKANKSHA JAIN
 
Data abstraction in DBMS
Data abstraction in DBMS
Papan Sarkar
 
Decomposition using Functional Dependency
Decomposition using Functional Dependency
Raj Naik
 

Similar to Chapter-8 Relational Database Design (20)

Normalization
Normalization
Dabbal Singh Mahara
 
DBMS 3.pdf
DBMS 3.pdf
NithishReddy90
 
09.01 normalization
09.01 normalization
Bishal Ghimire
 
DBMS e evevevevevevevbebrbbrbrbrbrbrbrb 4.ppt
DBMS e evevevevevevevbebrbbrbrbrbrbrbrb 4.ppt
7c7fs5n555
 
chapter 4-Functional Dependency and Normilization.pdf
chapter 4-Functional Dependency and Normilization.pdf
University of Gondar
 
DBMS unit-3.pdf
DBMS unit-3.pdf
Prof. Dr. K. Adisesha
 
Normalization
Normalization
Mohd Mastana
 
Normalization
Normalization
baabtra.com - No. 1 supplier of quality freshers
 
normalization ppt.pptx
normalization ppt.pptx
AbdusSadik
 
Normalization-1NF,2NF,Functional dependencies.pptx
Normalization-1NF,2NF,Functional dependencies.pptx
prachi gat
 
UNIT II DBMS.pptx
UNIT II DBMS.pptx
NIVETHA37590
 
Relational Database design.pptx
Relational Database design.pptx
johndoe193402
 
Lecture no 7 Database. For Bs IT Semester Fall Spring
Lecture no 7 Database. For Bs IT Semester Fall Spring
lm0261806
 
MODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.ppt
MODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.ppt
HemaSenthil5
 
Chapter – 4 Normalization and Relational Algebra.pdf
Chapter – 4 Normalization and Relational Algebra.pdf
TamiratDejene1
 
Relational database
Relational database
amkrisha
 
MODULE 4 -Normalization_1.ppt
MODULE 4 -Normalization_1.ppt
BelkinAntony1
 
MODULE 3 -Normalization_1.ppt moduled in design
MODULE 3 -Normalization_1.ppt moduled in design
HemaSenthil5
 
Database Design and Normalization Techniques
Database Design and Normalization Techniques
Nishant Munjal
 
DBMS_Module 3_Functional Dependencies and Normalization.pptx
DBMS_Module 3_Functional Dependencies and Normalization.pptx
shruthis866876
 
DBMS e evevevevevevevbebrbbrbrbrbrbrbrb 4.ppt
DBMS e evevevevevevevbebrbbrbrbrbrbrbrb 4.ppt
7c7fs5n555
 
chapter 4-Functional Dependency and Normilization.pdf
chapter 4-Functional Dependency and Normilization.pdf
University of Gondar
 
normalization ppt.pptx
normalization ppt.pptx
AbdusSadik
 
Normalization-1NF,2NF,Functional dependencies.pptx
Normalization-1NF,2NF,Functional dependencies.pptx
prachi gat
 
Relational Database design.pptx
Relational Database design.pptx
johndoe193402
 
Lecture no 7 Database. For Bs IT Semester Fall Spring
Lecture no 7 Database. For Bs IT Semester Fall Spring
lm0261806
 
MODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.ppt
MODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.ppt
HemaSenthil5
 
Chapter – 4 Normalization and Relational Algebra.pdf
Chapter – 4 Normalization and Relational Algebra.pdf
TamiratDejene1
 
Relational database
Relational database
amkrisha
 
MODULE 4 -Normalization_1.ppt
MODULE 4 -Normalization_1.ppt
BelkinAntony1
 
MODULE 3 -Normalization_1.ppt moduled in design
MODULE 3 -Normalization_1.ppt moduled in design
HemaSenthil5
 
Database Design and Normalization Techniques
Database Design and Normalization Techniques
Nishant Munjal
 
DBMS_Module 3_Functional Dependencies and Normalization.pptx
DBMS_Module 3_Functional Dependencies and Normalization.pptx
shruthis866876
 
Ad

Recently uploaded (20)

Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
 
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
Cadastral Maps
Cadastral Maps
Google
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
(Continuous Integration and Continuous Deployment/Delivery) is a fundamental ...
(Continuous Integration and Continuous Deployment/Delivery) is a fundamental ...
ketan09101
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
François Garillot
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
Stay Safe Women Security Android App Project Report.pdf
Stay Safe Women Security Android App Project Report.pdf
Kamal Acharya
 
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
 
How to Un-Obsolete Your Legacy Keypad Design
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
 
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
Cadastral Maps
Cadastral Maps
Google
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
(Continuous Integration and Continuous Deployment/Delivery) is a fundamental ...
(Continuous Integration and Continuous Deployment/Delivery) is a fundamental ...
ketan09101
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
François Garillot
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
Stay Safe Women Security Android App Project Report.pdf
Stay Safe Women Security Android App Project Report.pdf
Kamal Acharya
 
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
Ad

Chapter-8 Relational Database Design

  • 1. Learning Resource On Database Management Systems Chapter-8 Relational Database Design Prepared By: Kunal Anand, Asst. Professor SCE, KIIT, DU, Bhubaneswar-24
  • 2. Chapter Outcome: • After the completion of this chapter, the students will be able to: – Identify the problems associated with bad database design – Explain Functional Dependency – List different types of dependencies – Explain Armstrong Inference Axioms – Determine closure of attribute / attribute set – Determine closure of FDs – Determine equivalence of FDs – Identify redundant FDs – Determine Canonical or Minimal Cover 16 March 2021 2
  • 3. Organization of this Chapter: • Introduction to Database Design • Problems encountered with bad design • Functional Dependency Theory • Armstrong Inference Axioms • Closure of Attributes/Attribute Set • Closure of a Set of Functional Dependency • Equivalence of FDs • Redundancy of FDs • Canonical Cover 16 March 2021 3
  • 4. Introduction to Database Design • The goal of relational database design is to generate a set of relational schemas that allow us to store information without unnecessary redundancy, yet it allows us to retrieve information easily. • First, fully characterize the data requirements of the prospective database users, which usually involves in textual descriptions. • Next, choose ER model to translate these requirements into a conceptual schema of the database. • In the logical design phase, map the high level conceptual schema onto the implementation data model of the database system that will be used. The implementation data model is typically the Relational data model. 16 March 2021 4
  • 5. contd.. • Finally, use the resulting system specific database schema in the subsequent physical design phase, in which the physical features of the database are specified. • Database design may be performed using following two approaches: – Bottom-up approach: It is also known as design by synthesis. It considers the basic relationship among individual attributes to construct the schemas. It suffers from a problem of finding large number of binary relationship among the attributes as the starting point, that is extremely difficult to achieve. – Top-down approach: It is also known as design by analysis. It starts with a number of grouping of attributes into relations that exists naturally e.g. Invoice, or a form, or a report. The relations are then analyzed individually and collectively, leading to further decomposition and until all desirable properties are met. 16 March 2021 5
  • 6. Bad Database Design/Concepts of Anomalies • Problems that can occur in poorly planned, un-normalized databases where all the data is stored in one table. • These anomalies affect the process of inserting, deleting and updating data in the relations. The intension of relational database theory is to eliminate anomalies from occurring in a database. Consider the student database. 16 March 2021 6 Name Course Phone_no Major Prof Grade Mahesh 353 1234 Comp sc Alok A Nitish 329 2435 Chemistry Pratap B Mahesh 328 1234 Comp sc Samuel B Harish 456 4665 Physics James A Pranshu 293 4437 Decision sc Sachin C Prateek 491 8788 Math Saurav B Prateek 356 8788 Math Sunil In prog Mahesh 492 1234 Comp sc Paresh In prog Sumit 379 4575 English Rakesh C
  • 7. contd.. • Insertion Anomaly: It is the anomaly in which the user cannot insert an attribute about an entity until he/she has an additional attribute about another entity. – Ex: Suppose a new prof has joined but not assigned with a course. Now, We cannot record the new prof details in our database due to non assignment of the course to him. • Deletion Anomaly: It is the anomaly in which the deletion of attributes about an entity, automatically deletes the attributes of another entity. – Ex: If we want to delete the information about course 293, automatically the information of prof Sachin will be deleted which is not our interest 16 March 2021 7
  • 8. contd.. • Updation Anomaly: – It is the anomaly in which the modification in the value of specific attribute requires modification in all records in which that value occurs. – In other words, the same data can be expressed in multiple rows. Therefore, updates to the table may result in logical inconsistencies. – Ex: If the updation to the phone_no of Mahesh is done in a single row only, then the updation process will put the database in an inconsistent state so that the phone_no of Mahesh will give conflicting answers 16 March 2021 8
  • 9. Functional Dependency (FD) • Functional Dependency is the building block of normalization principles. • Attribute(s) A in a relation schema R functionally determines another attribute(s) B in R, if for a given value a1 of A; there is a single, specific value b1 of B i.e. if t1 and t2 are two tuples in the relation R where t1(A) = t2(A), then we must have t1(B) = t2(B). • The symbolic expression of this FD is: – A→B; – where A (LHS of FD) is known as the determinant and B (RHS of FD) is known as the dependent • The functional dependency is a relationship that exists between two attributes. It typically exists between the primary key and non-key attribute within a table. 16 March 2021 9
  • 10. contd.. • From Student schema, we can infer that Name→Phone_no because all tuples of Student with a given Name value also have the same Phone_no value. • Likewise, it can also be inferred that Prof→Grade. At the same time, notice that Grade does not determine Prof i.e. Grade → Prof does not hold true. • When the determinant or dependent in an FD is a composite attribute, the constituent atomic attributes are enclosed by braces as shown in the following example: – {Name, Course}→Phone_no 16 March 2021 10
  • 11. contd.. • FD is a constraint between two sets of attributes in a relation from a database. • Steps for Checking FD: ( A → B) 1. You must check the value of A , if all the values of A are unique then FD holds good. 2. If all values of B are same then also FD holds good. 3. If two same values of A , we get two different values of B , then FD doesnot holds good. 16 March 2021 11
  • 12. Example-1 Testing of Functional Dependency: (FD Holds Good or NOT) 1. A -> BC (holds Good) 2. DE ->C (holds good) 3. C -> DE (not holds good) 4.BC -> A (holds good) Q. which of the above option is correct (FD holds good.) 16 March 2021 12 A B C D E a 2 3 4 5 2 a 3 4 5 a 2 3 6 5 a 2 3 6 6
  • 13. Example-2 Testing of Functional Dependency: (FD Holds Good or NOT) 1. XY -> Z && Z->Y 2. YZ ->X && Y->Z (Good) 3. YZ ->X && X-> Z 4.XZ -> Y && Y ->Z Q. which of the above option is correct (FD holds good.) 16 March 2021 13 X Y Z 1 4 2 1 5 3 1 6 3 3 2 2
  • 14. Example-3 Testing of Functional Dependency: (FD Holds Good or NOT) 1. A -> B && BC -> A 2. C -> B && CA->B 3. B ->C && AB-> C (Good) 4.A -> C && BC ->A Q. which of the above option is correct (FD holds good.) 16 March 2021 14 A B C 1 2 4 3 5 4 3 7 2
  • 15. Trivial vs Non-Trivial FD • Trivial FDs: – A functional dependency X→Y is a trivial functional dependency, if Y is a subset or equal of X. – For example, {Name, Course}→Course. If two records have the same values on both the Name and Course attributes, then they obviously have the same Course. Again, A→A is a trivial FD as here the dependent is equal to determinant. – Trivial dependencies hold for all relation instances • Non-Trivial FDs: – A functional dependency X→Y is called as non-trivial type if Y∩X =Φ – For example, Prof→Grade as Grade is not a subset of Prof. – Non-trivial FDs are given implicitly in the form of constraints when designing a database. 16 March 2021 15
  • 16. Multivalued Dependency  Multivalued dependency occurs when there are more than one independent multivalued attributes in a table.  Example: Consider a bike manufacture company, which produces two colors (Black and white) in each model every year. bike_model mfg_year color M1001 2007 Black M1001 2007 Red M2012 2008 Black M2012 2008 Red M2222 2009 Black M2222 2009 Red • Here columns mfg_year and color are independent of each other and dependent on bike_model. • In this case these two columns are said to be multivalued dependent on bike_model. These dependencies can be represented like this: bike_model ->> mfg_year; bike_model ->> color 16 March 2021 16
  • 17. Transitive Dependency  A functional dependency is said to be transitive if it is indirectly formed by two functional dependencies.  For e.g. X → Z is a transitive dependency if the following three functional dependencies hold true:  X→Y  Y does not →X  Y→Z Note: A transitive dependency can only occur in a relation of three of more attributes. This dependency helps us normalizing the database in 3NF (3rd Normal Form). 16 March 2021 17
  • 18. Armstrong’s InferenceAxioms  It was proposed by William Armstrong.  The inference axioms or rules allow users to infer the FDs that are satisfied by a relation.  Let R(X, Y, Z, W); where X, Y, Z, and W are arbitrary subsets of the set of attributes of a universal relation schema R.  The three fundamental inference rules are:  Reflexivity Rule:  If Y is a subset of X, then X→Y (Trivial FDs).  Ex:{Name, Course}→Course 16 March 2021 18
  • 19. contd..  Augmentation Rule:  If X→Y, then {X, Z}→{Y, Z}.  Ex: Prof→Grade, therefore {Prof, Major}→{Grade, Major}  Adding an attribute to the both sides of a FD does not change the basic dependency.  Transitivity Rule:  If X→Y and Y→Z, then X→Z.  Ex: Course→Name and Name→Phone_no functional dependencies are present, therefore Course→Phone_no 16 March 2021 19
  • 20. Contd..  The four secondary inference rules are:  Union or Additive Rule:  If X→Y and X→Z, then X→{Y, Z}.  Ex: Prof→Grade and Prof→Course FDs are present; therefore, Prof→{Grade, Course}  Decomposition Rule:  If X→{Y, Z}, then X→Y and X→Z.  Ex: if Prof→{Grade, Course}, then this FD can be decomposed as Prof→Grade and Prof→Course 16 March 2021 20
  • 21. contd..  Composition Rule:  If X→Y and Z→W, then {X, Z}→{Y,W}.  Ex: if Prof→Grade and Name→Phone_no, then the FDs can be composed as {Prof, Name}→{Grade, Phone_no}  Pseudotransitivity Rule:  If X→Y and {Y, W}→Z, then {X,W}→Z.  Ex: if Prof→Grade and {Grade, Major}→Course, then the FD {Prof, Major}→Course is valid 16 March 2021 21
  • 22. An Example  Example: Consider relation E = (P, Q, R, S, T, U) having set of Functional Dependencies (FD). P → Q P → R QR → S Q → T QR → U PR → U So, some members of Axioms are as follows, 1. P → T (Transitivity Rule) 2. PR → S (Pseudo Transitivity Rule) 3. QR → SU (Union Rule) 4. PR → SU (Pseudo transitivity and Union Rule) 16 March 2021 22
  • 23. Logical Implication  Given a relation schema R and a set of functional dependencies F.  Let FD X→Y is not in F.  F can be said to logically imply X→Y; if for every relation r on the relation schema R that satisfies the FD in F, the relation r also satisfies X→Y  F logically implies X→Y is written as: F|=X→Y  Let R = (A, B, C, D) and F = {A→B, A→C, BC→D} F|=A→D; Given F = {A→B, C→D} with C⊆B, show that F|=A→D 16 March 2021 23
  • 24. Closure of Attribute Set  Attribute Closure of an attribute set 'A' can be defined as a set of attributes which can be functionally defined from it.  Denoted by A+. Closure set means directly or indirectly which attribute we found. Ex-1: R(A,B,C) and the dependencies are A→ B and B→C. Find (A)+ ? Ans : (A)+ = A = AB (A-> B) = ABC ( A -> C; Using Transitivity) 16 March 2021 24
  • 25. contd.. • Ex-2: R(ABCDEF) and the dependencies are{ A- > B , C-> DE, AC ->F, D ->AF, E ->CF}. Find (D)+ and (DE)+. • Ans : (D)+ = D (Using Trivial property) = ADF (Using D->AF) = ABDF (Using A->B) (DE) + = DE (Using Trivial property) = ADEF (Using D-> AF) = ACDEF (Using E-> CF) = ABCDEF (Using A->B) 16 March 2021 25
  • 26. Exercise • Consider the relation R(A,B,C,D,E,F) and set of FDs S={AB->C, BC->AD, D->E, CF->B}. Find (AB)+. – Ans: (A,B,C,D,E) • Consider the relation R(A,B,C,D,E,F,G) and set of FDs S={A->B, BC->DE, AEG->G}. Find (AC)+. – Ans: (A,C,B,D,E) • Consider the relation R(A,B,C,D,E) and set of FDs S={A->BC, CD->E, B->D, E->A}. Find (B)+. – Ans: (B,D) • Consider the relation R(A,B,C,D,E,F,G,H) and set of FDs S={A->BC, CD->E, E->C, D->AEH, ABH->BD, DH->BC, AEG->G}. Is BCD->H a valid FD? – Ans: Yes, BCD->H is a valid FD. 16 March 2021 26
  • 27. Closure of set of Attributes  Given a set of attributes X and a set of functional dependencies F, then the closure of the set of attributes X under F, denoted as X +, is the set of attributes A that can be derived from X by applying the Armstrong’s Inference Axioms to the functional dependencies of F.  The closure of X is always a non empty set.  Consider the relation R = (A, B, C, D) and the dependencies F = {A→C, B→D}, then the closure of set of attributes is {A}+ = {A, C}, {B}+ = {B, D}, {C}+={C}, {D}+={D}, 16 March 2021 27
  • 28. contd.. {A, B}+ = {A, B, C, D}, {A, C}+ = {A, C}, {A, D}+ = {A, C, D}, {B, C}+ = {B, C, D}, {B, D}+ = {B, D}, {C, D}+ = {C, D}, {A, B, C}+ = {A, B, C, D}, {A, B, D}+ = {A, B, C, D}, {A,C, D}+ = {A, C, D} {B, C, D}+ = {B, C, D}, {A, B, C, D}+ = {A, B, C, D} 16 March 2021 28
  • 29. contd..  Uses of Attribute Closure:  Testing for key :  To test whether X is a key or not, X + is computed.  X is a key or super key iff X + contains all the attributes of R.  X is a candidate key if none of its subsets is a key.  Testing functional dependencies: To check whether a functional dependency X→Y holds or not, just check if Y⊆ X + • Given R=(A, B, C, D) and F={AB→C, B→D, D→B}, find the candidate keys of the relation. How many candidate keys are in this relation? (Ans: 2 C.K; AB and AD) 16 March 2021 29
  • 30. Closure of a Set of Functional Dependencies  Given a set F of FDs for a relation schema R, we define F+, the closure of F, to be the set of F as well as all FDs that are logically implied by F.  To generate all FDs that can be derived from F, the steps are:  First, apply the inference axioms to all single attributes and use the FDs of F whenever it is applicable.  Second, apply the inference axioms to all combinations of two attributes and use the functional dependencies of F whenever it is applicable.  Next apply the inference axioms to all combinations of three attributes and use the FDs of F when necessary.  Proceed in this manner for as many different attributes as there are in F. 16 March 2021 30
  • 31. An Example  Let R=(A, B, C) and F={A→B, B→C}. Find the closure of F. Also, find the SK and CK. Ans: S-1: When all the three attributes are excluded then we will have only Φ->Φ i.e. 1 FD. S-2: When only Ais included then, (A)+ =(A,B,C) i.e. 2^3=8 FDs can exist which is as below: A->A; A->B; A->C A->AB; A->BC; A->AC A->ABC; A->Φ A is a super key as it determines all attributes of R. S-3: When only B is included then, (B)+ = (B,C) i.e. 2^2=4 FDs can exist which is as below: B->B; B->BC B->C; B-> Φ 16 March 2021 31
  • 32. contd.. S-4: When only C is included then, (C)+ = (C) i.e. 2^1=2 FDs can exist which is as below: C->C; C-> Φ S-5: When only (AB) is included then, (AB)+ = (ABC) i.e. 2^3=8 FDs can exist which is as below: AB->A; AB->B; AB->C AB->AB; AB->BC; AB->AC AB->ABC; AB->Φ AB is a super key as it determines all attributes of R. S-6: When only (BC) is included then, (BC)+ = (BC) i.e. 2^2=4 FDs can exist which is as below: BC->B; BC->C BC->BC; BC->Φ 16 March 2021 32
  • 33. S-7: When only (AC) is included then, (AC)+ = (ABC) i.e. 2^3=8 number of FDs can exist qhich is as below: AC->A; AC->B; AC->C AC->AB; AC->BC; AC->AC AC->ABC; AC->Φ AC is a super key as it determines all attributes of R. S-8: When only (ABC) is included then, (ABC)+ = (ABC) i.e. 2^3=8 number of FDs can exist qhich is as below: ABC->A; ABC->B; ABC->C ABC->AB; ABC->BC; ABC->AC ABC->ABC; ABC->Φ ABC is a super key as it determines all attributes of R. S-9: F+ ={43 number of FDs} SK= {A, AB, AC, ABC}; CK={A} 16 March 2021 33
  • 34. Equivalence of Functional Dependency • For a given relation R, if F and G are two sets of FDs then When F +=G+, then the FD sets F and G are equivalent. • This can also be derived from the closure set of attributes. • Ex: Consider the relation R(A,C,D,E,H) and the set of FDs are F={A->C, AC->D, E->AD, E->H} and G={A->CD, E->AH}. Determine if F and G are equivalent. Ans: S-1: Find the closure of LHS of F using FDs of G (A)+ = (ACD); (AC)+ = (ACD); (E)+ = (EAHCD) Hence, F⊆G S-2: Find the closure of LHS of G using FDs of F (A)+ = (ACD); (E)+ = (EADHC); Hence, G⊆F Hence, the set of FDs F and G are equivalent. 16 March 2021 34
  • 35. Redundant Functional Dependencies  A FD in the set F is redundant if it can be derived from the other FDs in the set. A redundant FD can be detected using the following steps: • Step 1: Start with a set of S of FDs • Step 2: Remove an FD f and create a set of FDs S' = S - f . • Step 3: Test whether f can be derived from the FDs in S'; by using the set of Armstrong's axioms and derived rules. • Step 4: If f can be so derived, it is redundant , and hence S' = S. Otherwise replace f into S'; so that now S' = S + f. • Step 5: Repeat steps 2 to 4 for all FDs in S. 16 March 2021 35
  • 36. An Example  For example, suppose the following set of FDs is given in the algorithm: Z -> A; B -> X; AX -> Y; ZB -> Y  Now, the dependency ZB -> Y can be derived from other FDs in the set, it can be shown to be redundant.  The following argument can be given:  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. 16 March 2021 36
  • 37. Canonical Cover/ Minimal Cover  Canonical Cover / Minimal Cover: For a given set F of FDs, a canonical cover, denoted by Fc , is a set of FDs where the following conditions are satisfied:  F and Fc are equivalent  Every FD of Fc is simple i.e. the RHS of every FD of Fc has only one attribute  No FD in Fc is redundant  The determinant or LHS of every FD in Fc is irreducible  Since it is a reduced version, it is also called as Irreducible set.  As canonical cover contains the FDs without any redundancy, therefore finding the key of the relation becomes efficient. 16 March 2021 37
  • 38. contd..  Sometimes FD Sets are not able to reduce if the set has following properties, 1. The RHS set of FD holds only one attribute. 2. The LHS set of FD cannot be reduced, it changes the entire content of the set. 3. Reducing any FD may change the content of the set.  A set of FDs with the above three properties are also called as Canonical or Minimal. 16 March 2021 38
  • 39. How to find Canonical Cover? • Step-01: – Write the given set of FDs in such a way that each FD contains exactly one attribute on its right side. • Step-02: – Consider each FD one by one from the set obtained in Step- 01. Determine whether it is essential or non-essential. – To determine whether a FD is essential or not, compute the closure of its left side: • Once by considering that the particular FD is present in the set. • Once by considering that the particular FD is not present in the set. 16 March 2021 39
  • 40. • Step-2 (contd..) – Case-1: • If results come out to be same,It means that the presence or absence of that FD does not create any difference. • Thus, it is non-essential. Eliminate that FD from the set. • Do not consider it while checking the essentiality of other FDs. – Case-2: • If results come out to be different, It means that the presence or absence of that FD creates a difference. • Thus, it is essential. Do not eliminate that FD from the set. • Mark that FD as essential. • 16 March 2021 40
  • 41. contd.. Step-03: – Consider the newly obtained set of FDs after performing Step-02 and check if there is any FD that contains more than one attribute on its left side. – Then following two cases are possible- • Case-01: No – There exists no FD containing more than one attribute on its left side. – In this case, the set obtained in Step-02 is the canonical cover. 16 March 2021 41
  • 42. • Case-02: Yes – There exists at least one FD containing more than one attribute on its left side. – In this case, consider all such FD one by one. – Check if their left side can be reduced. – Use the following steps to perform a check- » Consider a FD and compute the closure of all the possible subsets of the left side of that FDs. » If any of the subsets produce the same closure result as produced by the entire left side, then replace the left side with that subset. » After this step is complete, the set obtained is the canonical cover. 16 March 2021 42
  • 43. An Example  Consider a relation R(WXYZ) and a set of FDs X-> W, WZ ->XY, Y->WXZ. Find the canonical Cover or Minimal cover. Ans: Step-1: The right side should contain single attribute. X->W; WZ->X; WZ->Y; Y->W; Y->X; Y->Z Step-2 : Find out Closure X->W X+ = XW (When X->W is considered) X + = X (When X->W is not considered) Clearly, the two results are different. Thus, we conclude that X → W is essential and can not be eliminated. 16 March 2021 43
  • 44. contd.. Step-2 (contd..) • For WZ → X: Considering WZ → X, (WZ)+ = { W , X , Y , Z } Ignoring WZ → X, (WZ)+ = { W , X , Y , Z } • Now, Clearly, the two results are same. Thus, we conclude that WZ → X is non-essential and can be eliminated. • Eliminating WZ → X, our set of functional dependencies reduces to- X → W; WZ → Y; Y → W; Y → X; Y → Z Now, we will consider this reduced set in further checks. 16 March 2021 44
  • 45. Step-2 (contd..) • For WZ → Y: Considering WZ → Y, (WZ)+ = { W , X , Y , Z } Ignoring WZ → Y, (WZ)+ = { W , Z } Now, Clearly, the two results are different. Thus, we conclude that WZ → Y is essential and can not be eliminated. • For Y → W: Considering Y → W, (Y)+ = { W , X , Y , Z } Ignoring Y → W, (Y)+ = { W , X , Y , Z } Now, Clearly the two results are same. Thus, the FD Y->W is not essential and hence can be eliminated. Eliminating Y → W, our set of functional dependencies reduces to- X → W; WZ → Y; Y → X; Y → Z 16 March 2021 45
  • 46. contd.. Step-2 (contd..) • For Y → X: Considering Y → X, (Y)+ = { W , X , Y , Z } Ignoring Y → X, (Y)+ = { Y , Z } Now, Clearly, the two results are different. Thus, we conclude that Y → X is essential and can not be eliminated. • For Y → Z: Considering Y → Z, (Y)+ = { W , X , Y , Z } Ignoring Y → Z, (Y)+ = { W , X , Y } Now, Clearly, the two results are different. Thus, we conclude that Y → Z is essential and can not be eliminated. 16 March 2021 46
  • 47. contd.. Step-03: Consider the FD having more than one attribute on their left side. Check if their left side can be reduced. • In our set, – Only WZ → Y contains more than one attribute on its left side. – Considering WZ → Y, (WZ)+ = { W , X , Y , Z } – Now, Consider all the possible subsets of WZ and check if the closure result of any subset matches to the closure result of WZ. • (W)+ = { W } • (Z)+ = { Z } 16 March 2021 47
  • 48. contd.. Step-4: – Clearly, None of the subsets have the same closure result same as that of the entire left side. – Thus, we conclude that we can not write WZ → Y as W → Y or Z → Y. – Thus, set of FDs obtained in step-02 is the canonical cover. • Finally, the canonical cover is- X → W; WZ → Y; Y → X; Y → Z 16 March 2021 48