Unit I Normalization
Unit I Normalization
Unit I Normalization
Mr.V.Yuvaraj
Assistant Professor – Department of Computer Applications
Dr. N.G.P. ARTS AND SCIENCE COLLEGE
Dr. N.G.P.-KALAPATTI ROAD
COIMBATORE-641 048
Tamil Nadu, India
Mobile: +917502919891,
E-mail: [email protected]
Dr. NGPASC
COIMBATORE | INDIA
Objective
Dr. NGPASC
COIMBATORE | INDIA
Normalization
A large database defined as a single relation may
result in data duplication.
This repetition of data may result in:
• Making relations very large.
• It isn't easy to maintain and update data as it would
involve searching many records in relation.
• Wastage and poor utilization of disk space and
resources.
• The likelihood of errors and inconsistencies increases.
Dr. NGPASC
COIMBATORE | INDIA
What is Normalization?
• Normalization is the process of organizing the data in
the database.
• Normalization is used to minimize the redundancy
from a relation or set of relations. It is also used to
eliminate undesirable characteristics like Insertion,
Update, and Deletion Anomalies.
•Normalization divides the larger table into smaller and
links them using relationships.
•The normal form is used to reduce redundancy from
the database table.
Dr. NGPASC
COIMBATORE | INDIA
Data modification anomalies can be
categorized into three types:
Data modification anomalies can be categorized into
three types:
•Insertion Anomaly: Insertion Anomaly refers to when
one cannot insert a new tuple into a relationship due to
lack of data.
•Deletion Anomaly: The delete anomaly refers to the
situation where the deletion of data results in the
unintended loss of some other important data.
•Updatation Anomaly: The update anomaly is when an
update of a single data value requires multiple rows of
data to be updated.
Dr. NGPASC
COIMBATORE | INDIA
Types of Normal Forms:
Dr. NGPASC
COIMBATORE | INDIA
First Normal From
• For a library
Dr. NGPASC
COIMBATORE | INDIA
1-NF Solution
Dr. NGPASC
COIMBATORE | INDIA
Example
• For an airline
Flight Weekdays
UA59 Mo We Fr
UA73 Mo Tu We Th Fr
Dr. NGPASC
COIMBATORE | INDIA
1NF Solution
Flight Weekday
UA59 Mo
UA59 We
UA59 Fr
UA73 Mo
UA73 We
… …
Dr. NGPASC
COIMBATORE | INDIA
Example
• Book table
BookNo Title Author Year
B1 Moby Dick H. Melville 1851
B2 Lincoln G. Vidal 1984
Dr. NGPASC
COIMBATORE | INDIA
Why it matters
• table Borrowed Books
Dr. NGPASC
COIMBATORE | INDIA
Example
Dr. NGPASC
COIMBATORE | INDIA
2NF Solution
Dr. NGPASC
COIMBATORE | INDIA
Third Normal Form
Dr. NGPASC
COIMBATORE | INDIA
Example
• Table BorrowedBooks
BookNo Patron Address Due
B1 J. Fisher 101 Main Street 3/2/15
B2 L. Perez 202 Market Street 2/28/15
Dr. NGPASC
COIMBATORE | INDIA
3NF Solution
Patron Address
J. Fisher 101 Main Street
L. Perez 202 Market Street
Dr. NGPASC
COIMBATORE | INDIA
Another example
• Tournament winners
Tournament Year Winner DOB
Indiana Invitational 1998 Al Fredrickson 21 July 1975
Dr. NGPASC
COIMBATORE | INDIA
Example
Manager Project Branch
Alice Alpha Austin
Alice Delta Austin
Carol Alpha Houston
Dean Delta Houston
• We can assume
– Manager → Branch
– {Project, Branch} → Manager
Dr. NGPASC
COIMBATORE | INDIA
Example
Manager Project Branch
Alice Alpha Austin
Bob Delta Houston
Carol Alpha Houston
Alice Delta Austin
Dr. NGPASC
COIMBATORE | INDIA
Fourth Normal Form
Dr. NGPASC
COIMBATORE | INDIA
Example from Wikipedia
Dr. NGPASC
COIMBATORE | INDIA
Discussion
Dr. NGPASC
COIMBATORE | INDIA
4NF Solution
Restaurant DeliveryArea
Pizza Milano SW Houston
Pizza Firenze NW Houston
Pizza Milano NW Houston
• Two separate tables
Restaurant Pizza
Pizza Milano Thin crust
Pizza Milano Thick crust
Pizza Firenze Thin crust
Pizza Firenze Thick crust
Dr. NGPASC
COIMBATORE | INDIA
Fifth normal form
Dr. NGPASC
COIMBATORE | INDIA
An example
Dr. NGPASC
COIMBATORE | INDIA
The result of the join
• Introduces
Dr. NGPASC
COIMBATORE | INDIA
two spurious tuples
A different table
Dr. NGPASC
COIMBATORE | INDIA
The result of the join
Store Brand
Circuit City Apple
Circuit City Toshiba
CompUSA
Dr. NGPASC
COIMBATORE | INDIA
Apple
Conclusion
Dr. NGPASC
COIMBATORE | INDIA
Normalisation Example
• First decomposition
– First table
Order Product Quantity UnitPrice
– Second table
Order Customer Address
Dr. NGPASC
COIMBATORE | INDIA
2NF Solution (II)
• Second decomposition
– First table
Order Product Quantity
– Second table
Product UnitPrice
Dr. NGPASC
COIMBATORE | INDIA
3NF
• In second table
Order Customer Address
– Customer Address
• Split second table into
Order Customer
Dr. NGPASC
Customer Address
COIMBATORE | INDIA
Normalisation to 2NF
Dr. NGPASC
COIMBATORE | INDIA
Normalisation to 2NF
Dr. NGPASC
COIMBATORE | INDIA
Normalisation to 3NF
Dr. NGPASC
COIMBATORE | INDIA
Normalisation
• 1NF:
– {Order, Product, Customer, Address, Quantity, UnitPrice}
• 2NF:
– {Order, Customer, Address}, {Product, UnitPrice}, and
{Order, Product, Quantity}
• 3NF:
– {Product, UnitPrice}, {Order, Product, Quantity},
{Order, Customer}, and {Customer, Address}
Dr. NGPASC
COIMBATORE | INDIA
Dr. NGPASC
COIMBATORE | INDIA 51