Lecture 3 Functional Dependancy +closure
Lecture 3 Functional Dependancy +closure
Dependancy
Chapter 3
1
Functional Dependency
Normalization is based on
functional dependencies (FDs)
A type of relationship between
attributes of a relation
2
Functional Dependency
Definition: If A and B are attributes of
a relation R, then B is functionally
dependent on A if each value of A in
R is associated with exactly one value
of B; written as A B
3
Functionally Dependency
It does not mean that A derives B,
although it may be the case sometime
Means that if we know value of A then
we can precisely determine a unique
value of B
4
Functional Dependency
Attribute of set of attributes on the left
side are called determinant and on the
right are called dependents
Like R (a, b, c, d, e)
a b, c, d
d d, e
5
FD Example
6
FD Example from Table
stId stName stAdr prName prCrdts
S1020 Sohail Dar I-8 Islamabad MCS 64
7
FDs and Keys
We can determine the keys of a
table seeing its FDs
The determinant of an FD that
determines all attributes of that
table is the super key
8
FDs and Keys
A minimal super key is the candidate
key, so if a determinant of an FD
determines all attributes of that relation
then it is definitely a super key, and
FDs help to identify keys, how
9
FDs and Keys
EMP(eId, eName, eAdr, eDept, prId, prSal)
eId eName, eDept, eAdr
11
Functional Dependencies
Diagram
EmpNum EmpEmail 3 different ways
EmpNum EmpFname you might see FDs
EmpNum EmpLname depicted
EmpEmail
EmpNum EmpFname
EmpLname
12
Partial dependency
A partial dependency exists when an attribute B is
functionally dependent on an attribute A, and A is a
component of a multipart candidate key.
14
Transitive dependency
EmpNum DeptNum
DeptNum DeptName
15
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.
17
Axioms
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.
18
Inference Rules
Called inference axioms or
armstrong axioms
These are rules that establish certain
FDs from a given set of FDs
These rules are sound
19
Reflexivity
If B is a subset of A then A B,
it also implies that A A always
hold, that is
stName, stAdr stName
Or stName stName
20
Augmentation
If we have A B then
AC BC that is
if stId stName then
stId, stAdr stName, stAdr
21
Transitivity
If A B and B C then A C
that is
If stId prName and prName credits
Then
stId credits
22
Additivity or Union
If A B and A C then A BC
if empId eName and empId qual
Then we can write it as
empId eName, qual
23
Projectivity or Decomposition
If A BC then A B and A C
if empId eName, qual
Then we can write it as
empId eName and empId qual
24
Pseudotransitivity
If A B and CB D then AC D
if stId stName and
stName, fName stAdr
Then we can write it as
stId, fName stAdr
25
Axioms Cont.
1. Reflexivity Rule --- If X is a set of attributes and Y is a
subset of X, then X Y holds.
each subset of X is functionally dependent on X.
f1 : F → N
f2 : F → P
f3 : P,F, N → PU
f4 : P → C
f5 : P → T
f6 : C → T
f7 : N → F
All the elements are already in the elementry dependance because
2.Eleminate the redundant
functional dependancies
f4 : P → C and f6 : C → T et f5 : P → T
If X → Y and Y → Z ⇒ X → Z
It means P → T so f5 : P → T can be deleted
3,Eleminate the redundant
elemetns in the left side
f3 : P,F, N → PU , f1: F → N so Psuedo
Transitiviy
If X → Y and W U Y → Z ⇒ W U X → Z
It means F → N, W=PF, Y=N, X=F, ⇒ P F,
F → PU Therefore P F → PU
Similar property for P F → PU
It means f2:F → P, W=F, Y=P,
X=F, ⇒ F , F → PU enfin F →
PU
Closure
f1 : F → N
f2 : F → P
f3 : F→ PU
f4 : P → C
f6 : C → T
f7 : N → F
33
Find out the Functional, Transitive and Partial dependancies.
34
Functional depenancies
f1 : C→ D
f2 : D → C
f3 : F → V
f4 : C,F → P
f5 : D,F → P
f6 : C → S
f7 : D → S
35