Professional Documents
Culture Documents
DBMS Module 4
DBMS Module 4
Second Normal Form (2NF) is based on the concept of full functional dependency.
To be in second normal form, a relation must be in first normal form and relation
must not contain any partial dependency.
A relation is in 2NF if it has No Partial Dependency, i.e., no non-prime attribute
(attributes which are not part of any candidate key) is dependent on any proper
subset of any candidate key of the table.
Example: Let's assume, a school can store the data of teachers and the subjects they
teach. In a school, a teacher can teach more than one subject.
To convert the given table into 2NF, we decompose it into two tables:
Third Normal Form (2NF):
FD set:
{STUD_NO -> STUD_NAME, STUD_NO -> STUD_STATE, STUD_STATE ->
STUD_COUNTRY, STUD_NO -> STUD_AGE}
Candidate Key:
{STUD_NO}
For this relation in table 4, STUD_NO -> STUD_STATE and STUD_STATE ->
STUD_COUNTRY are true.
So, STUD_COUNTRY is transitively dependent on STUD_NO.
It violates the third normal form. To convert it in third normal form, we will
decompose the relation STUDENT (STUD_NO, STUD_NAME, STUD_PHONE,
STUD_STATE, STUD_COUNTRY_STUD_AGE) as:
1. STUDENT (STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_AGE)
2. STATE_COUNTRY (STATE, COUNTRY)
Boyce Codd Normal Form is an advanced form of the third natural form and hence is
quite stricter than it.
If every functional dependency is in the form X → Y, the table is in BCNF. Here, X is
the super key to the table.
For a table to be in BCNF, it should be in 3NF. For every FD, LHS is the super key.
For example, let us consider a company which has employees in more than one
department.
In this table, functional dependencies are:
EMP_ID →EMP_COUNTRY
EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate key: {EMP-ID, EMP-DEPT}
This table is not in BCNF because EMP_DEPT or EMP_ID are not alone keys.To convert to
BCNF, we break it down into three tables.
EMP_ID →EMP_COUNTRY
EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate keys:
For the first table: EMP_ID
For the second table: EMP_DEPT
For the third table: {EMP_ID, EMP_DEPT}
This is in BCNF because the left side of the two functional dependencies is a key.
A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-valued
dependency.
For a dependency A → B, if for a single value of A, multiple values of B exists, then
the relation will be a multi-valued dependency.
Example:
The given STUDENT table is in 3NF, but the COURSE and HOBBY are two independent
entities. Hence, there is no relationship between COURSE and HOBBY.
In the STUDENT relation, a student with STU_ID, 21 contains two
courses, Computer and Math and two hobbies, Dancing and Singing. So, there is a
multi-valued dependency on STU_ID, which leads to unnecessary repetition of data.
So, to make the above table into 4NF, we can decompose it into two tables:
NORMAL FORMS CONDITION
1NF No multivalued attribute
Only single valued
2NF 1NF
No partial dependency
Only full dependency
3NF 2NF
No transitivity dependency
No non-prime should determine
non-prime
BCNF 3NF
LHS must be candidate key or
super key
4NF BCNF
No Multivalued dependency
5NF 4NF
Lossless Decomposition
2.
If X ⊇ Y then X→Y
If X → Y then XZ → YZ
Union rule says, if X determines Y and X determines Z, then X must also determine Y
and Z.
If X → Y and X → Z then X → YZ
Decomposition rule is also known as project rule. It is the reverse of union rule.
This Rule says, if X determines Y and Z, then X determines Y and X determines Z
separately.
If X → YZ then X → Y and X → Z