
1
Schema Refinement
and Normalization
Nobody realizes that some people
expend tremendous energy
merely to be normal.
Albert Camus
Normal Forms
ā¢Review FDs, Armstrongās Axioms and Attr. Closures!
ā¢Q1: is any refinement needed??!
ā¢If a relation is in a
normal form
(BCNF, 3NF etc.):
āwe know that certain problems are avoided/minimized.
āhelps decide whether decomposing a relation is useful.
ā¢Role of FDs in detecting redundancy:
āConsider a relation R with 3 attributes, ABC.
ā¢No (non-trivial) FDs hold: There is no redundancy here.
ā¢Given A B: If A is not a key, then several tuples could have the
same A value, and if so, theyāll all have the same B value!
ā¢1st Normal Form āall attributes are atomic
āi.e. the relational model
ā¢1st 2nd (of historical interest) 3rd Boyce-Codd ā¦
Boyce-Codd Normal Form (BCNF)
ā¢Reln R with FDs
F
is in BCNF if, for all X A in F+
āA X (called a
trivial
FD), or
āX is a superkey for R.
ā¢In other words: āR is in BCNF if the only non-trivial FDs
over R are
key constraints
.ā
ā¢If R in BCNF, then every field of every tuple records
information that cannot be inferred using FDs alone.
āSay we know FD X A holds this example relation:
ā¢Can you guess the value of the
missing attribute?
ā¢Yes, so relation is not in BCNF
X Y A
5y1 7
5y2 ?
Decomposition of a Relation Schema
ā¢If a relation is not in a desired normal form, it can be
decomposed
into multiple relations that each are in that
normal form.
ā¢Suppose that relation R contains attributes
A1 ... An.
A
decomposition
of R consists of replacing R by two or more
relations such that:
āEach new relation scheme contains a subset of the
attributes of R, and
āEvery attribute of R appears as an attribute of at least
one of the new relations.
Example (same as before)
ā¢SNLRWH has FDs S SNLRWH and R W
ā¢Q: Is this relation in BCNF?
Hourly_Emps
No, The second FD causes a violation;
W values repeatedly associated with R values.
Decomposing a Relation
ā¢Easiest fix is to create a relation RW to store these
associations, and to remove W from the main
schema:
ā¢Decompositions should be used only when needed.
āQ: potential problems of decomposition?
ā¢Q: Are both of these relations are now in BCNF?