
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?