Unit 3 Normalization
Unit 3 Normalization
• Armstrong Axioms :
• Armstrong axioms defines the set of rules for
reasoning about functional dependencies and
also to infer all the functional dependencies
on a relational database.
Primary armstrong axiom rules:
secondary or derived axioms:
Types of functional dependencies:
14 John 7272826385, UP
9064738238
14 John 7272826385 UP
14 John 9064738238 UP
20 Harry 8574783832 Bihar
Second Normal Form (2NF)
1 C1 1000
2 C2 2000
1 C4 3000
4 C3 5000
4 C1 1000
2 C5 6000
Second Normal Form (2NF)
• X is a super key.
• Y is a prime attribute, i.e., each element of Y is part of some candidate
key.
Third Normal Form (3NF)
02228 US Boston
60007 US Chicago
06389 UK Norwich
462007 MP Bhopal
Boyce Codd normal form
(BCNF,3.5NF)
EMP_ID EMP_COUNTRY
264 India
264 India
Boyce Codd normal form
• In the above table Functional dependencies are as
follows:
• EMP_ID → EMP_COUNTRY
• EMP_DEPT → {DEPT_TYPE, }
• DEPT_TYPE → {EMP_DEPT_NO}
• Candidate key: {EMP-ID, EMP-DEPT}
• The table is not in BCNF because dept_type is not a
key.
• To convert the given table into BCNF, we decompose it
into three tables:
BCNF
• EMP_DEPT table:
EMP_DEPT DEPT_TYPE
Designing D394
Testing D394
Stores D283
Developing D283
BCNF
• EMP_DEPT_MAPPING table:
DEPT_TYPE EMP_DEPT_NO
D394 283
D394 300
D283 232
D283 549
BCNF
• Functional dependencies:
• EMP_ID → EMP_COUNTRY
• EMP_DEPT → DEPT_TYPE
• DEPT_TYPE → EMP_DEPT_NO
• Candidate keys:
• For the first table: EMP_ID
For the second table: EMP_DEPT
For the third table: {DEPT_TYPE}
BCNF
• Id Subject Professor
• 101 Java Mayank
• 101 C++ Kartik
• 102 Java Sarthak
• 103 C# Lakshay
• 104 Java Mayank
BCNF
in the table:
Professor is now the primary key and the prime attribute column,
deriving the subject column. Hence, it is in BCNF.
Fourth normal form (4NF)
• STUDENT_COURSE
STU_ID COURSE
21 Computer
21 Math
34 Chemistry
74 Biology
59 Physics
Fourth normal form (4NF)
• STUDENT_HOBBY
STU_ID HOBBY
21 Dancing
21 Singing
34 Dancing
74 Cricket
59 Hockey
Fifth normal form (5NF)
• STUDENT TABLE
• P1 TABLE
SEMESTER SUBJECT
Semester 1 Computer
Semester 1 Math
Semester 1 Chemistry
Semester 2 Math
Fifth normal form (5NF)
• P2 TABLE
SUBJECT LECTURER
Computer Anshika
Computer John
Math John
Math Akash
Chemistry Praveen
Fifth normal form (5NF)
• P3 TABLE
SEMSTER LECTURER
Semester 1 Anshika
Semester 1 John
Semester 1 John
Semester 2 Akash
Semester 1 Praveen
Decomposition
• The process of breaking up or dividing a single
relation into two or more sub relations is
called as decomposition of a relation.
Properties of Decomposition
• Super Key-
• If the closure result of an attribute set contains all the
attributes of the relation, then that attribute set is called
as a super key of that relation.
• Thus, we can say-
• “The closure of a super key is the entire relation
schema.”
• In the above example,
• The closure of attribute A is the entire relation schema.
• Thus, attribute A is a super key for that relation.
Candidate Key