DBMS 9
DBMS 9
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.
The table is not in 1NF because of multi-valued attribute Course_code. The decomposition of the
table into 1NF is shown below:
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 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
Questions
Solution:
101 Akon OS
101 Akon CN
102 Ckon C
ID Name Mobile_number
Solution:
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
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
Solution:
Student: Course:
3 Smith
4 Baker
Faculty: Score:
SID CID Grade
3 IS318 B
4 IS301 A
4 IS318 B
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:
4 JKL 123
5 MNO 789
6 PQR 789
7 STU 123
Solution:
Orders:
OID O_date CID C_name C_state
Products:
7 Table 800
5 Desk 325
4 Chair 200
11 Dresses 500
Shopping:
1006 7 1
1006 5 1
1006 4 5
1007 11 4
1007 4 6
20CS2016L - Database Management Systems Lab URK21CS7008
Solution:
Department: Employee:
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
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
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.