0% found this document useful (0 votes)
354 views20 pages

Types of Normalization

Here are the answers to your questions: 1. Normalization is a process of organizing data in a database to reduce redundancy and dependency. The main types of normalization are 1NF, 2NF, 3NF, BCNF, 4NF and 5NF. 2. Prime attributes are attributes that are part of candidate key. Non-prime attributes are attributes that are not part of candidate key. 3. We use normalized database to reduce redundancy, avoid data anomalies, ensure data integrity and improve performance of database. 4. Partial dependency means attribute depends on subset of candidate key. Full dependency means attribute depends on whole candidate key. 5. Normalization is process of organizing columns and tables to avoid anomalies.

Uploaded by

pratibha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
354 views20 pages

Types of Normalization

Here are the answers to your questions: 1. Normalization is a process of organizing data in a database to reduce redundancy and dependency. The main types of normalization are 1NF, 2NF, 3NF, BCNF, 4NF and 5NF. 2. Prime attributes are attributes that are part of candidate key. Non-prime attributes are attributes that are not part of candidate key. 3. We use normalized database to reduce redundancy, avoid data anomalies, ensure data integrity and improve performance of database. 4. Partial dependency means attribute depends on subset of candidate key. Full dependency means attribute depends on whole candidate key. 5. Normalization is process of organizing columns and tables to avoid anomalies.

Uploaded by

pratibha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MCA, MSc(CS), PGDCA

Pratibha Rashmi
 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)

Note: The database designers don’t have


to normalize relations to the highest
possible normal form (usually 3NF, BCNF
or 4NF is enough)
First normal form enforces these criteria:
 Eliminate repeating groups in individual
tables.
 Create a separate table for each set of
related data.
 Identify each set of related data with a
primary key.
 Each set of column must have a unique
value.
 It contains atomic values because the table
cannot hold multiple values.
tb_Product
p_id colour cost
1 Red, yellow 3000
2 Blue 2000
3 Green, Red 2030

This table is not in first normal form because the


“Colour” column contains multiple Values.
p_id cost
1 3000
2 2000
3 2030

p_id Colour
1 Red
1 Yellow
2 Blue
3 Green
3 Red
A table is said to be in 2NF if both the
following conditions hold:

 Table is in 1NF (First normal form).


 Nonon-prime attribute is dependent on the
proper subset of any candidate key of table.
 Non-prime attribute-An attribute that is not
part of any candidate key is known as non-
prime attribute.
 Or in other words A relation R is said to be in
2NF if it is in 1NF and if all nono-prime
attributes are not partially dependent on
candidate key ie all non- prime attribute
must be fully functionally dependent on
candidate key.
 Partially dependency: In a relationa R XY->Z
is said to be partial FD if either X->Z or Y->Z
exists in R.
 On other hand In a relationa R XY->Z is said
to be fully FD if neither X->Z nor Y->Z exists
in R.
 We use a teacher table that have teacher id,
subject and age. Since a teacher can teach more
than one subjects, the table can have multiple
rows for a same teacher.
tb_teacher
t_id subject t_age
1 DBMS 40
1 Networking 40
2 OS 38
2 DM 38
3 AI 42

* Candidate Keys: {t_id, subject}


* Non prime attribute: t_age
 This table is in 1 NF because each attribute
has atomic values.

 But, it is not in 2NF because non prime


attribute t_age is dependent on t_id alone
which is a proper subset of candidate key.
This violates the rule for 2NF as the rule says
“no non-prime attribute is dependent on the
proper subset of any candidate key of the
table”.

 To make the table complies with 2NF we can


break it in two tables , eg. t_details and
t_subject.
 Table 1: t_details
t_details
t_id t_age
1 40
2 38
3 42

 Table 2: t_subject
t_subject
t_id subject
1 DBMS
1 Networking
2 OS
2 DM
3 AI

Now the tables execute with Second normal form (2NF).


 Third Normal Form (3NF) is used to minimize
the transitive redundancy.
 In 3NF, the table is required in 2NF.
 While using the 2NF table, there should not
be any transitive partial dependency.
 3NF reduces the duplication of data and also
achieves the data integrity.
In other words: A table is in 3NF if it is in 2NF
and for each functional dependency X-> Y at
least one of the following conditions hold:
 X is a super key of table
 Y is a prime attribute of table
 Let’stake a table Student details with
attributes student id, name, city, district,
state, zip.
tb_Student
s_id s_name city district state zip
1 Jaunty Delhi Delhi Delhi 110001
2 Arnav Agra Agra UP 282005
3 Ram Aligarh Aligarh UP 200201
4 Reeta Meerut Meerut UP 250001
5 Sita Delhi Delhi Delhi 110013

Super keys: {s_id}, {s_id, s_name}, {s_id, s_name, zip}…....so on


Candidate Keys: {s_id}
Non-prime attributes: all attributes except s_id are non-prime
as they are not part of any candidate keys.
 Here, state, city and district dependent on
zip. And, zip is dependent on s_id that makes
non-prime attributes (state, city and district)
transitively dependent on super key (s_id).
This violates the rule of 3NF.
 To make this table complies with 3NF we
have to break the table into two tables to
remove the transitive dependency:

tb_Student tb_Zip
s_id s_name zip zip city district state
1 Jaunty 110001 110001 Delhi Delhi Delhi
2 Arnav 282005 282005 Agra Agra UP
3 Ram 200201 200201 Aligarh Aligarh UP
4 Reeta 250001 250001 Meerut Meerut UP
5 Sita 110013 110013 Delhi Delhi Delhi
 Even when a database is in 3rd Normal
Form, still there would be anomalies resulted
if it has more than one Candidate Key.
 BCNF is an advance version of 3NF that’s why
it is also referred as 3.5NF.
 BCNF is stricter than 3NF.
 A table complies with BCNF if it is in 3NF
and for every functional dependency X->Y, X
should be the super key of the table.
 Let's assume there is a company where
employees work in more than one
department.
tb_employee
e_id e_country e_dept dept_type e_dept_id
1 India Sales D003 1003
1 India Account D003 1008
2 USA Developing D001 1001
2 USA Designing D001 1006
3 UK Sales D003 1007
In the above table Functional dependencies are as follows:
e_id → e_country
e_dept → {dept_type, e_dept_id}
Candidate key: {e_id, e_dept}

The table is not in BCNF because neither e_dept nor e_id alone
are keys.
 To
convert the given table into BCNF, we
decompose it into three tables:
Table 1:

tb_emp_country
e_id e_country Table 2:

1 India tb_emp_dept
2 USA e_dept dept_type e_dept_id
3 UK Sales D003 1003
Table 3: Account D003 1008
tb_emp_dept_mapping Developing D001 1001
e_id e_dept Designing D001 1006
1 Sales Sales D003 1007

1 Account
2 Developing
2 Designing
3 Sales
 Functional
dependencies:
e_id → e_country
e_dept → {dept_type, e_dept_id}

 Candidate keys:

For the first table: e_id


For the second table: e_dept
For the third table: {e_id, e_dept}

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


both the functional dependencies is a key.
 Ques 1: What is normalization? What are
different type of normalization?
 Ques 2: Define Prime and Non - prime
attributes.
 Ques 3: Why do we use normalized database?
 Ques 4: Define partial and full dependency.
 Ques 5: Define normalization. Explain INF,
2NF, and 3NF using appropriate example.
 Ques 6: differentiate between 3NF and BCNF.

You might also like