You are on page 1of 13

Chapter 12

Further Normalization I
1NF, 2NF, 3NF, BCNF
Topics in this Chapter

• Nonloss Decomposition and Functional


Dependencies
• First, Second, and Third Normal Forms
• Dependency Preservation
• Boyce/Codd Normal Form
• A Note on Relation-Valued Attributes

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-2


Normalization

• Normalized and 1 NF are the same thing;


typically “normalized” refers incorrectly to
3NF
• Normalization helps control redundancy
• Normalization is reversible; i.e. nonloss, or
information preserving
• Six normal forms are discussed: 1 through 5,
and Boyce-Codd Normal Form (BCNF),
which is an improvement on 3NF

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-3


Nonloss Decomposition and Functional
Dependencies

• Normalization uses a process of projection to


decompose relvars
• Recomposition is a process of joins
• The decomposition of relvar R into
projections R1…Rn is nonloss if R = the join
of R1…Rn
• The normalization procedure can be seen as a
method for eliminating functional
dependencies that do not emanate from a
candidate key

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-4


Third Normal Form

• A relvar is in 3NF if and only if the nonkey


attributes are both mutually independent and
irreducibly dependent on the primary key
• A relvar is in 3NF if and only if, for all time,
each tuple consists of a primary key value that
identifies some entity, together with a set of
zero or more mutually independent attribute
values that describe that entity in some way

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-5


First Normal Form

• A relvar is in 1NF if and only if in every legal


value of that relvar, every tuple contains
exactly one value for each attribute
• In this way, relvars are always in 1NF
• A relvar in 1NF may display functional
dependencies other than those emanating from
the primary key
• Such non-primary-key dependencies promote
a miasma of update anomolies

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-6


Update Anomalies

• “Update anomalies” include three operations:


• An INSERT anomaly occurs when the user
wishes to record a subordinate fact that is not
dependent on the primary key (e.g., recording
a supplier location before the supplier supplies
a part)
• A DELETE anomaly, conversely, may delete
the location inadvertently
• An UPDATE anomaly occurs when many
updates are required to record a simple fact

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-7


Second Normal Form

• A relvar is in 2NF if and only if it is in 1NF


and every nonkey attribute is irreducibly
dependent on the primary key
• (Assumes only one candidate key)
• A relvar in 2NF is less susceptible to update
anomalies, but may still exhibit transitive
dependencies
• Both attributes in a transitive dependency are
irreducibly implied by the primary key, and
each implies the other

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-8


Third Normal Form

• A relvar is in 3NF if and only if it is in 2NF


and every nonkey attribute is nontransitively
dependent on the primary key
• (Assumes only one candidate key)
• The process of normalization is a series of
projections that eliminate complex functional
dependencies
• Such projections must be able to be
recombined via JOIN to form the original
relvar

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-9


Dependency Preservation

• Dependency preservation refers to a specific


case of nonloss decomposition, such that the
normalized relvars are independent of each
other
• Some nonloss decompositions do not exhibit
dependency preservation
• Example: decompose supplier, city, status
where supplier implies city and status, and
city and status imply each other

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-10


Dependency Preservation

• Dependency is preserved in this projection:


SC {S#, CITY}
CS {CITY, STATUS}
• Dependency is not preserved in this one:
SC {S#, CITY}
CS {S#, STATUS}
• Although the second is nonloss, you still
cannot update them independently

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-11


Boyce/Codd Normal Form

• BCNF refers to decompositions involving


relvars with more than one candidate key,
where the candidate keys are composite and
overlapping
• A relvar is in BCNF if and only if every
nontrivial, left- irreducible FD has a candidate
key as its determinant
• That is, a relvar is in BCNF if and only if
every determinant is a candidate key

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-12


Relation-Valued Attributes

• A relation may include attributes whose


values are relations
• Traditionally this would be seen to violate
1NF, which was held to prohibit repeating
groups
• Now they are theoretically sound, but in
practice you should avoid them because they
have complicated predicates

Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 12-13

You might also like