2
7
Reasoning with FD’s
Given a relation
R
and a set of FD’s
F
±
Does another FD follow from
F
?
²
Are some of the FD’s in
F
redundant (i.e., they follow
from the others)?
±
Is
K
a key of
R
?
²
What are all the keys of
R
?
8
Attribute closure
±
Given
R
, a set of FD’s
F
that hold in
R
, and a set of
attributes
Z
in
R
:
The closure of
Z
(denoted
Z
+
) with respect to
F
is
the set of all attributes {
A
1
,
A
2
, …} functionally
determined by
Z
(that is, Z
→
A
1
A
2
…)
±
Algorithm for computing the closure
²
Start with closure =
Z
²
If
X
→
Y
is in
F
and
X
is already in the closure, then
also add
Y
to the closure
²
Repeat until no more attributes can be added
9
A more complex example
StudentGrade
(
SID
,
name
,
email
,
CID
,
grade
)
±
SID
→
name
,
email
±
email
→
SID
±
SID
,
CID
→
grade
(Not a good design, and we will see why later)
10
Example of computing closure
±
F
includes:
²
SID
→
name
,
email
²
email
→
SID
²
SID
,
CID
→
grade
±
{
CID
,
email
}
+
= ?
±
email
→
SID
²
Add
SID
; closure is now {
CID
,
email
,
SID
}
±
SID
→
name
,
email
²
Add
name
,
email
; closure is now {
CID
,
email
,
SID
,
name
}
±
SID
,
CID
→
grade
²
Add
grade
; closure is now all the attributes in
StudentGrade
11
Using attribute closure
Given a relation
R
and set of FD’s
F
±
Does another FD
X
→
Y
follow from
F
?