Noormalization 10
Noormalization 10
Normalization of Database
Database Normalization is a technique of organizing the data in the database.
• Normalization is a systematic approach of decomposing tables to eliminate
data redundancy and undesirable characteristics like Insertion, Update and
Deletion Anomalies.
• It is a multi-step process that puts data into tabular form by removing
duplicated data from the relation tables.
• Before we learn about the second normal form, we need to understand the following
• Prime attribute − An attribute, which is a part of the prime-key, is known as a
prime attribute.
• Non-prime attribute − An attribute, which is not a part of the prime-key, is said to
be a non-prime attribute.
If we follow second normal form, then every non-prime attribute should be fully
functionally dependent on prime key attribute. That is, if X → A holds, then there
should not be any proper subset Y of X, for which Y → A also holds true.
Another Example 2NF
We see here in Student_Project relation that the prime key attributes are Stu_ID and Proj_ID.
According to the rule, non-key attributes, i.e. Stu_Name and Proj_Name must be dependent upon
both and not on any of the prime key attribute individually. But we find that Stu_Name can be
identified by Stu_ID and Proj_Name can be identified by Proj_ID independently. This is called
partial dependency, which is not allowed in Second Normal Form.
Third Normal Form (3NF)
For a relation to be in Third Normal Form, it must be in Second Normal form and the
following must satisfy −
• No non-prime attribute is transitively dependent on prime key attribute.
• For any non-trivial functional dependency, X → A, then either −
• X is a superkey or,
• A is prime attribute.
We find that in the above Student_detail relation, Stu_ID is the key and only
prime key attribute. We find that City can be identified by Stu_ID as well as Zip
itself. Neither Zip is a superkey nor is City a prime attribute. Additionally,
Stu_ID → Zip → City, so there exists transitive dependency.
What do you understand by Functional dependency?
Functional dependency in DBMS, as the name suggests is a relationship between attributes
of a table dependent on each other. A relation is said to be in Functional dependency when
one attribute uniquely defines another attribute.
For Example, R is a Relation, X and Y are two attributes. T1 and T2 are two tuples.
Then,T1[X]=T2[X] and T1[Y]=T2[Y] means the value of component X uniquely define the
value of component Y.
Also, X->Y means Y is functionally dependent on X.
Example
The following is an example that would make it easier to understand functional dependency:
• We have a <Department> table with two attributes: DeptId and DeptName.
The DeptId is our primary key. Here, DeptId uniquely identifies the DeptName attribute. This is because if
you want to know the department name, then at first you need to have the DeptId. Therefore, the above
functional dependency between DeptId and DeptName can be determined as DeptId is functionally dependent
on DeptName:
• DeptId -> DeptName
In this table Student_id is Primary key, but street, city and state depends upon Zip.
The dependency between zip and other fields is called transitive dependency.
Hence to apply 3NF, we need to move the street, city and state to new table,
with Zip as primary key.
New Student_Detail Table :
Student_id Student_name DOB Zip
Address Table :
Zip Street city state
Boyce and Codd Normal Form (BCNF)
• Boyce-Codd Normal Form (BCNF) is an extension of Third Normal Form on
strict terms. BCNF states that −
• In the above image, Stu_ID is the super-key in the relation Student_Detail and Zip
is the super-key in the relation ZipCodes. So,
• Stu_ID → Stu_Name, Zip and
• Zip → City
emp_dept_mapping table:
Functional dependencies:
emp_id emp_dept
1001 Production and planning emp_id -> emp_nationality
emp_dept -> {dept_type, dept_no_of_emp}
1001 stores
Candidate keys:
1002 design and technical support For first table: emp_id
1002 Purchasing department For second table: emp_dept
For third table: {emp_id, emp_dept}
1NF
2NF
3NF
Final Relation with table name
END