Unit4 Normalization PDF
Unit4 Normalization PDF
Topics
Pitfalls in Relational Database Design What is normalization? First, Second and Third Normal Form
Decomposition
Consider a Relation - Lending
Reconstruct the lending relation by performing a natural join on the two new schemas
What is Normalisation?
Transforming data from a problem into relations while ensuring data integrity and eliminating data redundancy. Normalisation should remove redundancy, but not at the expense of data integrity.
Normal Forms
First Normal Form Second Normal Form Third Normal Form Boyce Codd Normal Form Fourth Normal Form Fifth Normal Form
Repeating group (any project can have a group of data entries) which should not to be appeared in relational table
Example
matric_no 960100 Name Smith, J date_of_birth 14/11/1977 subject Databases Soft_Dev ISDE Soft_Dev ISDE 960120 Moore, T 11/03/1970 Databases Soft_Dev Workshop Databases Databases Soft_Dev ISDE Workshop grade C A D B B A B C B B D C D
960105
White, A
10/05/1975
960145 960150
Smith, J Black, D
09/01/1972 21/08/1973
Flattened Tables
matric_no 960100 960100 960100 960105 960105 960120 960120 960120 960145 960150 960150 960150 960150
Copyright 2008 Pratian Technologies www.pratian.com
name Smith, J Smith, J Smith, J White, A White, A Moore, T Moore, T Moore, T Smith, J Black, D Black, D Black, D Black, D
date_of_birth 14/11/1977 14/11/1977 14/11/1977 10/05/1975 10/05/1975 11/03/1970 11/03/1970 11/03/1970 09/01/1972 21/08/1973 21/08/1973 21/08/1973 21/08/1973
Subject Databases Soft_Dev ISDE Soft_Dev ISDE Databases Soft_Dev Workshop Databases Databases Soft_Dev ISDE Workshop
grade C A D B B A B C B B D C B
Relations
We now have two relations, Student and Record. Student(matric_no, name, date_of_birth ) Record(matric_no, subject, grade ) Without repeating groups, we say the relations are in First Normal Form (1NF).
Example 1
Consider again the Student relation from the flattened Student
matric_no 960100 960100 960100 960105 960105 960120 960120 960120 960145 960150 960150 960150 960150 name Smith, J Smith, J Smith, J White, A White, A Moore, T Moore, T Moore, T Smith, J Black, D Black, D Black, D Black, D date_of_birth 14/11/1977 14/11/1977 14/11/1977 10/05/1975 10/05/1975 11/03/1970 11/03/1970 11/03/1970 09/01/1972 21/08/1973 21/08/1973 21/08/1973 21/08/1973 Subject Databases Soft_Dev ISDE Soft_Dev ISDE Databases Soft_Dev Workshop Databases Databases Soft_Dev ISDE Workshop grade C A D B B A B C B B D C B
Dependency Diagram
A dependency diagram is used to show how non-key attributes relate to each part or combination of parts in the primary key.
Student
matric_no name date_of_birth subject grade
Student Details
matrix_no name date_of_birth
Student
matrix_no subject grade
All attributes in each relation are fully functionally dependent upon its primary key These relations are now in 2NF
Example
project_no p1 p2 p3 p4 manager Black,B Smith,J Black,B Black,B address 32 High Street 11 New Street 32 High Street 32 High Street
Project has more than one non-key field so we must check for transitive dependency:
Project p1 p2 p3 p4
project_no
manager Black,B Smith,J Black,B Black,B Manager manager Black,B address 32 High Street
Smith,J
11 New Street
Summary: 1NF
A relation is in 1NF if it contains no repeating groups
Summary: 2NF
A relation is in 2NF if it contains no repeating groups and no partial key functional dependencies
Summary: 3NF
A relation is in 3NF if it contains no repeating groups, no partial functional dependencies, and no transitive functional dependencies
Figure 4.3
Question time
Please try to limit the questions to the topics discussed during the session. Thank you.
Solution
R1(ClassCode, ClassDescription) R2(ClassCode, StudentNumber, Name)
Question time
Please try to limit the questions to the topics discussed during the session. Thank you.