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

DATABASE

The document summarizes three cases of database normalization. In the first case, it shows the normalization of a database with courses and students from 1NF to 3NF. In 2NF, it separates the tables into Course Details, Student Details, and Student Course. In 3NF, it removes transitive dependencies. The second case normalizes an employee project database from 1NF to 3NF. In 2NF, it separates the tables into Project, Employee, and Job. The third case shows the initial normalization of a clothing store database into 1NF by removing repeating groups.

Uploaded by

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

DATABASE

The document summarizes three cases of database normalization. In the first case, it shows the normalization of a database with courses and students from 1NF to 3NF. In 2NF, it separates the tables into Course Details, Student Details, and Student Course. In 3NF, it removes transitive dependencies. The second case normalizes an employee project database from 1NF to 3NF. In 2NF, it separates the tables into Project, Employee, and Job. The third case shows the initial normalization of a clothing store database into 1NF by removing repeating groups.

Uploaded by

Zaini Xh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

DATABASE

ASSIGNMENT

Submitted By:
Zainab Naafey
Submitted To:
Sir Riaz-Ul-Amin
Roll No. :
BSCS-4M-1053
DATABASE NORMALIZATION
Case 01:
Institute having two departments.
Entities: Course Detail, Student Details, Student Course
Attributes: DEP_NO, DEP_NAME, Std_no, Std_name, Std_age, Course_name, Course_fee
Primary Keys: DEP_NO, Std_no
Non-Normalize Database:

DEP_NO DEP_NAME Std_no Std_name Std_age Course_name Course_fee


1 CS 1001 Zainab 19 Python 3000
1 CS 1002 Nimra 20 Java,Html 5000
1 CS 1003 Kiran 20 C 4000
2 IT 1004 Ayesha 21 Python 5000
2 IT 1005 Rabia 20 C++ 2000
2 IT 1006 Reha 20 C 2000

1ST Normal Form (1NF):


To bring it to 1NF, remove the repeating groups.

DEP_NO DEP_NAME Std_no Std_name Std_age Course_name Course_fee


1 CS 1001 Zainab 19 Python 3000
1 CS 1002 Nimra 20 Java,Html 5000
1 CS 1002 Nimra 20 Html 5000
1 CS 1003 Kiran 20 C 4000
2 IT 1004 Ayesha 21 Python 5000
2 IT 1005 Rabia 20 C++ 2000
2 IT 1006 Reha 20 C 2000
2ND Normal Form (2NF):
To bring it to 2NF, it must be in 1NF and there is no partial dependency exist.
Course Details:

DEP_NO Std_n Course_name Course_fee


o
1 1001 Python 3000
1 1002 Java,Html 5000
1 1002 Html 5000
1 1003 C 4000
2 1004 Python 5000
2 1005 C++ 2000
2 1006 C 2000

Student Details:

DEP_NO Std_name Std_age


1 Zainab 19
1 Nimra 20
1 Nimra 20
1 Kiran 20
2 Ayesha 21
2 Rabia 20
2 Reha 20

3RD Normal Form (3NF):


To bring it to 3NF, it must be in 2NF and there is no transitive dependency exist.
Student Details:

Std_no Std_nam Std_age Course_name


e
1001 Zainab 19 Python
1002 Nimra 20 Java,Html
1002 Nimra 20 Html
1003 Kiran 20 C
1004 Ayesha 21 Python
1005 Rabia 20 C++
1006 Reha 20 C

Student Course:

DEP_NO Std_n Course_name


o
1 1001 Python
1 1002 Java,Html
1 1002 Html
1 1003 C
2 1004 Python
2 1005 C++
2 1006 C

Course Details:

Course_nam Course_fee
e
Python 3000
Java,Html 5000
Html 5000
C 4000
Python 5000
C++ 2000
C 2000

QUERY:
 Write a query that shows course that has fee “3000”?
SELECT *
FROM ‘Course Details’;
WHERE ‘Course_fee=3000’
 Write a query that shows name of std who has age ‘19’?
SELECT *
FROM ‘Student Details’;
WHERE ‘Std_age=19’;
RELATIONSHIPS:

ER DIAGRAM:

