0% found this document useful (0 votes)
62 views16 pages

Functional Dependencey: J.C.Patni

The document discusses functional dependencies, which specify relationships between attributes in a database relation. It provides examples of functional dependencies and discusses: - Functional and non-functional dependencies - Closure of a set of functional dependencies - Finding all keys and superkeys of a relation given its functional dependencies through closure operations - Trivial vs non-trivial functional dependencies

Uploaded by

AsasAsas
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)
62 views16 pages

Functional Dependencey: J.C.Patni

The document discusses functional dependencies, which specify relationships between attributes in a database relation. It provides examples of functional dependencies and discusses: - Functional and non-functional dependencies - Closure of a set of functional dependencies - Finding all keys and superkeys of a relation given its functional dependencies through closure operations - Trivial vs non-trivial functional dependencies

Uploaded by

AsasAsas
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/ 16

Functional Dependencey

J.C.PATNI

Functional Dependence
Existence dependence: The existence of B depends on A
Functional dependence: Bs value depends on As value
EmpName is functionally dependent on EmpNo
Given the EmpNo, I can one and only one value of
EmpName
Require that the value for a certain set of attributes
determines uniquely the value for another set of attributes.
Functional dependence is a generalization of the notion of
a key.

Functional Dependencies

Loan-info = (branch-name, loan-number, customername, amount)


We expect the following set of functional dependencies
to hold:
loan-number amount
loan-number branch-name
but would not expect the following to hold:
loan-number customer-name

Examples
loan-number amount
loan-number branch-name

customer-name
loan-number

Another example:
reverse of the fds above

loan-info
branch-nm
Perryridge
Perryridge
Perryridge
Wanchai
loan-info
branch-nm
Perryridge
Perryridge
Central
Wanchai

loan-no
L-001
L-001
L-001
L-002

loan-no
L-001
L-001
L-001
L-002

cust-nm
Peter Yeung
David Chan
May Chan
Leon Lai

cust-nm
Peter Yeung
Peter Yeung
Peter Yeung
Leon Lai

amount
100000
100000
100000
100000

amount
100000
100000
250000
100000

Closure of a Set of Functional


Dependencies
Given a set of functional dependencies F, there are certain other
functional dependencies that are logically implied by F.
The set of all functional dependencies logically implied by F is the
closure of F.
We denote the closure of F by F+.
We can find all of F+ by applying :
if , then (reflexivity)
if , then (augmentation)
if and , then (transitivity)

Closure
We can further simplify computation of F+ by
using the following additional rules.
If holds and holds, then
holds (union)
If holds, then holds and
holds (decomposition)
If holds and holds, then
holds (pseudotransitivity)

Examples of Armstrongs
Axioms
We can find all of F+ by applying :
if , then (reflexivity)
loan-no loan-no
loan-no, amount loan-no
loan-no, amount amount
if , then (augmentation)
loan-no amount
(given)
loan-no, branch-name amount, branch-name
if and , then (transitivity)
loan-no branch-name (given)
branch-name branch-city
(given)
loan-no branch-city

Example
R = (A, B, C, G, H, I)
F = {A
A
CG
CG
B

B
C
H
I
H}

some members of F+
A H
AG I
CG HI

A B; B H
A C; AG CG; CG I

Example

R = (A, B, C, G, H, I)
F= ( A B
A C
CG H
CG I
B H}
(AG+)
1. Result= AG
2. Result= ABCG (A C; A B and A
AG)
3. Result= ABCGH (CG H and CG AGBC)
4. Result=ABCGHI (CG I and CG
AGBCH)
Is AG a candidate key?
1. AG R

result contains
all of the
attributes of R,
so stop

Example

R = (A, B, C, G, H, I)
F={ AB
AC
CG H
CG I
B H}
some members of F +
AH
by transitivity from A B and B H
AG I
by augmenting A C with G, to get AG CG
and then transitivity with CG I
CG HI
from CG H and CG I : union rule

Example
Given this FD for this R(A,B,C,D,E,F)
AB C
AD E
BD
AFB
Check if AB+ is a key for this relation?
AB+ is key if AB+ can find all the attribute of R
ABAB
BD so B AB AB+ABD
ADE so AD ABDAB+ABDE
ABC so AB ABDE AB+ABCDE
AFB so AF Not ABDE AB+ABCDE
AB not a key because it does not contain all attributes such as F

Example
Given this FD for this R(A,B,C,D,E,F)
AB C
AD E
BD
AFB
Check if AF+ is a key for this relation?
AF is a key

Example
Given this FD for this R(A,B,C,D,E,F,G)
A D
D CG
BE
EF
ABF
What are all the keys for this relation?
Solution: we look to the right side of FD and take all the attribute
which does not found in the FD
Here is AB
Then find AB+ = ABCDEFG AB is a key

Example
Given this FD for this R(A,B,C,D)
AB C
CD
DA
What are all the keys for this relation?
Look to the right B
Take all minimum combination with B
AB,BC,BD
Find
AB+=ABCD
BC+=ABCD
BD+=ABCD
ALL AB,BC,BD are keys
List all the super keys for R that are not key (not minimal number of attributes)
ABC
BCD
ABCD

Trivial and non trivial dependency


A Functional dependency A1,A2,.An Bn is said to be
trivial dependency if B is one of As such as:
title, year title
Not trivial if one of Bs not on As such as:
title, year length, year
Complete not trivial dependency if all Bs not found on
As

Example
Given this FD for this R(A,B,C,D)
AC D
completely non trivial
BC A
completely non trivial
DB
completely non trivial
What are the keys?
Look to right C take all combinations AC, BC, CD
What are the super key?
ABC
ADC
BCD
ABCD
ABD not a super key because C must be found on left side

You might also like