650 likes | 821 Views
Theory of Normalization. There are many types of normalized forms existing in a data base environment. 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).
E N D
Theory of Normalization Learners Support Publications www.lsp4you.com
There are many types of normalized forms existing in a data base environment • 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) Learners Support Publications www.lsp4you.com
What is the need of Normalization ? Learners Support Publications www.lsp4you.com
Normalization – The Need • to reduce redundancy => No inconsistencies • No loss of information from database over the life time of database Learners Support Publications www.lsp4you.com
STUDENTS Relation • Roll No • Name • Course • Phone Number • Major • Professor • Grade Learners Support Publications www.lsp4you.com
Different constraints • Students Roll No should be unique • A student can join many courses • A particular student has a single phone number, major • A course is taught by only one Professor • One grade is given to a student for a particular course Learners Support Publications www.lsp4you.com
Constraints • Restricts the design of the Data Base Management System Learners Support Publications www.lsp4you.com
A Relational State Learners Support Publications www.lsp4you.com
A Relational State The instance in which the data base is currently Learners Support Publications www.lsp4you.com
A Relational State Learners Support Publications www.lsp4you.com
PROBLEMS • Redundancy • Update Anomalies • Insertion Anomalies • Deletion Anomalies Learners Support Publications www.lsp4you.com
STUDENTS Relation Redundancy Of Data Learners Support Publications www.lsp4you.com
STUDENTS Relation Redundancy Of Data Learners Support Publications www.lsp4you.com
STUDENTS Relation Update Anomalies 696453 Learners Support Publications www.lsp4you.com
STUDENTS Relation Insertion Anomalies Learners Support Publications www.lsp4you.com
STUDENTS Relation Deletion Anomalies Learners Support Publications www.lsp4you.com
Functional Dependence • FDs are constraints on Legal Relations • Express facts about the enterprise that we are modeling with the database Learners Support Publications www.lsp4you.com
Identifying Functional Dependence There is no algorithmic method of identifying dependency. We have to use our commonsense and judgement to specify dependencies. Learners Support Publications www.lsp4you.com
Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
Problems in the STUDENT relation scheme can be remedied by DECOMPOSITION Learners Support Publications www.lsp4you.com
Desirable Decomposition • Lossless Join Decomposition • On taking JOIN of the decomposed relations have the same set of tuples as Original relation • Dependency Preservation • Constraints should not be violated Learners Support Publications www.lsp4you.com
Normalization • Is an attempt to eliminate/minimize the problems occurring due to data redundancy over the life time of the database. • Is an attempt for Good Database Design using Decomposition. Learners Support Publications www.lsp4you.com
Normalization • Is an attempt to eliminate/minimize the problems occurring due to data redundancy over the life time of the database. • Is an attempt for Good Database Design using Decomposition. States of the database Learners Support Publications www.lsp4you.com
FIRST NORMAL FORM (1NF) • This is also called a flat file and shown as 1NF. • There are no composite attributes and describes one property. • A Database Scheme is in 1NF if every Relational Scheme included in the Database Scheme is in 1NF. Learners Support Publications www.lsp4you.com
This relation is in 1NF STUDENTS Relation Learners Support Publications www.lsp4you.com
SECOND NORMAL FORM(2NF) • A relation is said to be in 2NF if it is in 1NF and non-key attributes are fully functionally dependent on the key attribute(s). • If the key has more than one attribute then no non-key attributes should be functionally dependent on a part of the key attributes. Learners Support Publications www.lsp4you.com
Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
This leads Data Redundancy and Anomalies Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
This leads Data Redundancy and Anomalies Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes This can be solved by means of DECOMPOSITION Learners Support Publications www.lsp4you.com
Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
Dependency Diagram Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
STUDENT Relation IN 2NF • Student_Info (Name, Phone, Major) • Result (Name, Course, Grade) • C_T (Course, Prof.) Learners Support Publications www.lsp4you.com
STUDENT Relation IN 2NF • Student_Info (Name, Phone, Major) • Result (Name, Course, Grade) • C_T (Course, Prof.) By combining these three relations, using common attributes, we will get the original relation Learners Support Publications www.lsp4you.com
STUDENT Relation IN 2NF • Student_Info (Name, Phone, Major) Phone Name Major Name to Phone dependency and Name to Major dependency are being preserved in the STUDENT_INFO relation. Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
STUDENT Relation IN 2NF • C_T (Course, Prof.) Course to Prof. is being preserved in the C_T relation Phone Name Major Grade Course Prof. Key Attributes Learners Support Publications www.lsp4you.com
STUDENT Relation IN 2NF • Result (Name, Course, Grade) Name & Course to Grade is being preserved in the RESULT relation Name Grade Course Key Attributes Learners Support Publications www.lsp4you.com
STUDENT Relation IN 2NF • Student_Info (Name, Phone, Major) • Result (Name, Course, Grade) • C_T (Course, Prof.) Learners Support Publications www.lsp4you.com
Consider the following relation Learners Support Publications www.lsp4you.com
Consider the following relation Roll No uniquely determines the Name Learners Support Publications www.lsp4you.com
Consider the following relation Roll No uniquely determines the Depart. Learners Support Publications www.lsp4you.com
Consider the following relation Roll No uniquely determines the Year Learners Support Publications www.lsp4you.com
Consider the following relation Roll No uniquely determines the Hostel Learners Support Publications www.lsp4you.com
Consider the following relation So this relation is in 2NF Learners Support Publications www.lsp4you.com
Non-Key Attributes Key Attribute STUDENT Relation Learners Support Publications www.lsp4you.com
Non-Key Attributes Key Attribute STUDENT Relation Functionally determines Learners Support Publications www.lsp4you.com
Non-Key Attributes Key Attribute STUDENT Relation Functionally determines So a Dependency existing between the Year and the Hostel Learners Support Publications www.lsp4you.com
Dependency Diagram Name Depart. Roll No Year Key Attribute We are in trouble Hostel Learners Support Publications www.lsp4you.com
STUDENT Relation Redundancy of Data Learners Support Publications www.lsp4you.com