Case 02:
Few Employees work for one project.
Entities: PROJECT, EMPLOYEE, JOB
Attributes: PROJ_NUM, PROJ_NAME, EMP_NUM, EMP_Name, JOB_Class, Salary
Primary Keys: PROJ_NUM, EMP_NUM
Non-Normalize Database:
PROJ_NUM PROJ_NAME EMP_NUM EMP_Name JOB_Class Salary

15 Software Project 101 Zainab Database 10000/


Designer/ 19000
Operator
15 Software Project 103 Nimra Programmer 20000
15 Software Project 107 Kiran Web 40000
Developer
15 Software Project 102 Ayesha Computer 19000
Operator
15 Software Project 106 Rabia Programmer 20000
15 Software Project 104 Reha Database 10000
Designer

1ST Normal Form (1NF):


To bring it to 1NF, remove the repeating groups.

PROJ_NUM PROJ_NAME EMP_NUM EMP_Name JOB_Class Salary

15 Software Project 101 Zainab Database 10000


Designer
15 Software Project 101 Zainab Operator 19000
15 Software Project 103 Nimra Programmer 20000
15 Software Project 107 Kiran Web 40000
Developer
15 Software Project 102 Ayesha Computer 19000
Operator
15 Software Project 106 Rabia Programmer 20000
15 Software Project 104 Reha Database 10000
Designer

2ND Normal Form (2NF):


To bring it to 2NF, it must be in 1NF and there is no partial dependency exist.
PROJECT:

PROJ_NUM PROJ_NAME
15 Software Project
15 Software Project
15 Software Project
15 Software Project
15 Software Project
15 Software Project
15 Software Project

EMPLOYEE:

EMP_NUM EMP_Name JOB_Class Salary

101 Zainab Database 10000


Designer
101 Zainab Operator 19000
103 Nimra Programmer 20000
107 Kiran Web 40000
Developer
102 Ayesha Computer 19000
Operator
106 Rabia Programmer 20000
104 Reha Database 10000
Designer

3RD Normal Form (3NF):


To bring it to 3NF, it must be in 2NF and there is no transitive dependency exist.
PROJECT:

PROJ_NUM PROJ_NAME
15 Software Project
15 Software Project
15 Software Project
15 Software Project
15 Software Project
15 Software Project
15 Software Project

EMPLOYEE:

EMP_NUM EMP_Name JOB_Class

101 Zainab Database Designer


101 Zainab Operator
103 Nimra Programmer
107 Kiran Web Developer
102 Ayesha Computer
Operator
106 Rabia Programmer
104 Reha Database Designer

JOB:

JOB_Class Salary

Database Designer 10000


Operator 19000
Programmer 20000
Web Developer 40000
Computer Operator 19000
Programmer 20000
Database Designer 10000

QUERY:
 Write a query that shows employee name that has Salary “40000”?
SELECT *
FROM ‘JOB’;
WHERE ‘Salary=40000’
 Write a query that shows name of employee who has EMP_NUM ‘102’?
SELECT *
FROM ‘EMPLOYEE’;
WHERE ‘EMP_NUM=102’;

RELATIONSHIPS:
ER DIAGRAM:

Case 03:
Clothing Store Database
Entities: ITEM, ITEM_PRICE, ITEM_TAX
Attributes: Item name, Colors, Price, Tax
Primary Keys: Item name, Price
Non-Normalize Database:

Item name Colors Price Tax


T-Shirt Black 1200 0.60
Sweat shirt Red/Blue 1200 1.25
Hoodies Blue 2500 0.60
Coat Camel/Black 3000 1.25
1ST Normal Form (1NF):
To bring it to 1NF, remove the repeating groups.

Item name Colors Price Tax


T-Shirt Black 1200 0.60
Sweat shirt Red 1200 1.25
Sweat shirt Blue 1200 1.25
Hoodies Blue 2500 0.60
Coat Camel 3000 1.25
Coat Black 3000 1.25

2ND Normal Form (2NF):


To bring it to 2NF, it must be in 1NF and there is no partial dependency exist.
ITEM:

Item name Colors


