Lecture 7 & 8 - Database Systems
Lecture 7 & 8 - Database Systems
Lecture-7
Functional Dependency and Normalization
Data Normalization
• Primarily a tool to validate and improve a logical
design so that it satisfies certain constraints that
avoid unnecessary duplication of data
• The process of decomposing relations with
anomalies to produce smaller, well-structured
relations
3
Data Normalization
• Three major occasions when you can benefit from
normalization:
– During conceptual data modeling
– During Logical database design
– During Reverse Engineering older system
4
Data Normalization
• Following are some of the main goals of
normalization:
5
Figure 5.22 Steps in normalization
6
Well-Structured Relations
• A relation that contains minimal data redundancy and
allows users to insert, delete, and update rows without
causing data inconsistencies
• Goal is to avoid anomalies
– Insertion Anomaly–adding new rows forces user to create
duplicate data
– Deletion Anomaly–deleting rows may cause a loss of data that
would be needed for other future rows
– Modification Anomaly–changing data in a row forces changes to
other rows because of duplication
9
Anomalies in this Table
• Insertion– can’t enter a new employee without having the
employee take a course (e.g. E_ID 140)
• Deletion–if we remove employee 140, we lose information about
the existence of a Tax Acc class
• Modification–giving a salary increase to employee 100 forces us to
update multiple records
11
Functional Dependencies and Keys
12
Functional Dependencies and Keys
13
Functional Dependencies and Keys
• Examples of Functional Dependencies
14
Functional Dependencies and Keys
• Examples of Functional Dependencies
15
First Normal Form
• No multi-valued attributes
• Every attribute value is atomic
• EMPLOYEE1 is not in 1st Normal Form (multi-
valued attributes) it is not a relation
• EMPLOYEE2 is in 1st Normal form
• All relations are in 1st Normal Form
16
Table with multi-valued attributes, not in 1st normal form
17
Table with no multivalued attributes and unique rows, in 1st
normal form
18
Anomalies in this Table
• Insertion–if new product is ordered for order 1007 of
existing customer, customer data must be re-entered,
causing duplication
• Deletion–if we delete the Dining Table from Order 1006,
we lose information concerning this item's finish and
price
• Update–changing the price of product ID 4 requires
update in several records
20
Figure 5-27 Functional dependency diagram for INVOICE
22
Third Normal Form
23
Figure 5-28 Removing partial dependencies
Getting it into
Third Normal
Form
24
Figure 5-30 Relational Schema of invoice Data (3NF)
25
Merging Relations
• An understanding of how to merge relationships is important
for three reasons: -
– On a large project, the work of several sub teams comes
together during logical design.
– Integrating databases with new information requirements
often leads to the need to integrate different views.
– New data requirements may arise during the life cycle, so
there is a need to merge what has already been
developed.
26
Merging Relations
• Issues to watch out for when merging entities from different
ER models:
– Synonyms –two or more attributes with different names
but same meaning
27
Merging Relations
– Homonyms –attributes with same name but different
meanings
28
Merging Relations
– Transitive dependencies –even if relations are in 3NF prior
to merging, they may not be after merging
29
Merging Relations
– Supertype/subtype relationships –may be hidden prior to
merging
30
References
Chapter 5: Modern Database Management 8th
Edition by Jeffrey A. Hoffer, Mary B. Prescott,
Fred R. McFadden