Professional Documents
Culture Documents
Chapter 3
Design theory for
Relational Database - FDs
Objectives
5 Understand what are closing sets of FD’s and how to determine them
1 Functional Dependencies
6 Projecting FD’s
1. Functional Dependency Definition
Movies1
1. TRUE
(title, year) → (length, genre, studioName)
2. FALSE
(title, year) → (starName)
Example: Functional Dependency
1. TRUE/FALSE
A→B
2. TRUE/FALSE
AB → C
2. Properties of
functional dependencies
Given that X, Y, and Z are sets of attributes in a relation R,
one can derive several properties of functional dependencies.
Among the most important are Armstrong’s axiom, which are used in
database normalization:
• Subset Property (Reflexivity): If Y is a subset of X, then X → Y
• Augmentation (Augmentation): If X → Y, then XZ → YZ
• Transitivity (Transitivity): If X → Y and Y → Z, then X → Z
Exercise 1:
(title, year) forms a key?
Exercise 2:
(title, year, starName) forms a key ?
Example: Keys
Exercise 1:
(title, year) forms a key? Not a key
Row 1 and 2: agree in (title, year) but do not agree in
starName (title, year) do not determine starName
Exercise 2:
(title, year, starName) forms a key ? A key
Find keys
A B C D E F
13
Find keys
A B C D E F
Custid Cphone
14
3. Super-key
Step 2: result = A;
25
Some LEMAs
26
Exercises 1
R (A, B, C, D)
S = {BC→D, D→A, A→B}
What are all the keys of R?
What are all the super-keys for R that are not
keys?
Exercises 2
R (A, B, C, D)
S = {AD→B, AB→C, BC→D, CD→A}
What are all the keys of R?
What are all the super-keys for R that are not
keys?
Closing sets of FD’s
A minimal basis (or closing sets) of FD’s for a relation
is a set of functional dependencies B that satisfies three
conditions:
All the FD’s in B have singleton right sides.
If any FD is removed from B, the result is no longer the
basic.
If for any FD in B we remove one or more attributes
from the left side, the result is no longer the basic.
No trivial FD can be in a minimal basis.
Projecting FD’s
Algorithm for projecting a set of FD’s
Ex. The attribute closures
1. R = (A,B,C,D,E), F = {A -> C, E -> D, B -> C}
a. {A, B, E}+ b. {A, B, C, E}+ c. {A, B, D, E}+
2. R = (A,B,C,D,E), F = {A -> BE, C -> BE, B -> D}
a. {A, C}+ b. {A, B, C}+ c. {A, C, E}+
3. R = (A,B,C,D,E,F), F = {A -> B, B -> D, C -> D, E -> F}
a. {A, C, E}+ b. {A, B, C, E}+ c. {A, C, D, E, F}+
4. R = (A,B,C,D), F = {AB -> C, BC -> D, CD -> A}
a. {A, B}+ b. {B, C}+ c. {B, C, D}+
a. R = (A,B,C,D), F = {A -> BCD, C -> A}
a. {A}+ b. {C}+ c. {A, D}+ d. {A, B, C}+
32
Ex. Closing sets of FD’s
33
ĐẠI HỌC FPT CẦN THƠ