T-Shirt Black
Sweat shirt Red
Sweat shirt Blue
Hoodies Blue
Coat Camel
Coat Black
ITEM_PRICE:

Item name Price Tax


T-Shirt 1200 0.60
Sweat shirt 1200 1.25
Sweat shirt 1200 1.25
Hoodies 2500 0.60
Coat 3000 1.25
Coat 3000 1.25

3RD Normal Form (3NF):


To bring it to 3NF, it must be in 2NF and there is no transitive dependency exist.
ITEM:

Item name Colors


T-Shirt Black
Sweat shirt Red
Sweat shirt Blue
Hoodies Blue
Coat Camel
Coat Black

ITEM_PRICE:

Item name Price


T-Shirt 1200
Sweat shirt 1200
Sweat shirt 1200
Hoodies 2500
Coat 3000
Coat 3000

ITEM_TAX:

Item name Tax


T-Shirt 0.60
Sweat shirt 1.25
Sweat shirt 1.25
Hoodies 0.60
Coat 1.25
Coat 1.25

QUERY:
 Write a query that shows item name that has Tax ‘0.25'?
SELECT *
FROM ‘ITEM_TAX’;
WHERE ‘Tax=0.25’;
 Write a query that shows the color of item who has Price ‘2500’?
SELECT *
FROM ‘ITEM_PRICE’;
WHERE ‘Price=2500’;

RELATIONSHIPS:
ER DIAGRAM:

Case 04:
Ride Company UBER Database
Entities: DRIVER, RIDER, PAYMENT
Attributes: Driver_ID, Cab-ID, Rider_ID, Rider_Gender, Payment, Destination
Primary Keys: Item name, Price
Non-Normalize Database:

Driver_ID Cab_ID Rider_ID Rider_Gender Payment Destination


A10 LA10 50,51 Female,Male 1000 Okara
Z03 MZ03 65 Male 1300 Renala
N07 KN07 74 Female 1200 Lahore
U15 UK15 25 Male 2000 Depalpur

1ST Normal Form (1NF):


To bring it to 1NF, remove the repeating groups.

Driver_ID Cab_ID Rider_ID Rider_Gender Payment Destination


A10 LA10 50 Female 1000 Okara
A10 LA10 51 Male 1000 Okara
Z03 MZ03 65 Male 1300 Renala
N07 KN07 74 Female 1200 Lahore
U15 UK15 25 Male 2000 Depalpur

2ND Normal Form (2NF):


To bring it to 2NF, it must be in 1NF and there is no partial dependency exist.
DRIVER:

Driver_ID Cab_ID Rider_ID


A10 LA10 50
A10 LA10 51
Z03 MZ03 65
N07 KN07 74
U15 UK15 25

RIDER:

Rider_ID Rider_Gender Payment Destination


50 Female 1000 Okara
51 Male 1000 Okara
65 Male 1300 Renala
74 Female 1200 Lahore
25 Male 2000 Depalpur

3RD Normal Form (3NF):


To bring it to 3NF, it must be in 2NF and there is no transitive dependency exist.
DRIVER:

Driver_ID Cab_ID Rider_ID


A10 LA10 50
A10 LA10 51
Z03 MZ03 65
N07 KN07 74
U15 UK15 25

RIDER:

Rider_ID Rider_Gender Destination


50 Female Okara
51 Male Okara
65 Male Renala
74 Female Lahore
25 Male Depalpur
PAYMENT:

Rider_ID Payment
50 1000
51 1000
65 1300
74 1200
25 2000

QUERY:
 Write a query that shows the rider gender whose destination is ‘Lahore’'?
SELECT *
FROM ‘RIDER’;
WHERE ‘Destination=Lahore’;
 Write a query that shows the CAB_ID that contain RIDER_ID=50?
SELECT *
FROM ‘DRIVER’;
WHERE ‘RIDER_ID=50’;

RELATIONSHIPS:
ER DIAGRAM:
Case 05:
TRAIN Database
Entities: TRAIN, BOGIES, MODEL
Attributes: Train ID, Train Name, Color, Model, No. of Bogies
Primary Keys: Train ID, Model
Non-Normalize Database:

