Sei sulla pagina 1di 2

Lecture Notes For DBMS

Multivalued Dependencies
Let R be a relation schema, and X and Y be disjoint subsets of R (i.e., X R, Y R,
XY= ), and Z = R- XY.A relation r(R) satisfies X Y if for any two tuples t1 and t2,
o t1(X)=t2(X), then there exist t3 in r such that
o t3(X)=t1(X), t3(Y)=t1(Y), t3(Z)=t2(Z).
o By symmetry, there exist t4 in r such that
o t4(X)=t1(X), t4(Y)=t2(Y), t4(Z)=t1(Z).

X Y Z
t1 x1 y1 z1
t2 x1 y2 z2
t3 x1 y1 z2
t4 x1 y2 z1

The MVD X Y says that the relationship between X and Y is independent of the
relationship between X and R-Y
For example consider the table Employee:

Employee-name Project-name Dependant-name


Smith X John
Smith Y Ann
Smith X Ann
Smith Y John

o MVDs Employee-name Project-name and Employee-name Dependant-name


hold in the relation
o The employee named Smith works on projects X and Y, and has two dependents
John and Ann.
o If we store only the first two tuples in the relation, it would incorrectly show the
associations among attributes
o If we have MVDs in a relation, we may have to repeat values redundantly in the
tuples. In the Employee relation, values X and Y of Project-name are repeated
with each value of Dependant-name--- clearly undesirable
o Problem: Employee schema is in BCNF because no FDs hold for it
o Trivial MVD: If MVD X Y is satisfied by all relations whose schemas include X
and Y, it is called trivial MVD.
XY is trivial whenever Y X or XY=R
o If a relation r fails to satisfy a given MVD, a relation r that satisfies the MVD can
be constructed by adding tuples to r.
MVD is called "tuple generating dependency"
compare it with FD: need to delete tuples to make the relation to satisfy a
given FD
o MVD can be used in two ways

Department of Computer Science By: Dipendra Air


Lecture Notes For DBMS

test relations to determine whether they are legal under a given set of FDs
and MVDs
specify constraints on a set of relations
Let D: a set of FDs and MVDs then D+: the closure of D is the set of all FDs and MVDs
logically implied by D.
D+ can be computed using the following set of sound and complete rules
1. reflexivity: if Y X then XY
2. augmentation: if X Y then WX Y
3. transitivity: if XY and YZ then X Z
4. complementation: if XY then X R-XY
5. MV augmentation: if X Y and W R, V W,then WX VY
6. MV transitivity: if X Y and Y Z then X Z-Y
7. replication: if X Y then X Y
8. coalescence: if XY and ZY, WR, WY= , WZ, then XZ
Note: The first three rules are Armstrongs axioms.

Fourth Normal Form(4NF):


A relation scheme R is in 4NF w.r.t. D, if for every non-trivial MVD XY in D+, X is a
superkey for R
4NF vs BCNF
o 4NF is different from BCNF only in the use of D (FD + MVD) instead of F (FDs)
o every 4NF schemas are also in BCNF.
By replication rule, XY implies XY.
o If R is not in BCNF, there exists a non-trivial FD XY where X is not a superkey
--- R cannot be in 4NF
For example: Employee (Employee-name, Project-name, Dependant-name) is not in 4NF,
since
o Employee-namePproject-name but Employee-name is not a key.
o Decompose into Emp-proj (E-n, P-n) and Emp-dep (E-n, D-n) do bring the tables
in 4NF
For example: Borrow (Loan#, C-name, Street, C-city) is in BCNF, but not in 4NF,
because C-nameLoan# is a non-trivial MVD, where C-name is not a key in this
schema.
The decomposition -- R1=(C-name, Loan#), R2=(C-name, Street, C-city)brings them
in 4NF
Benefits of Fourth Normal Form
o Reduced number of tuples
o No anomalies for insert/delete/update
Comparing FD and MVD
o if we have (a1,b1,c1,d1) r and (a1,b2,c2,d2) r
AB implies b1=b2
AB implies (a1,b1,c2,d2) r and (a1,b2,c1,d1) r

Department of Computer Science By: Dipendra Air

Potrebbero piacerti anche