3. Normalization
Normalization is the process of organizing data to minimize data redundancy (data duplication)
If same piece of information is stored more than once, it is called redundant information
The goal of normalization is to decompose relations with anomalies in order to produce smaller and well-
structured tables
Normalization theory is based on functional dependencies
The most commonly used normal forms: First normal form(1NF), Second normal form(2NF), Third normal
form(3NF)
.
3
ID Name Gende
r
Age DOB Street City Zip_Code Department_ID Department_Name
Department
Location
1000 Rasmus
Jensen
M 27 28-05-1990 strandvej 112 Hellerup 2910 098 BE-IT Lygten 16
Copenhagen
2400
1001 Sara
Victoria
F 19 07-10-1996 Løvstikkevej
500, st.
København S 2300 101 Multimedia design Lygten 16
DK 2400
Copenhagen
1003 Jens
Rasmusen
M 20 09-10-97 Langkærvej
22
København S 2300 098 BE-IT Lygten 16
DK 2400
Copenhagen
4. Anomalies
• Database anomalies refer to errors and inconsistencies in the database
• Anomalies have a negative effect on the process of inserting, deleting and modifying data
in the tables
It is important to remove these anomalies in order to perform different processing on the
tables without any problem
◼ http://slideplayer.com/slide/9705202/
4
ID Name Gender Age DOB Street City Zip_Code
Departme
nt_ID
Department_Nma
e
Department
Location
1000 Rasmus
Jensen
M 27 28-05-1990 strandvej 112 Hellerup 2910 098 BE-IT Lygten 16
DK 2400
Copenhagen
1001 Sara
Victoria
F 19 07-10-1996 Løvstikkevej 500, st. Københ
avn S
2300 101 Multimedia
design
Lygten 16
DK 2400
Copenhagen
1003 Jens
Rasmusen
M 20 09-10-97 Langkærvej
22
Københ
avn S
2300 098 BE-IT Lygten 16
DK 2400
Copenhagen
5. Functional Dependency
5
An FD is a relationship between an attribute "Y" and a determinant (1 or more other attributes) "X"
such that for a given value of a determinant the value of the attribute is uniquely defined.
(written X → Y) if, and only if, each X value is associated with exactly one Y value
X → Y
X is a determinant
X determines Y
Y is functionally dependent on X
Student_ ID Student_Name
1000 Rasmus Jensen
1001 Sara Victoria
1003 Jens Rasmusen
1004 Sara Victoria
1001 Rasmus Jesnsen
Student_ID Student_Name
Example: Student_ID determines Student_Name (or
Student_Name depends on Student_ID)
Each student has exactly one name, but the name could
be the name of many students. So Name does not
determine Student_ID
1005
Is student_name functionally
dependent on Student_ID?
6. First Normal Form
◼A table is said to be in First Normal Form (1NF) if
1. the data in each column be atomic. No multiple values, separated by comma
2. the table does not contain any repeating column groups
3. Identify each record uniquely using primary key
6
Department _Name Student_Name
BE_IT Rasums, Jens , Kim
Multimedia design Sara
It is not possible to INSERT, UPDATE, and DELETE
just one student
Department
_Name
Student_Name
BEIT Rasmus
BEIT Jens
BEIT Kim
Multimedia
design
Sara
Department
_Name
Student_Name1 Student_Name2 Student_Name3
BE_IT Rasmus Jens Kim
Multimedia
design
Sara
Student_ID
1000
1000
1001
1001
7. Exercise A (1NF)
7
Convert the following table into the first NormalForm
Product_Id Product_Name Category Price_1 Price_2 Price_3
200 Table Classic, Glas 708,67 800 932,50
205 Chair Modern, Wood 553,56 475,99
8. Exercise B(1NF)
8
Studentname ZIP_Code Town Course1 Course2 Course3 Course4 Course5 Course6 Course7
Mark Owen 02474 ARLINGTON English German
Mathematic
s Chemistry Gymnastics
Ann Owen 02201 BOSTON English
Mathematic
s Physics Gymnastics
Bill Gates 02474 ARLINGTON English German
Mathematic
s Chemistry Gymnastics Computing
Mark Owen 02201 BOSTON English German Design
Mathematic
s Chemistry Gymnastics Zen
Convert this table into the first NormalForm
9. Second normal form(2NF)
9
Is a table with a single primary key in 2NF?
A table is in 2NF if it is in 1NF and every non-primary key
(non-prime) attribute is fully functionally dependent on
the primary key (and not on a set of primary
keys/Composite Key )
If a table is not in 2NF, we will divide it into separate
tables (DECOMPOSE) each in 2NF by ensuring that
the primary key of each new relation functionally
determines all the attributes
Find out the non key fields which do not depend on
the whole primary key (partial functional dependency
column) and then place them in a separate table with
a copy of the primary key
Is not in second normal form
In second normal form
In second normal form
10. Decomposition-2NF
10
Lecture
r_ID
Lecturer_Name Gen
der
DOB Department_I
D
Department_N
ame
Street City Zip_Code
Head of
Department
100 Jesper
Frederiksen
M NULL 022 BEIT Lygten 16 København 2400 Ola Pukkii
101 Lars Thomasen M 09-10-1955 053 Datamatiker Lygten 37 København 2400 Annette Havkær
102 Kim juhl M NULL 022 BEIT Lygten 16 København 2400 Ola
Pukkii
103 Jens Rasmusen M 29-12-80 053 Datamatiker Lygten 37 København 2400 Annette Havkær
104 Tina Jensen F 15-03-1965 008 Design Guldbergsgade 29N København 2200 Mette
Harrestrup
11. Decomposition-2NF
11
Lecturer_ID Lecturer_Name Gender DOB
100 Jesper Frederiksen M NULL
101 Lars Thomasen M 09-10-1955
102 Kim juhl M NULL
103 Jens Rasmusen M 29-12-80
104 Tina Jensen F 15-03-1965
Department_ID Department_Name Street City Zip_Code Head of Department
022 BEIT Lygten 16 København 2400 Ola Pukkii
053 Datamatiker Lygten 37 København 2400 Annette Havkær
008 Design Guldbergsgade 29 København 2200 Mette Harrestrup
Department_ID
022
053
022
053
008
How to Find the Relationship
Between Two Tables?
MANY TO MANY??
12. Exercise C (2NF)
12
Convert the following table into the second NormalForm
S# STATUS CITY P# QTY
S1 20 London P1 300
S1 20 London P2 200
S1 20 London P3 400
S1 20 London P4 200
S1 20 London P5 100
S1 20 London P6 100
S2 10 Paris P1 300
S2 10 Paris P2 200
S3 10 Paris P2 200
S4 20 London P2 200
S4 20 London P4 200
S4 20 London P5 100
13. Exercise D (2NF)
13
Provider ID DiagnonisCode DiagnonisDescrip
tion
ServiceLocationI
D
ServiceCity ServiceState ServiceDate
8472 798 Fever 354 St.Louis MO 20-03-2015
8427 678 Hypertension 278 KirkWood MA 10-03-2015
1928 798 Fever 452 Austin TX 10-09-08
1928 536 Stomach Gas 867 Kyle TX 78-01-02
◼Convert the following table into the second NormalForm
14. Third normal form(3NF)
14
A table is in 2NF if
I. It is in 1NF
II. All nonprimary fields are dependent
on the primary key OR
Nonprimary key attributes don’t
depend on other nonprimary key
attributes OR
No transitive functional dependencies
between two non-keys attributes
A B (B A)
B C
A C
15. Example-Third normal form(3NF)
15
Department_ID Department_Name Street City Zip_Code
022 BEIT Lygten 16 København NV 2400
014 Construction Management Guldbergsgade 29 København N 2200
020 Multimedia Lygten 16 København NV 2400
053 Tech Landskronagade 64 København Ø 2100
002 Datamatiker Lygten 37 København NV 2400
008 Design Guldbergsgade 29 København N 2200
A B (B A)
Department_ID City City Department_ID
B C
City Zip_Code
A C
Department_ID Zip_Code
16. Decomposition-3NF
16
Decompose tables(s) to eliminate transitive functional dependencies
Move all columns involved in transitive dependencies to a new table
Identify a primary key for the new entity.
Place the primary key for the new table as a foreign key on the original table
Department_ID Department_Name Street
022 BEIT Lygten 16
014 Construction Management Guldbergsgade 29
020 Multimedia Lygten 16
053 Tech Landskronagade 64
002 Datamatiker Lygten 37
008 Design Guldbergsgade 29
City Zip_Code
København NV 2400
København N 2200
København Ø 2100
Zip_Code
2400
2200
2400
2100
2400
2200
All transitive dependencies are
removed to place in another
table
17. Exercise E (3NF)
17
◼Convert the following table into the third NormalForm
Cutomer_ID Customer_FirstName Customer_LastName Customer_DOB AccNO BankCode Bank
1002 Helle Allamn 09-10-1978 100987654 9090 BOA
1003 Chad Herlof 12-12-1950 100987655 9090 BOA
1004 Ken Rasmusen 01-08-1999 100987656 8920 CAPITA1
1005 Tina Borup 29-06-1970 100987657 8920 CAPITAL1
20. Summary
20
FIRST NORMAL FORM
(1NF)
No repeating values and
No repeating groups
Specify primary key
SECOND NORMAL FORM
(2NF)
No non-key values based on
just part of a composite key
Third NORMAL FORM
(3NF)
No non-key values based on
other non-key values
https://www.youtube.com/watch?v=UrYLYV7WSHM