Lesson 02 Database Normalization
Lesson 02 Database Normalization
Chapter 2 – Normalization
www.belgiumcampus.ac.za
Learning Objectives
• At the end of this chapter, students should be able to:
• Define Normalization
2
www.belgiumcampus.ac.za
What is Normalization?
• Normalization is the process of efficiently organizing data in a database.
2. Ensuring data dependencies make sense (only storing related data in a table).
• Both of these are worthy goals as they reduce the amount of space a database consumes and
ensure that data is logically stored.
3
www.belgiumcampus.ac.za
Benefits of Normalization
• Normalizing your database ensures the following three things:
1. Dependencies between data are identified. This means that you will be able to see which tables and fields
depend on which other tables and fields.
2. Redundant data (and all the related problems associated with it) is minimized.
4
www.belgiumcampus.ac.za
Levels of normalization
There are 4 common forms of database normalization:
5
www.belgiumcampus.ac.za
Zero Normal Form
• Zero normal form
• is the first step in any normalization process.
• It states that:
• All the data(attributes/columns) in the database need to be listed .
6
www.belgiumcampus.ac.za
A student-degree relationship
FirstName
LastName
MiddleInitial
BillingAddress1
BillingAddress2
BillingCity
BillingProvince
BillingPostCode
HostelName
HostelStreet
HostelPhone
HostalRoomNumber
DegreeName
DegreeWhenEarned
DegreeInProgress
7
www.belgiumcampus.ac.za
First Normal Form
• 1st Normal Form sets very basic rules for the database as follows:
• It eliminates duplicate columns from the same table.
• Create separate tables for each group of related data and identify each row with a unique
column (the primary key).
• NB : To discover a violation of first normal form, look at each attribute for an entity and
ask yourself whether the attribute occurs repeatedly for any particular instance of this
entity. If the occurrence is repeated then you must correct the 1NF violation.
• Definition:
• An entity is in the first normal form if it contains no repeating groups.
8
www.belgiumcampus.ac.za
Grouping of data
FirstName
…
DegreeName1
DegreeWhenEarned1
DegreeInProgress1
DegreeName2
DegreeWhenEarned2
DegreeInProgress2
…
9
www.belgiumcampus.ac.za
10
www.belgiumcampus.ac.za
Second Normal Form
• Second normal form (2NF) further addresses the concept of removing duplicate data:
• Meet all the requirements of the first normal form.
• Remove subsets of data that apply to multiple rows of a table and place them in separate
tables.
• Create relationships between these new tables and their predecessors through the use of
foreign keys.
• Note: Important, to make this easier, when you take a database from the first normal
form to the second normal form, you work on the new table you just created.
• Definition: A relationship is in the second normal form (2NF) if it is in the first normal
form, and all of its attributes depend on the whole primary key.
11
www.belgiumcampus.ac.za
12
www.belgiumcampus.ac.za
Third Normal Form
• There are two basic requirements for a database to be in third normal form:
• Already meet the requirements of both 1NF and 2NF
• Remove columns that are not fully dependent upon the primary key.
Definition: A relationship is in the third normal form (3NF) if all the attributes
are non-transitively dependent on the primary key.
13
www.belgiumcampus.ac.za
14
www.belgiumcampus.ac.za
THANK YOU
/belgiumcampusSA
#Belgium Campus
15
www.belgiumcampus.ac.za