Docsity

Functional Dependencies and Normal Forms in Database Systems, Study notes of Distributed Database Management Systems

Toggle sidebar
bg1
Background: Functional Dependencies
We are always talking about a relation
R
,
with a xed schema (set of attributes) and a
varying
instance
(set of tuples).
Conventions:
A;B;:::
are attributes;
:::;Y;Z
are sets of attributes. Concatenation means
union.
FD is
X
!
Y
, where
X
and
Y
are sets
of attributes. Two tuples that agree in all
attributes of
X
must agree in all attributes
of
Y
.
Implication: FD
X
!
Y
follows from
F
i all
relation instances that satisfy
F
also satisfy
X
!
Y
.
Three Ways to Reason About FD's
1.
Semantic
:FD
X
!
Y
is the set of relation
instances that satisfy it.
✦
Say
Fj
=
X
!
Y
if every instance that
satises all FD's in
F
also satisfy
X
!
Y
.
✦
All approaches assume there is a xed
relation scheme
R
to which the FD's
pertain.
2.
Algorithmic
: Give an algorithm that tells us,
given
F
and
X
!
Y
, whether
Fj
=
X
!
Y
.
3.
Logical
: Give a reasoning system that lets us
deduce an FD like
X
!
Y
exactly when
Fj
=
X
!
Y
.
✦
Deduction indicated by
F`
X
!
Y
.
Closure Test for Implication (Algorithmic
Approach)
Start with
X
+
=
X
. Adjoin
V
to
X
+
if
U
!
V
is
in
F
, and
U
X
+
.At end, test if
Y
X
+
.
Proof that if
Y
X
+
, then
Fj
=
X
!
Y
:
Easy induction on the number of additions to
X
+
that
X
!
A
for all
A
in
X
+
.
Proof that if
F
implies
X
!
Y
, then
Y
X
+
:
Prove the contrapositive; assume
Y
is not a
subset of
X
+
and prove
F
does not imply
X
!
Y
. Construct relation
R
with two tuples
that agree on
X
+
and disagree elsewhere.
1
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Functional Dependencies and Normal Forms in Database Systems and more Study notes Distributed Database Management Systems in PDF only on Docsity!

Background: Functional Dep endencies

 We are always talking ab out a relation R, with a xed schema (set of attributes) and a varying instance (set of tuples).

 Conventions: A; B ; : : : are attributes; : : : ; Y ; Z are sets of attributes. Concatenation means union.

 FD is X! Y , where X and Y are sets of attributes. Two tuples that agree in all attributes of X must agree in all attributes of Y.

 Implication: FD X! Y fol lows from F i all relation instances that satisfy F also satisfy X! Y.

Three Ways to Reason Ab out FD's

  1. Semantic : FD X! Y is the set of relation instances that satisfy it.

F Say F j= X! Y if every instance that satis es all FD's in F also satisfy X! Y.

F All approaches assume there is a xed relation scheme R to which the FD's p ertain.

  1. Algorithmic : Give an algorithm that tells us, given F and X! Y , whether F j= X! Y.
  2. Logical : Give a reasoning system that lets us deduce an FD like X! Y exactly when F j= X! Y.

F Deduction indicated by F ` X! Y.

Closure Test for Implication (Algorithmic Approach)

Start with X +^ = X. Adjoin V to X +^ if U! V is in F , and U  X +^. At end, test if Y  X +^.

 Pro of that if Y  X +^ , then F j= X! Y : Easy induction on the numb er of additions to X +^ that X! A for all A in X +^.

 Pro of that if F implies X! Y , then Y  X +^ : Prove the contrap ositive; assume Y is not a subset of X +^ and prove F do es not imply X! Y. Construct relation R with two tuples that agree on X +^ and disagree elsewhere.

Armstrong's Axioms (Logical Approach)

A sound (what may b e deduced is correct in the j= sense) and complete (what is true in the j= sense can b e deduced) axiomatization of FD's.

A1: Trivial FD's or Re exivity. X! Y always holds if Y  X.

