Normalization sparkling beelzebub
-
Upload
hassan-ahmed -
Category
Software
-
view
29 -
download
0
Transcript of Normalization sparkling beelzebub
Normalization
The biggest problem needed to be solved in database is data redundancy.
Why data redundancy is the problem? Because it causes:
Insert Anomaly
Update Anomaly
Delete Anomaly
Normalization is the process of removing redundant data from your tables to
improve storage efficiency, data integrity, and scalability.
Normalization generally involves splitting existing tables into multiple ones,
which must be re-joined or linked each time a query is issued.
Why normalization?
The relation derived from the user view or data store will most likely be
unnormalized.
The problem usually happens when an existing system uses unstructured
file, e.g. in MS Excel.
Steps of Normalization First Normal Form (1NF)
Second Normal Form (2NF)
Third Normal Form (3NF)
Boyce-Codd Normal Form (BCNF)
Fourth Normal Form (4NF)
Fifth Normal Form (5NF)
In practice, 1NF, 2NF, and 3NF are enough for database
SCENERIO HERE WE ARE GOING TO DESCRIBE THE PATIENT DATA BASE,IT WILL ILLUSTRATE THE RELATION
SHIPS,DEPENDECIES AND COMPLEXITY OF UN NORMALIZED FORMS.
ONLY TABLE OF A SINGLE PATIENT WITH ATTRIBUTES IS SHOWN HERE FOR THE SAKE OF UNDERSTANDING.
First Normal Form (1NF) The official qualifications for 1NF are:
1. Each attribute name must be unique.
2. Each attribute value must be single.
3. Each row must be unique.
4. There is no repeating groups.
Additional:
Choose a primary key.
Reminder:
A primary key is unique, not null, unchanged. A primary key can be either
an attribute or combined attributes.
EXAMPLE
It violates the 1NF because:
Attribute values are not single.
Repeating groups exists.
NF-1 TABLE GIVEN BELOW
ID Name Gender Department Disease Zip City State Street Age D.O Admission D.O.Discharge
1321 Saeed-ur-Rasheed Male Pathology Kidney 64200 R.Y.K Pakistan 1 23 8/12/2014 12/12/2018
1321 Saeed-ur-Rasheed Male Pathology Stomach 64200 R.Y.K Pakistan 1 23 8/12/2014 12/12/2018
1308 Ali Raza Male Emergency Scratches 64200 R.Y.K Pakistan 14 20 8/12/2016 10/12/2016
1333 M.Yousaf Male Emergency Wounds 64200 R.Y.K Pakistan 233 18 8/12/2014 10/12/2014
1319 Salman Majeed Male Aansoo Lake I think Fracture ha 64200 R.Y.K Pakistan 123 28 4/8/2016 4/8/2025
1319 Salman Majeed Male Aansoo Lake Laat toot gai 64200 R.Y.K Pakistan 123 28 4/8/2016 4/8/2025
ID Name Gender Department Disease Zip City State Street Age D.O
Admission D.O.Discharge
1321 Saeed-ur-Rasheed Male Pathology Kidney,Stomach 64200 R.Y.K Pakistan 1 23 8/12/2014 12/12/2018
1308 Ali Raza Male Emergency Scratches 64200 R.Y.K Pakistan 14 20 8/12/2016 10/12/2016
1333 M.Yousaf Male Emergency Wounds 64200 R.Y.K Pakistan 233 18 8/12/2014 10/12/2014
1319 Salman Majeed Male Aansoo Lake I think Fracture ha,Laat toot gai 64200 R.Y.K Pakistan 123 28 4/8/2016 4/8/2025
The official qualifications for 2NF are:
1. A table is already in 1NF.
2. All non-key attributes are fully dependent on the primary key.
All partial dependencies are removed to place in another table.
Second Normal Form (2NF)
ID Name Gender Department Disease Zip City State Street D.O
Admission D.O.Discharge
1321 Saeed-ur-Rasheed Male Pathology Kidney 64200 R.Y.K Pakistan 1 8/12/2014 12/12/2018
1321 Saeed-ur-Rasheed Male Pathology Stomach 64200 R.Y.K Pakistan 1 8/12/2014 12/12/2018
1308 Ali Raza Male Emergency Scratches 64200 R.Y.K Pakistan 14 8/12/2016 10/12/2016
1333 M.Yousaf Male Emergency Wounds 64200 R.Y.K Pakistan 233 8/12/2014 10/12/2014
1319 Salman Majeed Male Aansoo Lake I think Fracture ha 64200 R.Y.K Pakistan 123 4/8/2016 4/8/2025
1319 Salman Majeed Male Aansoo Lake Laat toot gai 64200 R.Y.K Pakistan 123 4/8/2016 4/8/2025
AGE TABLE
Name Age
Saeed-ur-Rasheed 23
Ali Raza 20
M.Yousaf 18
Salman Majeed 28
The official qualifications for 3NF are:
1. A table is already in 2NF.
2. Nonprimary key attributes do not depend on other nonprimary key
attributes (i.e. no transitive dependencies)
All transitive dependencies are removed to place in another table.
Third Normal Form (3NF)
ID Name Gender Departement Disease Zip City State Street D.O
Admission D.O.Discharge
1321 Saeed-ur-Rasheed Male Pathology Kidney 64200 R.Y.K Pakistan 1 8/12/2014 12/12/2018
1321 Saeed-ur-Rasheed Male Pathology Stomach 64200 R.Y.K Pakistan 1 8/12/2014 12/12/2018
1308 Ali Raza Male Emergency Scratches 64200 R.Y.K Pakistan 14 8/12/2016 10/12/2016
1333 M.Yousaf Male Emergency Wounds 64200 R.Y.K Pakistan 233 8/12/2014 10/12/2014
1319 Salman Majeed Male Aansoo Lake I think Fracture ha 64200 R.Y.K Pakistan 123 4/8/2016 4/8/2025
1319 Salman Majeed Male Aansoo Lake Laat toot gai 64200 R.Y.K Pakistan 123 4/8/2016 4/8/2025
AGE TABLE
Name Age
Saeed-ur-Rasheed 23
Ali Raza 20
M.Yousaf 18
Salman Majeed 28
DISEASE TABLE
ID Departement Disease
1321 Pathology Kidney
1321 Pathology Stomach
1308 Emergency Scratches
1333 Emergency Wounds
1319 Aansoo Lake I think Fracture ha
1319 Aansoo Lake Laat toot gai
ADDRESS TABLE
ID Zip City State Street
1321 64200 R.Y.K Pakistan 1
1308 64200 R.Y.K Pakistan 14
1333 64200 R.Y.K Pakistan 233
1319 64200 R.Y.K Pakistan 123
FINALIZED 3NF TABLE
ID Name Gender Zip
1321 Saeed-ur-Rasheed Male 64200
1308 Ali Raza Male 64200
1333 M.Yousaf Male 64200
1319 Salman Majeed Male 64200