Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views

Normalization (mysql)

Normalization ( mysql )

Uploaded by

kmyozaw.dev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Normalization (mysql)

Normalization ( mysql )

Uploaded by

kmyozaw.dev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.1.

Normalization

1.1.1. Introduction to Normalization


Normalization is the process of evaluating and restructuring the logical data model of a
database to eliminate or minimize redundancy, organize data efficiently in order to
reduce repeating data and to reduce the likelihood of data anomalies. It may also
improve data consistency and simplify future extension of the logical data model.
Normalization process through a series of stage called normal forms (NF) and most of
rhetorical books of the database discuss the stage as below:

 First normal form (1NF) lays the groundwork for an organized database design:
1. Ensure that each table has a primary key: minimal set of attributes which can
uniquely identify a record.
2. Eliminate repeating groups (categories of data which would seem to be required
a different number of times on different records) by defining keyed and non-
keyed attributes appropriately.
3. Atomicity: Each attribute must contain a single value, not a set of values.
 Second normal form (2NF) If a table has a composite key, all attributes must be
related to the whole key:
1. The database must meet all the requirements of the first normal form.
2. Data which is redundantly duplicated across multiple rows of a table is moved
out to a separate table.
 Third normal form (3NF) requires that data stored in a table be dependent only on
the primary key, and not on any other field in the table:
1. The database must meet all the requirements of the second normal form.
2. Any field which is dependent not only on the primary key but also on another
field is moved out to a separate table.
1.1.2. Normalization Process
The figure below illustrates how original form (or data model) go through the
normalization process such as 1NF, 2NF and 3NF:

Original Repeated elements


Form

Eliminate
repeating
groups

1NF

Functional
Primary Key Move out to
Dependence
separate table

2NF

Functional
Primary Dependence Move out to
Key separate table

3NF

Figure 1 – Process original form to 1NF, 2NF and 3NF

Table below is a sample original form for sales orders that is to go through the
normalization process. An attribute with underline represents the primary key of the form.
Table 1 - Sample original form
Order Order Date Customer Customer Customer Product ID Product ID Product ID
Number ID Name Address Product Product Product
Quantity Quantity Quantity
Unit Price Unit Price Unit Price
1 10/01/2007 1 ABC Yangon A01 B99 C01
Pencil Notebook Eraser S
5 1 3
20 95 50
2 31/01/2007 2 XYZ Bagan C01 C02 C03
Eraser S Eraser M Eraser L
1 1 1
50 60 80
3 31/01/2007 1 ABC Yangon A01
Pencil
1
20

(1) First Normal Form (1NF)


Eliminate repeating group of order detailed information by splitting into four attributes
such as Product ID, Product, Quantity and Unit Price as shown in Table below:

Table 2 - 1NF
Order Order Date Customer Customer Customer Product Product Quantity Unit
Number ID Name Address ID Price
1 10/01/2007 1 ABC Yangon A01 Pencil 5 20
1 10/01/2007 1 ABC Yangon B99 Notebook 1 95
1 10/01/2007 1 ABC Yangon C01 Eraser S 3 50
2 31/01/2007 2 XYZ Bagan C01 Eraser S 1 50
2 31/01/2007 2 XYZ Bagan C02 Eraser M 1 60
2 31/01/2007 2 XYZ Bagan C03 Eraser L 1 80
3 31/01/2007 1 ABC Yangon A01 Pencil 1 20
(2) Second Normal Form (2NF)
Remove functional dependences for the primary key (Order Number and Product ID)
attributes to separate tables such as Order, Order Details and Product tables as shown in
Table below:

Table 3 - 2NF
Order
Order Order Date Customer Customer Customer
Number ID Name Address
1 10/01/2007 1 ABC Yangon
2 10/01/2007 2 XYZ Bagan

Order Details (2NF to be continued…)


Order Product ID Quantity Unit Price
Number

1 A01 5 20
1 B99 1 95
1 C01 3 50
2 C01 1 50
2 C02 1 60
2 C03 1 80
3 A01 1 20

Order Details
Order Product ID Quantity
Number
1 A01 5
1 B99 1
1 C01 3
2 C01 1
2 C02 1
2 C03 1
3 A01 1

Product
Product Product Unit Price
ID

A01 Pencil 20
B99 Note 95
C01 Eraser S 50
C02 Eraser M 60
C03 Eraser L 80
(3) Third Normal Form (3NF)
Remove functional dependences for non-primary key (Order Number and Product ID)
attributes to separate tables such as Customer as shown in Table below:

Table 4 - 3NF
Order
Order Order Customer
Number Date ID
1 10/01/2007 1
2 10/01/2007 2

Order Details
Order Product ID Quantity
Number

1 A01 5
1 B99 1
1 C01 3
2 C01 1
2 C02 1
2 C03 1
3 A01 1

Product
Product Product Unit Price
ID

A01 Pencil 20
B99 Note 95
C01 Eraser S 50
C02 Eraser M 60
C03 Eraser L 80

Customer
Customer Customer Customer
ID Name Address
1 ABC Yangon

2 XYZ Bagan
1.1.3. Normalization and Database Design
Relational database model based on the normalization process will be described as
shown in Figure below:

Order Order Number Order Date Customer ID

Order Detail Order Number Product ID Quantity

Product Product ID Order Number Order Number

Customer Customer ID Customer Name Customer Address

Primary Key:
Foreign Key:

Figure 2 - Relational Database Model

You might also like