Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
CHAPTER 4
NORMALIZATION

Dr.Girija Narasimhan

1
WHAT IS NORMALIZATION
Break down
Inconsistency It is the process of decomposing relation with
or
anomalies into small rela...
INSERT ANOMALY
The primary key for this table is the combination of Emp_ID and Course_Title

EmpId
100
100
140
110
110
150...
UPDATE ANOMALY
EmpId 150 has two records, the salary as 4200

EmpId
100
100
140
110
110
150
150

Ename
Ali
Ali
Said
ahmed
...
DELETE ANOMALY
EmpId
100
100
140
110
110
150
150

Ename
Ali
Ali
Said
ahmed
ahmed
Khalid
khalid

DeptName
Marketting
Market...
Exercise 1- Anomaly
Apply insert, update, delete anomaly for the given
below table
Passenger

Passenger

ID

Name

101

Al...
Exercise 2- Anomaly
Apply insert, update, delete anomaly for the given
below table
Accno

Accounttype

date_acct-

Opened
...
NORMALIZATION
Student Name Date
ID
of
Birth

Adviso Advisor
rID
Name

Advisor CourseID
Phone

Course
Name

Credit
Hrs

Mul...
First Normal Form (1NF)
Adjust the table to have one value in each cell
Separate the repeating group fields into a separat...
Second Normal Form (2NF)
1NF → 2NF

Partial functional dependency

Find out the non key fields which do not depend on the ...
2NF → 3NF

Third Normal Form (3NF)

Transitive dependency: A relationship between two (or more) nonkey attributes
For each...
Dr.Girija Narasimhan

12
Dr.Girija Narasimhan

13
1NF Tables: Repeating Attributes Removed
Project table
Project Code

Project Title

Project Manager

Project Budget

PC010...
2NF Tables: Partial Key Dependencies Removed
Project table
Project
Code

Project Title

Project
Manager

Project
Budget

P...
Project table
Project
Code

Project Title

Project
Manager

Project
Budget

PC010

Pensions System

M Phillips

24500

PC0...
Project table

3NF Tables: Non-Key Dependencies Removed
Employee table

Project
Code

Project Title

Project
Manager

Proj...
Upcoming SlideShare
Loading in …5
×

normalization

1,367 views

Published on

normalization, inser anomaly, delete anomaly, update anomaly,funcational dependency

Published in: Education
  • Be the first to like this