A2: Augmentation. If X! Y , then X Z! Y Z for any set of attributes Z.

A3: Transitivity. If X! Y and Y! Z , then X! Z.

Deductive Pro ofs

A series of \lines." Each line is either:

  1. A given statement (FD in the given set F for deductions ab out FD's), or
  2. A statement that follows from previous lines by applying an axiom.

Example

Given fAB! C ; C D! E g, deduce AB D! E.

AB! C (Given) AB D! C D (A2)

C D! E (Given)

AB D! E (A3)

Pro of of Soundness

Easy observations ab out relations.

Pro of of Completeness

  1. Given F , show that if A is in X +^ , then X! A follows from F by AA's.
  2. Show that if X! A 1 ; : : : ; X! An follow from AA's, then so do es X! A 1    An.
  3. Complete the pro of by observing that X! A 1    An follows from F i all of A 1 ; : : : ; An are in X +^ , and therefore i X! A 1    An follows by AA's.

Pro of (2)

Induction on i that X! A 1    Ai follows.

 Basis: i = 1, given.

 Any set of FD's equivalent to F is a cover for F.

 A cover is minimal if:

  1. No right side has more than one attribute.
  2. We cannot delete any FD from the cover and have an equivalent set of FD's.
  3. We cannot delete any attribute from any left side and have an equivalent set of FD's.

Example

Relation C T H RS G represents courses, teachers, hours, ro oms, students, and grades. The FD's: C! T ; H R! C ; H T! R; H S! R; C S! G; C H! R.

 We can eliminate C H! R.

F Pro of: Using the other 5 FD's, C H +^ = C H T R.

 Having done so, we cannot eliminate any attribute from any left side. F Sample pro of: Supp ose we tried to eliminate T from H T! R. We would need that C! T , H T! R, H R! C , H S! R, and C S! G imply H! R. But H +^ = H with resp ect to these 5 FD's.

 Thus the remaining ve are a minimal cover of the original six.

 Note: minimal cover need not b e unique, or even have the same numb er of FD's.

Lossless Join

The decomp osition of R into S 1 ; : : : ; Sn has a lossless join (with resp ect to some constraints on R) if for any instance r of R that satis es the constraints:

S 1 (r ) ./    ./ Sn (r ) = r

 Motivation: We can replace R by S and T , knowing that the instance of R can b e recovered from the instances of S and T.

Theorem

A decomp osition of R into S and T has a lossless join wrt FD's F if and only if S \ T! S or S \ T! T.

Pro of

 First note that r  S (r ) ./ T (r ) always.

 Assume S \ T! S and show that

S (r ) ./ T (r )  r

F Supp ose s is in S (r ) and t is in T (r ), and s and t join (i.e., they agree in S \ T ).

F Then t is the pro jection of a tuple t^0 of r that agrees with s on S.

F So t^0 agrees with t on T and with s on S , so t^0 is s ./ t; i.e., s ./ t is in r.

 Similarly if S \ T! T.

 Now assume neither FD follows from F.

F Then there is an instance r consisting of two tuples that agree on (S \ T )+^ and disagree elsewhere. This instance satis es F.

F Neither S nor T is contained in (S \ T )+ (or else one of the FD's in question would follow).

F Thus, r pro jected and rejoined yields four distinct tuples, and cannot b e r.

Theorem

We can always decomp ose a relation R with FD's F into BCNF relations with a lossless join.

Pro of

 We decomp ose when we nd a BCNF violation X! Y , into X [ Y and (R Y ) [ X.

 But

(R Y ) [ X

\ (X [ Y ) = X. Thus the intersection of the schemas functionally determines one of them, X [ Y.

 To complete the pro of, we need to show that when we decomp ose further, the resulting n relations have a lossless join, but that is an easy induction on n.

 Pro of that the decomp osition is always LJ will have to wait for the theory of \generalized dep endencies." F This decomp osition is obviously LJ, since AB ./ AC is lossless b ecause A! B , and then AB C ./ C D is lossless b ecause of C! D.