0% found this document useful (0 votes)
95 views35 pages

Lecture 3 Functional Dependancy +closure

code → Product, Supplier (FD) code, Supplier → City, Price, stock (PD on candidate key {code, Supplier}) City → Price (TD through Supplier)

Uploaded by

Tabindah asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views35 pages

Lecture 3 Functional Dependancy +closure

code → Product, Supplier (FD) code, Supplier → City, Price, stock (PD on candidate key {code, Supplier}) City → Price (TD through Supplier)

Uploaded by

Tabindah asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 35

Functional

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

STD(stId, stName, stAdr, prName, credits)


stId stName, stAdr, prName, credits
prName credits

6
FD Example from Table
stId stName stAdr prName prCrdts
S1020 Sohail Dar I-8 Islamabad MCS 64

S1038 Shoaib Ali G-6 Islamabad BCS 132

S1015 Tahira Ejaz L Rukh Wah MCS 64

S1015 Tahira Ejaz L Rukh Wah MCS 132

S1018 Arif Zia E-8, Islamabad. BIT 134

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

eId, prId  prSal


STD(stId, stName, prName, adr, nic, cgpa)
stId  stName, prName, adr, nic, cgpa
nic  stName, prName, adr, stId, cgpa
10
Functional Dependencies
EmpNum EmpEmail EmpFname EmpLname
123 [email protected] John Doe
456 [email protected] Peter Smith
555 [email protected] Alan Lee
633 [email protected] Peter Doe
787 [email protected] Alan Lee

If EmpNum is the PK then the FDs:


EmpNum  EmpEmail
EmpNum  EmpFname
EmpNum  EmpLname
must exist.

11
Functional Dependencies
Diagram
EmpNum  EmpEmail 3 different ways
EmpNum  EmpFname you might see FDs
EmpNum  EmpLname depicted
EmpEmail
EmpNum EmpFname
EmpLname

EmpNum EmpEmail 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.

InvNum LineNum Qty InvDate

Candidate keys: {InvNum, LineNum} InvDate is


partially dependent on {InvNum, LineNum} as
InvNum is a determinant of InvDate and InvNum is
part of a candidate key
13
Transitive dependency
Transitive dependency

Consider attributes A, B, and C, and where


A  B and B  C.
Functional dependencies are transitive, which
means that we also have the functional dependency
AC
We say that C is transitively dependent on A
through B.

14
Transitive dependency
EmpNum  DeptNum

EmpNum EmpEmail DeptNum DeptNname

DeptNum  DeptName

EmpNum EmpEmail DeptNum DeptNname

DeptName is transitively dependent on EmpNum via DeptNum


EmpNum  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.

However, a candidate key is always a determinant, but a


16
determinant doesn’t need to be a key.
Closure
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.

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.

2. Augmentation Rule --- If X  Y holds and W is a set


of attributes, then WX  WY holds.
3. Transitivity Rule --- If X  Y and Y  Z holds, then
X  Z holds.
Derived Theorems
from Axioms
4. Union Rule --- If X  Y and X  Z
holds, then X  YZ holds.
5. Decomposition Rule --- If X  YZ holds,
then so do X  Y and X  Z.
6. Pseudotransitivity Rule --- If X  Y and
WY  Z hold then so does WX  Z.
Three rules for closure
1. Decompose the Functioal Dependancies in
the Elementary Functional dependencies.
2. Eleminate the redundant functional
dependancies
3. Eleminate the redundant elemetns in the
left side
Decompose the Functioal Dependancies in
the Elementary Functional dependencies.

 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

Apply Transitive Dependancy

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.

code Product Supplier City Price stock


100 p1 f2 PARIS 15,50 2500
100 p1 f1 LYON 16,20 2500
103 p2 f1 LYON 18,50 1100
103 p2 f3 BORDEAUX 18,50 1100
103 p2 f2 PARIS 17,50 1100
105 p3 f1 LYON 275,60 300
112 p4 f3 BORDEAUX 38,75 0
112 p4 f1 LYON 39,60 0

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

You might also like