Mormal Form
Mormal Form
Mormal Form
CS157A
Chris Pollett
Nov. 21, 2005.
Outline
• General Definitions of Normal Forms
• Boyce-Codd Normal Form
• Properties of Relational Decomposition
General Definitions of Normal
Forms
• The original definitions of normal forms we
gave last day were defined in terms of the
primary key.
• Today, we’ll briefly consider definitions
which are with respect to any key.
General Definition 2NF
• A relation schema R is in 2NF if every nonprime attribute A in R is not
partially dependent on any key of R.
• For example, suppose we had the table:
LOTS(PropertyID, CountyName, Number, Area, Price, TaxRate)
and we had the functional dependencies:
PropertyID --> CountyName, Number, Area, Price, TaxRate
CountyName, Number --> PropertyID, Area, Price, TaxRate
CountyName --> TaxRate
Area --> Price
• In this situation, TaxRate is nonprime and partially depends on the
candidate key CountryName, Number.
• To put this in 2NF, we would set up a new relation for each partial key
with its dependent attributes.
General Definition 3NF
• Recall a trivial dependency is a dependency of the
form X-->A where X ⊇ A .
• A relation schema R is in 3NF if whenever a
nontrivial FD X-->A holds in R, either (a) X is a
superkey of R or (b) A is a prime attribute of R.
• For instance, if we had split LOTS from the last
slide into:
LOTS1(PropertyID, CountyName, Number, Area, Price)
LOTS2(CountyName, TaxRate)
It would be in 2NF but not 3NF, because Area --> Price in LOTS1
but Area is not a superkey and Price is not prime.
• Conditions (a) and (b) guarantee both being in 2NF and
there being no transitive dependencies.
Boyce-Codd Normal Form
• The general definition of 3NF can be further simplified to give an even
stronger normal form:
• A relation schema R is in Boyce-Codd Normal Formal (BCNF) if
whenever a nontrivial FD X-->A holds in R, then X is a superkey of R.
• For example, suppose we put LOTS1 of the last slide into 3NF by
making two relation schemas:
LOTS1a(PropertyID, CountyName, Number, Area)
LOTS1b(Area, Price)
• Now suppose we added the FD Area -->CountyName, since maybe
from the plots size we can figure out which county we are in.
• Even with this new FD our decomposition is still in 3NF.
• However, it is not in BCNF.
Properties of Relational
Decomposition
• We are now about to describe algorithms for putting our
tables in normal forms.
• We assume we start with a universal relation which has all
the attributes of the DB we want to store.
• We assume we also have a list of FDs, F, for these
attributes.
• The goal is to decompose this universal relation R=(A1,…,
An) into relation schemas D = {R1,…, Rm} in some normal
form.
• We also want the decomposition to be attribute preserving: