0% found this document useful (0 votes)
25 views

DBMS 9

The document discusses database normalization and provides examples to normalize tables to first, second, third, and other normal forms. Database normalization is used to reduce data redundancy and avoid data anomalies. The document includes examples of tables and their normalization to various normal forms along with explanations.

Uploaded by

Toygj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

DBMS 9

The document discusses database normalization and provides examples to normalize tables to first, second, third, and other normal forms. Database normalization is used to reduce data redundancy and avoid data anomalies. The document includes examples of tables and their normalization to various normal forms along with explanations.

Uploaded by

Toygj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

20CS2016L - Database Management Systems Lab URK21CS7008

Ex. No. 9 DATABASE NORMALIZATION

Date of Exercise 12-10-2023

Aim:
To normalize the table for a given application.
Description
Database Normalization is a technique that helps in designing the schema of the database in
an optimal manner. The normalisation process is used to reduce the redundancy in a relation
or set of relations. Anomalies in insertion, deletion, and update which can be caused by
relation redundancy can be avoided by normalization. The process is incremental, and higher
degrees of database normalisation cannot be performed until the preceding levels are met.

There are the four types of normal forms:


Normal Description
Form
1NF A relation is in 1NF if it contains an atomic value.
2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are fully
functional dependent on the primary key.
3NF A relation will be in 3NF if it is in 2NF and no transition dependency exists.
4NF A relation will be in 4NF if it is in Boyce Codd normal form and has no
multi-valued dependency.
5NF A relation is in 5NF if it is in 4NF and not contains any join dependency
and joining should be lossless.

First Normal Form (1NF)


● A relation will be 1NF if it contains an atomic value.
● It states that an attribute of a table cannot hold multiple values. It must hold only
single-valued attribute.
● First normal form disallows the multi-valued attribute, composite attribute, and their
combinations.
Instructor's name Course code
Prof. George (CS101, CS154)
Prof. Atkins (CS152)
20CS2016L - Database Management Systems Lab URK21CS7008

The table is not in 1NF because of multi-valued attribute Course_code. The decomposition of the
table into 1NF is shown below:

Instructor's name Course code


Prof. George CS101
Prof. George CS154
Prof. Atkins CS152

Second Normal Form (2NF)


1. The table should be in the first normal form.
2. The primary key of the table should compose of exactly 1 column.
Student name Course code
Rahul CS152
Rajat CS101
Rahul CS154
Raman CS101

As per the second normal form definition, our enrollment table above isn’t in the second normal
form. To achieve the same (1NF to 2NF), we can rather break it into 2 tables:
Students:
Student name Enrolment number
Rahul 1
Rajat 2
Raman 3

The second column is unique and it indicates the enrollment number for the student. Clearly, the
enrollment number is unique. Now, we can attach each of these enrollment numbers with course
codes.
Courses:
Course code Enrolment number
CS101 2
CS101 3
CS152 1
CS154 1

Third Normal Form


In the third normal form, the following conditions are required:
● The table should be in the second normal form.
● There should not be any functional dependency.
20CS2016L - Database Management Systems Lab URK21CS7008

Course code Course venue Instructor's name Department


MA214 Lecture Hall 18 Prof. Ronald Mathematics Department
ME112 Auditorium building Prof. John Electronics Department

Third normal incorporates functional dependency by decomposing the table into 2 separate
tables:
Course code Course venue Instructor's ID
MA214 Lecture Hall 18 1
ME112 Auditorium building, 2

Here, the third column is the ID of the professor who’s taking the course.
Instructor's ID Instructor's Name Department
1 Prof. Ronald Mathematics Department
2 Prof. John Electronics Department

Boyce-Codd Normal Form (BCNF)


Boyce-Codd Normal form is a stronger generalization of third normal form. A table is in Boyce-
Codd Normal form if and only if at least one of the following conditions are met for each
functional dependency A → B:
● A is a superkey
● It is a trivial functional dependency.
Fourth normal form
A table is said to be in fourth normal form if there is no two or more, independent and
multivalued data describing the relevant entity.

Fifth normal form


A table is in fifth Normal Form if:
● It is in fourth normal form.
● It cannot be subdivided into any smaller tables without losing some form of information.
20CS2016L - Database Management Systems Lab URK21CS7008

Questions

1. Normalize the following table to 1NF

Roll_no Name Subject

101 Akon OS, CN

103 Bkon Java

102 Ckon C, C++

Solution:

Roll_no Name Subject

101 Akon OS

101 Akon CN

103 Bkon Java

102 Ckon C

102 Ckon C++

2. Normalize the following ‘Student’ table to 1NF

ID Name Mobile_number

1 ABC DEF GHI 12345678,


87654321

2 JKL MNO PQR 11223344

3 RST UVW XYW 21436587,


78563412
20CS2016L - Database Management Systems Lab URK21CS7008

Solution:

ID FName MName LName Mobile_num Alternate_m


ber obile_numbe
r

1 ABC DEF GHI 12345678 87654321

2 JKL MNO PGQ 11223344

3 RST UVW XYZ 21436587 78563412

3. Normalize the following table to 2NF

Student_ID Course_ID Course_Fee

1 IOT 750

2 IOT 750

3 IOT 750

1 AI 880

2 AI 880

3 AI 880

Solution:

Student:
Student_ID Course_ID Course:
Course_ID Course_F
1 IOT ee
2 IOT IOT 750
3 IOT AI 880
1 AI

2 AI

3 AI
20CS2016L - Database Management Systems Lab URK21CS7008

4. Normalize the following table to 2NF

Teacher_ID Subject Teacher_age

25 Chemistry 30

25 Biology 30

47 English 35

83 Maths 38

83 Computer 38

Solution:

Teacher: Subject:
Teacher_ID Subject
Teacher_ID Teacher_age
25 Chemistry
25 30
25 Biology
47 35
47 English
83 38
83 Maths

83 Computer

5. Normalize the following table to 3NF


20CS2016L - Database Management Systems Lab URK21CS7008

Solution:

Student: Course:

CID C_name Faculty


SID S_name
IS318 Database Howser
1 Adams
IS301 Program Langley
2 Jones

3 Smith

4 Baker

Faculty: Score:
SID CID Grade

Faculty F_phone 1 IS318 A

Howser 60192 1 IS301 B

Langley 45869 2 IS318 A

3 IS318 B

4 IS301 A

4 IS318 B

6. Normalize the following table to 3NF

Emp_ID Emp_name Project_ID Project_name

1 ABC 123 X

2 DEF 789 Z

3 GHI 123 X

4 JKL 123 X
20CS2016L - Database Management Systems Lab URK21CS7008

5 MNO 789 Z

6 PQR 789 Z

7 STU 123 X

Solution:

Employee: Project:

Emp_ID Emp_name Project_ID Project_ID Project_name


1 ABC 123 123 X
2 DEF 789 789 Z
3 GHI 123

4 JKL 123

5 MNO 789

6 PQR 789

7 STU 123

7. Normalize the following table to BCNF


20CS2016L - Database Management Systems Lab URK21CS7008

Solution:

Orders:
OID O_date CID C_name C_state

1006 10/24/09 2 Apex NC

1007 10/25/09 6 Acme GA

Products:

PID P_Desc P_price

7 Table 800

5 Desk 325

4 Chair 200

11 Dresses 500

Shopping:

OID PID Qty

1006 7 1

1006 5 1

1006 4 5

1007 11 4

1007 4 6
20CS2016L - Database Management Systems Lab URK21CS7008

8. Normalize the following table to BCNF

Solution:
Department: Employee:

DID D_name EID E_name


10 Finance 1 Huey
14 R&D 5 Dewey

11 Louie
Products: 2 Jack
PID Pname 4 Jill
27 Alpha

25 Beta

22 Gamma

26 Pail

21 Hill
20CS2016L - Database Management Systems Lab URK21CS7008

Details:
DID EID PID Btime

10 1 27 4.5

10 5 25 3

10 11 22 7

14 2 26 8

14 4 21 9

9. Normalize the following table to 4NF

Stu_ID Course Hobby

21 Computer Dancing

21 Maths Singing

34 Chemistry Dancing

74 Biology Cricket

59 Physics Hockey

Solution:

Course:

Stu_ID Course

21 Computer

21 Maths

34 Chemistry

74 Biology
20CS2016L - Database Management Systems Lab URK21CS7008

59 Physics

Hobby:

Stu_ID Hobby

21 Dancing

21 Singing

34 Dancing

74 Cricket

59 Hockey

10. Normalize the following table to 5NF

Agent Company Product

A1 PQR Nut

A1 PQR Bolt

A1 XYZ Nut

A1 XYZ Bolt

A2 PQR Nut

Solution:

Company Product
Agent Company
PQR Nut
A1 PQR
PQR Bolt
A1 XYZ
XYZ Nut
A2 PQR
XYZ Bolt
20CS2016L - Database Management Systems Lab URK21CS7008

Agent Product

A1 Nut

A1 Bolt

A2 Nut

Result:
Thus, tables were normalized for a given application.

You might also like