04 Normalization
04 Normalization
Data Modeling
Concepts III
NORMALIZATION
IT IM01: Advanced Database Systems
2
Lecture Outline
• Define Normalization and Data Redundancy
• Data Redundancy Anomalies
• Normalization Objectives, Advantages, and
Goals
• Identify Dependencies Addressed in
Normalization
3
Conceptual Model to Relational Model
4
Normalization
5
Normalization: Anomalies
6
Normalization: Anomalies
7
Normalization: Anomalies
8
Normalization: Objectives
To avoid anomalies
To reduce
in insertion,
restructuring of
modification, and
tables.
deletion.
To make a neutral
To make the query of the
models more collection of
informative. relations despite
the fluidity of data.
9
Advantages of Normalization
Also, by narrowing of
Smaller database size
tables, we can easily
which then has an outcome
specify which tables are to
of faster response time.
be joined.
10
Goals of Normalization Process
Each row/column
Each relation (table)
intersection contains
represents a single
only one value and not a
subject.
group of values
12
Functional Dependence
13
Functional Dependence
Dependence
Partial Dependency
16
Transitive Dependency
17
Transitive Dependency
• Book → Author
If you know the book’s
name, you can learn the
author’s name
• Author → Author
Nationality
If you know the author’s
name, you can easily
identify his nationality
• Functional Dependence
A → B ( A determines B): For every value of A, there is a unique value of B
• Transitive Dependence
Q → E (Q is a transitive dependency of E): If Q is functionally dependent on W,
and W is functionally dependent on E, then Q is transitively dependent on E
Note: Check on non-key fields/columns: If there are fields that can be used to determine other non-key fields,
transitive dependence might be present
• Partial Dependence
If (A,B) are primary keys and C is functionally dependent on A alone, then C is partially
dependent on A
Note: Only happens when there are multiple primary keys on a table (Composite Primary Key)
19
Restaurant Mgmt Application
• Imagine we're building a restaurant management application. That application needs to store data about the
company's employees and it starts out by creating the following table of employees:
What is
the
Primary
Key?
20
Restaurant Mgmt Application
Functional
Dependence: Are
all of these
columns
dependent on
and specific to
the primary key?
21
Restaurant Mgmt Application
• Imagine we're building a restaurant management application. That application needs to store data about the
company's employees and it starts out by creating the following table of employees:
Transitive
Dependence:
Do any of the
non-primary key
fields depend
on something
other than the
primary key?
22
Restaurant Mgmt Application
• Imagine we're building a restaurant management application. That application needs to store data about the
company's employees and it starts out by creating the following table of employees:
Partial
Dependence:
Do any of the
non-primary key
fields depend
on only one of
the primary
keys?
23
Student Data Table
Student Student Fees Date of Teacher Teacher Course
Address Subject 1 Subject 2 Subject 3
ID Name Paid Birth Name Address Name
3 Main Street, James
2000- John 18-Jul- 4-Aug- Economics 1 Biology 1 44 March Way,
North Boston Peterso Economics
12345 Smith 00 91 (Business) (Science) Glebe 56100
56125 n
16 Leeds Road, Business James
2000- Maria 14- 10-Sep- Biology 1 Programm 44 March Way, Computer
South Boston Intro Peterso
23456 Griffin May-01 92 (Science) ing 2 (IT) Glebe 56100 Science
56128 (Business) n
21 Arrow
2000- Susan 3-Feb- 13-Jan- Biology 2 Sarah
Street, South Medicine
54628 Johnson 01 91 (Science) Francis
Boston 56128
14 Milk Lane,Â
2000- Matt 29- 25-Apr- Shane 105 Mist Road,
South Boston Dentistry
95634 Long Apr-02 92 Cobson Faulkner 56410
56128
• Dependency Diagrams
27
Relational Notation Schema
• Relational notation is a process of transforming an E/R diagram into a more friendly and usable
type of diagram that is easily readable.
• This can be done by
1. Taking the names of each table and its attributes and ordering them in a specific order.
2. Always start with the primary key(s), which are commonly notated with the underscore, Next all
other attributes are added.
3. If an attribute happens to be a foreign key it needs to be underscored with a dotted line.
TABLE_NAME(primary_key, foreign_key,
nonkey_attribute1, nonkey_attribute 2, nonkey_attribute3)
28
Dependency Diagram
29
Dependency Diagram Example
• The dependency diagram indicates that authors are paid royalties for each
book they write for a publisher. The amount of the royalty can vary by
author, by book, and by edition of the book.
30
Dependency Diagram Example
• The dependency diagram indicates that authors are paid royalties for each
book they write for a publisher. The amount of the royalty can vary by
author, by book, and by edition of the book.
NonKey Attributes
Primary Keys
31
Dependency Diagram Example
• The dependency diagram indicates that authors are paid royalties for each book they
write for a publisher. The amount of the royalty can vary by author, by book, and by edition
of the book.
NonKey Attributes
Primary Keys
Partial Dependencies: 32
33
Steps in Normalization: First Normal
Form 1NF
• Repeating groups happens when a single attribute contains data of
multiple entries with the same type.
• Removing repeating groups will reduce redundancies on a database
34
Steps in Normalization: 1NF
36
Steps in Normalization: 1NF Step 2
37
Steps in Normalization: 1NF Step 3
38
Steps in Normalization: Second Normal
Form 2NF
39
Steps in Normalization: Second Normal
Form 2NF
41
Steps in Normalization: 2NF Step 2
42
Steps in Normalization: Third Normal
Form 3NF
43
Steps in Normalization: Third Normal
Form 3NF
Steps to Third Normal Form:
Step 1. Remove all Step 2. Reassign
transitive dependencies dependency of
attributes
45
Steps in Normalization: 3NF Step 2
46
Example: Normalization Process
• The DreamHome Customer Rental Details form holds details about property rented by a given
customer. – To simplify things, we will assume that a renter rents a given property once and only
one property at a time.
47
Example: Normalization Process
48
Example: Normalization Process 1NF
Step 1
49
Example: Normalization Process 1NF
Step 2
Step 1: All repeating groups must be removed
50
Example: Normalization Process 1NF
Step 3
Step 1: All repeating groups must be removed
Step 2: A Primary key must be determined
51
52
Partial Dependencies
Transitive Dependency
CustNo PropNo RntSt RntFnsh CustNo CName PropNo PAddr Rent OwnerNo OName
53
Example: Normalization Process 2NF
Step 1
• Step 1: Make New Tables to Eliminate Partial Dependencies.
54
Example: Normalization Process 2NF
Step 2
Step 2: Reassign Corresponding Dependent Attributes
Rentals Table
Customer Table
55
Transitive Dependency
Example: Normalization Process 3NF
56
CustNo CName
Example: Normalization Process 3NF
58
Normalization and Denormalization
60