Train ID Train Name Color Model No. of bogies


2002 Akbar Express Black 21135 9
2003 Allama Iqbal Express Red 09007 10
2007 Attock Passenger Yellow 78601 7,8
2009 Awam express Orange 15901 14

1ST Normal Form (1NF):


To bring it to 1NF, remove the repeating groups.

Train ID Train Name Color Model No. of bogies


2002 Akbar Express Black 21135 9
2003 Allama Iqbal Express Red 09007 10
2007 Attock Passenger Yellow 78601 7
2007 Attock Passenger Yellow 78601 8
2009 Awam express Orange 15901 14

2ND Normal Form (2NF):


To bring it to 2NF, it must be in 1NF and there is no partial dependency exist.
TRAIN:

Train ID Train Name Color


2002 Akbar Express Black
2003 Allama Iqbal Express Red
2007 Attock Passenger Yellow
2007 Attock Passenger Yellow
2009 Awam express Orange

BOGIES:

Train ID Model No. of bogies


2002 21135 9
2003 09007 10
2007 78601 7
2007 78601 8
2009 15901 14

3RD Normal Form (3NF):


To bring it to 3NF, it must be in 2NF and there is no transitive dependency exist.
TRAIN:

Train ID Train Name


2002 Akbar Express
2003 Allama Iqbal Express
2007 Attock Passenger
2007 Attock Passenger
2009 Awam express

MODEL:

Train ID Model
2002 21135
2003 09007
2007 78601
2007 78601
2009 15901
QUERY:
 Write a query that shows the Train Name whose ID is ‘2007’?
SELECT *
FROM ‘TRAIN’;
WHERE ‘Train ID=’2007’;

 Write a query that shows the Train name whose bogies are Black?
SELECT *
FROM ‘Color’;
WHERE ‘Bogies=Black’;

RELATIONSHIPS:
ER DIAGRAM:

Case 06:
RESTURANT Database
Entities: CUSTOMER, PAYMENT, ORDER
Attributes: Customer ID, Name, Order no. , Payment, Date&Time
Primary Keys: Customer ID, Order no.
Non-Normalize Database:

Customer ID Name Order no. Payment Date&Time


S10 Zainab 10,11 2000 2/2/22
5:00,600
A15 Nimra 52 1500 2/4/21
6:00
Z21 Kiran 7 2500 5/9/20
1:00

1ST Normal Form (1NF):


To bring it to 1NF, remove the repeating groups.

Customer ID Name Order no. Payment Date&Time


S10 Zainab 10 2000 2/2/22
5:00
S10 Zainab 11 2000 2/2/22
6:00
A15 Nimra 52 1500 2/4/21
6:00
Z21 Kiran 7 2500 5/9/20
1:00

2ND Normal Form (2NF):


To bring it to 2NF, it must be in 1NF and there is no partial dependency exist.
CUSTOMER:

Customer ID Name Payment


S10 Zainab 2000
S10 Zainab 2000
A15 Nimra 1500
Z21 Kiran 2500

ORDER:

Customer ID Order no. Date&Time


S10 10 2/2/22
5:00
S10 11 2/2/22
6:00
A15 52 2/4/21
6:00
Z21 7 5/9/20
1:00
3RD Normal Form (3NF):
To bring it to 3NF, it must be in 2NF and there is no transitive dependency exist.
CUSTOMER:

Customer ID Name
S10 Zainab
S10 Zainab
A15 Nimra
Z21 Kiran

PAYMENT:

Customer ID Payment
S10 2000
S10 2000
A15 1500
Z21 2500

ORDER:

Customer ID Order no. Date&Time


S10 10 2/2/22
5:00
S10 11 2/2/22
6:00
A15 52 2/4/21
6:00
Z21 7 5/9/20
1:00

QUERY:
 Write a query that shows the Order no. of Name ‘Zainab’?
SELECT *
FROM ‘ORDER’;
WHERE ‘Name=Zainab’;

 Write a query that shows the payment of Customer ID ‘S10’?


SELECT *
FROM ‘Payment’;
WHERE ‘Customer ID=S10’;

RELATIONSHIPS:

ER DIAGRAM:

You might also like