normalization

  1. 1. CHAPTER 4 NORMALIZATION Dr.Girija Narasimhan 1
  2. 2. WHAT IS NORMALIZATION Break down Inconsistency It is the process of decomposing relation with or anomalies into small relations abnormal Why? Ensuring Data Integrity Remove Data Redundancy Satisfies all integrity constraints Domain integrity, entity integrity constraints, referential integrity constraints Prevent insert,delete,update anomaly. Since, the data is only available in one table in the database Dr.Girija Narasimhan 2
  3. 3. INSERT ANOMALY The primary key for this table is the combination of Emp_ID and Course_Title EmpId 100 100 140 110 110 150 150 Ename Ali Ali Said ahmed ahmed Khalid khalid DeptName Marketting Marketting Accounting Infosystem Infosystem Marketting Marketting Salary 4800 4800 5200 4300 4300 4200 4200 Course_Title SPSS Surveys Tax Acc Visual Basic C++ SPSS Java Date_Completed 6/19/2011 10/7/2011 12/8/2011 1/12/2011 4/22/2011 6/19/2011 8/12/2011 Because, in the new record empid is available but course_title is Null. As per entity integrity rule primary key must have not null value. EmpId 100 Ename Ali DeptName Marketting Salary 4800 Course_Title Date_Completed Null 6/19/2011 This is insert anomaly Dr.Girija Narasimhan 3
  4. 4. UPDATE ANOMALY EmpId 150 has two records, the salary as 4200 EmpId 100 100 140 110 110 150 150 Ename Ali Ali Said ahmed ahmed Khalid khalid DeptName Marketting Marketting Accounting Infosystem Infosystem Marketting Marketting Salary 4800 4800 5200 4300 4300 4200 4200 Course_Title SPSS Surveys Tax Acc Visual Basic C++ SPSS Java Date_Completed 6/19/2011 10/7/2011 12/8/2011 1/12/2011 4/22/2011 6/19/2011 8/12/2011 Once record change the salary as 4500 and another record missed for updating the changes is called update anomaly EmpId 150 150 Ename Khalid khalid DeptName Marketting Marketting Salary 4200 4500 Course_Title Date_Completed SPSS 6/19/2011 Java 8/12/2011 This is update anomaly Dr.Girija Narasimhan 4
  5. 5. DELETE ANOMALY EmpId 100 100 140 110 110 150 150 Ename Ali Ali Said ahmed ahmed Khalid khalid DeptName Marketting Marketting Accounting Infosystem Infosystem Marketting Marketting Salary 4800 4800 5200 4300 4300 4200 4200 Course_Title SPSS Surveys Tax Acc Visual Basic C++ SPSS Java Date_Completed 6/19/2011 10/7/2011 12/8/2011 1/12/2011 4/22/2011 6/19/2011 8/12/2011 Suppose delete empid 140, it also delete the course_title and date_completed also. EmpId 140 Ename Said DeptName Salary Accounting 5200 Course_Title Date_Completed Tax Acc 12/8/2011 Dr.Girija Narasimhan 5
  6. 6. Exercise 1- Anomaly Apply insert, update, delete anomaly for the given below table Passenger Passenger ID Name 101 Ali Sohar AI977 Muscat 101 Ali Sohar AI976 Hyderabad Muscat 102 Rahman Muscat WY899 Muscat 102 Rahman Muscat AI976 Address FlightI Origin Destination PilotID D Pilot Fare Name Hyderbad Dr.Girija Narasimhan Hyderabad AIP10 Raja 30 AIP12 Kiran 34 Riyad WYP10 Said 28 Muscat AIP11 Ram 30 6
  7. 7. Exercise 2- Anomaly Apply insert, update, delete anomaly for the given below table Accno Accounttype date_acct- Opened Manager Manager ID cid cname balance Name 100 loan 21-10-2011 1 alia 100 10 shaik 101 saving 28-10-2011 1 alia 200 10 shaik 102 current 30-10-2011 1 alia 100 20 ali 103 loan 25-10-2011 2 fatma 100 10 shaik 104 current 30-10-2011 2 fatma 200 30 saeed Dr.Girija Narasimhan 7
  8. 8. NORMALIZATION Student Name Date ID of Birth Adviso Advisor rID Name Advisor CourseID Phone Course Name Credit Hrs Multimedia 6 Passin g Grade Std Mark D 60 S01234 Ali 5/7/90 11 Mr. Aijaz 123 ITSE1100 S01234 Ali 5/7/90 11 Mr. Aijaz 123 ITNT1103 Hardware 5 C 70 S01234 Ali 5/7/90 11 Mr. Aijaz 123 ITDB1102 Database 5 C 50 S01235 Said 6/5/89 12 Ms. Aysha 124 ITSE1100 Multimedia 6 D 70 S01235 Said 6/5/89 12 Ms. Aysha 124 ITNT1103 Hardware C 80 5 Repeating data (Data Redundancy) Adjust the table to have one value in each cell Separate the repeating group fields into a separate table Determine the primary keys and foreign keys in each table Provide the link between primary key and foreign key Dr.Girija Narasimhan 8
  9. 9. First Normal Form (1NF) Adjust the table to have one value in each cell Separate the repeating group fields into a separate table. Student table StudentID Date of Birth AdvisorID Advisor Name Advisor Phone No S01234 Ali 5/7/90 11 Mr. Aijaz 123 S01235 Primary key Name Said 6/5/89 12 Ms. Aysha 124 Create the another table name as “student-course table” and keep all the remaining attributes Student –course table StudentID Composite primary key Course Name Credit Hrs Passing Grade Std Mark S01234 ITSE1100 Multimedia 6 D 60 S01234 S01234 Foreign key CourseID ITNT1103 ITDB1102 Hardware Database 5 5 C C 70 50 S01235 ITSE1100 Multimedia 6 D 70 S01235 ITNT1103 Hardware 5 C 80 Dr.Girija Narasimhan 9
  10. 10. Second Normal Form (2NF) 1NF → 2NF Partial functional dependency Find out the non key fields which do not depend on the whole primary key (partial functional dependency column)and place them in a separate table with a link Course table CourseID ITSE1100 Course Name Multimedia Credit Hours 6 Passing grade D ITNT1103 Hardware 5 C ITDB1102 Database 5 C Student –course table StudentID S01234 S01234 S01234 S01234 S01235 S01235 CourseID ITSE1100 ITNT1103 ITDB1102 ITDB1102 ITSE1100 ITNT1103 Std Mark 60 70 50 70 70 80 Dr.Girija Narasimhan 10
  11. 11. 2NF → 3NF Third Normal Form (3NF) Transitive dependency: A relationship between two (or more) nonkey attributes For each non key attribute (or set of attributes) that is a determinant in a relation, create a new relation. That attribute (or set of attributes) becomes the primary key of the new relation Foreign key Course Table CourseID StudentI D S01234 S01235 Name Ali Said Date of Birth 5/7/90 6/5/89 11 12 Advisor table AdvisorI D 11 12 Advisor Advisor Phone No Name Mr. Aijaz 123 Ms.Aysha 124 ITSE1100 Passing grade D Hardware 5 C ITDB1102 AdvisorID Course Credit Name Hours Multimedia 6 ITNT1103 Student table Database 5 C Student –course table StudentID S01234 S01234 S01234 S01234 S01235 S01235 Dr.Girija Narasimhan CourseID ITSE1100 ITNT1103 ITDB1102 ITDB1102 ITSE1100 ITNT1103 Std Mark 60 70 50 70 70 80 11
  12. 12. Dr.Girija Narasimhan 12
  13. 13. Dr.Girija Narasimhan 13
  14. 14. 1NF Tables: Repeating Attributes Removed Project table Project Code Project Title Project Manager Project Budget PC010 Pensions System M Phillips 24500 PC045 Salaries System H Martin 17400 PC064 HR System K Lewis 12250 Employee table Project Code Employee No. Employee Name Department No. Department Name Hourly Rate PC010 S10001 A Smith L004 IT 22.00 PC010 S10030 L Jones L023 Pensions 18.50 PC010 S21010 P Lewis L004 IT 21.00 PC045 S10010 B Jones L004 IT 21.75 PC045 S10001 A Smith L004 IT 18.00 PC045 S31002 T Gilbert L028 Database 25.50 PC045 S13210 W Richards L008 Salary 17.00 PC064 S31002 T Gilbert L028 Database 23.25 PC064 S21010 P Lewis L004 IT 17.50 PC064 S10034 B James L009 HR 16.50 Dr.Girija Narasimhan 14
  15. 15. 2NF Tables: Partial Key Dependencies Removed Project table Project Code Project Title Project Manager Project Budget PC010 Pensions System M Phillips 24500 PC045 Salaries System H Martin 17400 PC064 HR System K Lewis 12250 Employee table Employee-project table Project Code Employee No. Hourly Rate PC010 S10001 22.00 PC010 S10030 18.50 PC010 S21010 21.00 PC045 S10010 21.75 PC045 S10001 PC045 Employee Employee No. Name Department No. Department Name S10001 A Smith L004 IT S10030 L Jones L023 Pensions S21010 P Lewis L004 IT 18.00 S10010 B Jones L004 IT S31002 25.50 S31002 T Gilbert L028 Database PC045 S13210 17.00 S13210 W Richards L008 Salary PC064 S31002 23.25 S10034 B James L009 HR PC064 S21010 17.50 PC064 S10034 16.50 Dr.Girija Narasimhan 15
  16. 16. Project table Project Code Project Title Project Manager Project Budget PC010 Pensions System M Phillips 24500 PC045 Salaries System H Martin 17400 PC064 HR System K Lewis 12250 Employee table Employee-project table Project Code Employee No. Hourly Rate PC010 S10001 22.00 PC010 S10030 18.50 PC010 S21010 21.00 PC045 S10010 21.75 PC045 S10001 PC045 Employee Employee No. Name Department No. Department Name S10001 A Smith L004 IT S10030 L Jones L023 Pensions S21010 P Lewis L004 IT 18.00 S10010 B Jones L004 IT S31002 25.50 S31002 T Gilbert L028 Database PC045 S13210 17.00 S13210 W Richards L008 Salary PC064 S31002 23.25 S10034 B James L009 HR PC064 S21010 17.50 PC064 S10034 16.50 Dr.Girija Narasimhan 16
  17. 17. Project table 3NF Tables: Non-Key Dependencies Removed Employee table Project Code Project Title Project Manager Project Budget Employee No. Employee Name PC010 Pensions System M Phillips 24500 S10001 A Smith L004 PC045 Salaries System H Martin 17400 S10030 L Jones L023 PC064 HR System K Lewis 12250 S21010 P Lewis L004 S10010 B Jones L004 S31002 T Gilbert L023 S13210 W Richards L008 S10034 B James Employee-project table Project Code Employee No. Hourly Rate PC010 S10001 S10030 18.50 PC010 S21010 21.00 PC045 S10010 21.75 PC045 S10001 18.00 PC045 S31002 25.50 PC045 S13210 17.00 PC064 S31002 PC064 PC064 L0009 22.00 PC010 Department No. * Department table Department No. Department Name L004 IT L023 Pensions L028 Database 23.25 L008 Salary S21010 17.50 L009 HR S10034 16.50 Dr.Girija Narasimhan 17

×