3Nf, BCNF, 4Nf & 5Nf: UNIT-3 Rdbms BCA304 Presenter-Daisy Sharmah

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

3NF, BCNF, 4NF & 5NF

UNIT-3
RDBMS
BCA304
PRESENTER-DAISY SHARMAH
Introduction to 3 Normal Form
rd

• Although Second Normal Form (2NF) relations


have less redundancy than those in 1NF, they
may still suffer from update anomalies.
• If we update only one tuple and not the
other, the database would be in an
inconsistent state.
• This update anomaly is caused by a transitive
dependency.
• We need to remove such dependencies by
progressing to Third Normal Form (3NF).
Third Normal Form (3NF)

• A relation will be in 3NF if it is in 2NF and not


contain any transitive partial dependency.
• 3NF is used to reduce the data duplication. It
is also used to achieve the data integrity.
• If there is no transitive dependency for non-
prime attributes, then the relation must be in
third normal form.
Formal Definition of 3NF
• “A relation that is in First and Second Normal
Form and in which no non-primary-key
attribute is transitively dependent on the
primary key, then it is in Third Normal Form
(3NF).”
Transitive Dependency
• If A->B and B->C are two FDs then A->C is
called transitive dependency.
• The normalization of 2NF relations to 3NF
involves the removal of transitive
dependencies.
• If a transitive dependency exists, we remove
the transitively dependent attribute(s) from
the relation by placing the attribute(s) in a new
relation along with a copy of the determinant.
Example-1

• FD set:
{STUD_NO -> STUD_NAME, STUD_NO ->
STUD_STATE, STUD_STATE -> STUD_COUNTRY,
STUD_NO -> STUD_AGE}
• Candidate Key:
{STUD_NO}
Explanation
• For this relation in table, 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)
Introduction to BCNF
• Application of the general definitions
of 2NF and 3NF may identify additional
redundancy caused by dependencies that
violate one or more candidate keys.
• Dependencies can still exist that will cause
redundancy to be present in 3NF relations.
• This weakness in 3NF, resulted in the
presentation of a stronger normal form called
Boyce–Codd Normal Form.
• This can be solve by Boyce-Codd Normal Form
(BCNF).
Formal Definition of BCNF
“A relation R is in BCNF if R is in 3NF and every
determinant of a non-trivial functional
dependency in R is a candidate key.”
Explanation to BCNF
• BCNF is the advance version of 3NF. It is
stricter than 3NF.
• A table is in BCNF if every functional
dependency X → Y, X is the super key of the
table.
• For BCNF, the table should be in 3NF, and for
every FD, LHS is super key.
Example
• EMPLOYEE table:
EMP_ID EMP_COUNTRY EMP_DEPT DEPT_TYPE EMP_DEPT_NO

264 India Designing D394 283


264 India Testing D394 300
364 UK Stores D283 232
364 UK Developing D283 549
In the above table Functional dependencies are
as follows:
• EMP_ID  →  EMP_COUNTRY  
• EMP_DEPT  →   {DEPT_TYPE, EMP_DEPT_NO}  
Example
• Candidate key: {EMP-ID, EMP-DEPT}
• The table is not in BCNF because neither
EMP_DEPT nor EMP_ID alone are keys.
• To convert the given table into BCNF, we
decompose it into three tables:
• EMP_COUNTRY table:

EMP_ID EMP_COUNTRY

264 India
264 India
Example
• EMP_DEPT table:
EMP_DEPT DEPT_TYPE EMP_DEPT_NO

Designing D394 283


Testing D394 300
Stores D283 232
Developing D283 549

• EMP_DEPT_MAPPING table:
EMP_ID EMP_DEPT

264 Designing
264 Testing
364 Stores
364 Developing
Example
Functional dependencies:
• 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}

• Now, this is in BCNF because left side part of


both the functional dependencies is a key.
Fourth Normal Form (4NF)
Any relation is said to be in the fourth normal
form when it satisfies the following conditions:
• It must be in Boyce Codd Normal Form (BCNF).
• It should have no multi-valued dependency.
Multi Valued Dependency
• A multi-valued dependency is said to occur
when there are two attributes in a table which
depend on a third attribute but are
independent of each other.
• For a functional dependency X->Y there will be
a multi-valued dependency if there exists
multiple values of Y for a single value of X.
Example 

STUDENT-ID COURSE HOBBY


100 Science Dancing
100 Maths Singing
101 C# Dancing
101 PHP Singing
Example 
• In this relation Student-ID 1 has thus opted for
two courses and has two hobbies.
• Similarly Student-ID 2 has opted for two
courses and has two hobbies.
• Thus it contains multi-valued dependencies.
• It is not in 4NF and in order to convert it into
4NF it can be decomposed into two relations
Table – R1
STUDENT-ID COURSE
100 Science
100 Maths
101 C#
101 PHP
Table – R2
STUDENT-ID HOBBY
100 Dancing
100 Singing
101 Dancing
101 Singing
Fifth Normal Form (5NF)
Any relation in order to be in the fifth normal
form must satisfy the following conditions:
• It must be in Fourth Normal Form (4NF).
• It should have no join dependency and also
the joining must be lossless.
Fifth Normal Form (5NF)
• In the fifth normal form the relation must be
decomposed in as many sub-relations as possible so
as to avoid any kind of redundancy and there must
be no extra tuples generated when the sub-relations
are combined together by using natural join.
• A relation in 5NF cannot be decomposed further
without any kind of modification in the meaning or
facts.
• 5NF is also known as Project Join Normal Form
(PJNF).
What is Join Dependency?

• If a table can be recreated by joining multiple


tables and each of this table have a subset of
the attributes of the table, then the table is in
Join Dependency.
• It is a generalization of Multivalued
Dependency
Example 
STUDENT-ID MOBILE NUMBER HOBBY
123 9999900000 Dancing
124 9999900000 Singing
124 9999900000 Dancing
123 8975622122 Singing
123 9999900000 Singing

This can be further decomposed into three relations


Table – R1
STUDENT-ID MOBILE NUMBER
123 9999900000
123 8975622122
124 9999900000
Table – R2
STUDENT-ID HOBBY
123 Dancing
123 Singing
124 Singing
124 Dancing
Table – R3
MOBILE NUMBER HOBBY
9999900000 Dancing
9999900000 Singing
8975622122 Singing
Difference between 4NF and 5NF
S.NO 4NF 5NF
A relation in 4NF must also be in A relation in 5NF must also be in
1.
BCNF(Boyce Codd Normal Form). 4NF(Fourth Normal Form).
A relation in 4NF must not have A relation in 5NF must not have any join
2.
any multi-valued dependency. dependency.

3. A relation in 4NF may or may not A relation in 5NF is always in 4NF


be in 5NF.
Fourth Normal Form is less
Fifth Normal form is more stronger than
4. stronger in comparison to Fifth
Fourth Normal Form.
Normal form.
If a relation is in Fourth Normal If a relation is in Fifth Normal Form then
5. Form then it will have more
it will less redundancy.
redundancy.
If a relation is in Fifth Normal Form then
If a relation is in Fourth Normal
6. Form then it may be decomposed it cannot be decomposed further into
sub-relations without any modification in
further into sub-relations.
meaning or facts.
Link
• https://
www.tutorialspoint.com/what-is-multivalued-
dependency-in-dbms
• ANY QUERY…..
THANK YOU

You might also like