Professional Documents
Culture Documents
Normalisation Example With Ans
Normalisation Example With Ans
Consider a table that stores information about customers and their orders, with the following
:columns
CustomerName
CustomerAddress
CustomerCity
CustomerState
OrderDate
OrderTotal
OrderItem
OrderQuantity
Normalize it to Third Normal Form. Show all the necessary step and explanation for first and
second normal form too.
In its current state, this table violates the first normal form (1NF) because it allows for repeating groups.
For example, if a customer places multiple orders, their name and address information is repeated in
.each row of the table. This can lead to data redundancy and inconsistency
)marks 3 (
To normalize the table to 1NF, we can split it into two separate tables: one for customer information
:and one for order information. The customer table would have the following columns
CustomerAddress
CustomerCity
CustomerState
OrderDate
OrderTotal
We can then eliminate the repeating groups by creating a new table called "OrderItems" with the
:following columns
OrderItem
OrderQuantity
This ensures that each piece of information is only listed once in the database, and allows for easier
.management of customer and order data
To normalize the table to 2NF, we need to ensure that each non-key column in the order table is fully
dependent on the primary key (OrderID). In its current state, the "OrderTotal" column is dependent on
both the "OrderID" and "OrderItem" columns. To resolve this, we can create a new table called
:"OrderItemDetails" with the following columns
OrderItem
ItemPrice
OrderQuantity
This separates the item price and quantity from the order total, ensuring that the order total is only
.dependent on the order ID
Third Normal Form (3NF): ( 6 Marks)
To normalize the table to 3NF, we need to ensure that there are no transitive dependencies. In its
current state, the "CustomerCity" and "CustomerState" columns are dependent on the
"CustomerAddress" column. To resolve this, we can create a new table called "CustomerAddress" with
:the following columns
AddressLine1
AddressLine2
City
State
ZipCode
We can then remove the "CustomerAddress", "CustomerCity", and "CustomerState" columns from the
:customer table, and instead include a foreign key reference to the "CustomerAddress" table
CustomerName
This ensures that each piece of information is only listed once in the database and allows for easier
.management of customer address data
Consider the following grade report of a student in different courses. The first part of the report
contains general details of the student such as ID of the student, name of the student, department
code, and department name. The second part of the report contains the details of the courses in
which the student obtained a grade. The Id of the course, name of the course, Id of the teacher,
name of the teacher, country of the teacher and the grade obtained by the student in the course is
.given in this part
(a) Normalize the report into 0NF, 1NF, 2NF and 3NF. Show the complete relations with the
given data in each normal form. [11 marks]
Student Grade Report
Introduction to
A Jordan Dr.Wael T1 Computers CS01
(b) List primary keys & foreign keys (if any) of all tables in 3NF in the following format.
[4 marks]
ANSWER
)a(
Un-normalized Form - 1 mark
Table 1 [1 mark]
S_Code S DCode DN
N am
a e
m
e
S8799 A CS Co
s mp
m uter
a Stu
dies
Table 2 [1 mark]
S8799 Introducti
on to
Compute T Dr.W Jord
CS01 rs 1 ael an A
Table 1 [1 mark]
S_Code S DCode DN
N am
a e
m
e
S8799 A CS Co
s mp
m uter
a Stu
dies
Table 2 [1 mark]
S_Code C_ Gr
Co a
de d
e
S8799 CS
01 A
S8799 CS B
04 +
S8799 CS
09 B
Table 3 [1 mark]
C_Code CName TId TName TCty
Introduction
to
CS01 Computers T1 Dr.Wael Jordan
Web
CS09 Technology T1 Dr.Wael Jordan
S_Code S DCode
N
a
m
e
S8799 A CS
s
m
a
DCode DN
am
e
CS Co
mp
uter
Stu
dies
S8799 CS
01 A
S8799 CS B
04 +
S8799 CS
09 B
Introduction
to
CS01 Computers T1
CS04 Networks T2
Web
CS09 Technology T1
T1 Dr.Wael Jordan
T2 Dr.Talib Oman
DEPARTMENT DCode --
TEACHER TId --
Consider the following position report of a student club in different competitions. The first part
of the report contains general details of the club such as code of the club, name of the club,
university code, and university name. The club participates in different competitions. The second
part of the report contains the details of the competitions in which the club participated. The Id of
the competition, name of the competition, Id of the venue, name of the venue, city of the venue
.and the position won by the club in that competition is given in this part
(a) Normalize the report into 0NF, 1NF, 2NF and 3NF. Show the complete relations with the
given data in each normal form. [11 marks]
Student
First Kuwait Al Jahra V1 Conference CP3
Student
Third Bahrain Manama V2 Symposium CP2
[4 marks]
ANSWER
)a(
Un-normalized Form - 1 mark
Table 2 [1 mark]
Table 1 [1 mark]
C_Code C Po
PI s
d
C001 C Fir
P st
3
C001 C Th
P ir
2 d
C001 C Fir
P st
1
Table 3 [1 mark]
C_Code CN UCode
a
m
e
C001 Wi AOU
nn
ers
UCode UName
AOU Arab
Open
Universi
ty
C_Code C Po
PI s
d
C001 C Fir
P st
3
C001 C Th
P ir
2 d
C001 C Fir
P st
1
CP3 Student V1
Conference
CP2 Student V2
Symposium
CP1 Hash Code V2
V1 Al Jahra Kuwait
V2 Manama Bahrain
UNIVERSITY UCode --
VENUE VId --
Consider the following bill of an art shop. The first part of the bill contains details of the
customer and the salesman. The second part of the report contains the details of the product
purchased.
(a) Normalize the report into 0NF, 1NF, 2NF and 3NF. Show the complete relations with the
given data in each normal form. [10 marks]
Bill report
b) Write suitable table names resulting in 3NF and list primary keys & foreign keys (if any) of all
tables in 3NF in the following format.
[5 marks]
ANSWER
(a)
Un-normalized Form - 1 mark
Table 1 [1 mark]
Table 2 [1 mark]
Table 1 [1 mark]
Table 2 [1 mark]
790 OL988 2
790 PS032 1
790 PS451 1
Table 3 [1 mark]
PS032 Pencil 24
Sketch
PS451 Pencil 20
Sketch
SalesCod SalesName
e
EM003 Khamis
790 OL988 2
790 PS032 1
790 PS451 1
PS032 Pencil 24
Sketch
PS451 Pencil 20
Sketch
(b) (Suitable table names – 0.25 * 4 = 1 mark, Identifying correct primary key & foreign
key – 0. 5 *8 = 4 marks)
Answer
It violates the condition for 2NF because guest_name and guest_nationality_code and
guest_nationality_name is only dependent on one part of the primary key (guest_no).
room_type and room_rate is dependent only on one part of the primary key
(room_no)
)marks 2(
b. Normalized relations are shown below: (1.5 marks each)
a. ACCOMMODATION (guest_no, room_no,
start_date_of_stay,end_date_of_stay)
b. GUEST (guest_no, guest_name,guest_nationality_code)
c. GUEST_NATIONALITY (guest_nationality_code, guest_nationality_name)
d. ROOM (room_no, room_type,room_rate)
Answer
Consider the following bill of an art shop. The first part of the bill contains details of the
customer and the salesman. The second part of the report contains the details of the product
purchased.
(a) Normalize the report into 0NF, 1NF, 2NF and 3NF. Show the complete relations with the
given data in each normal form. [10 marks]
Bill report
b) Write suitable table names resulting in 3NF and list primary keys & foreign keys (if any) of all
tables in 3NF in the following format.
[5 marks]
Table 1 [1 mark]
Table 2 [1 mark]
Table 1 [1 mark]
Table 2 [1 mark]
790 OL988 2
790 PS032 1
790 PS451 1
Table 3 [1 mark]
PS032 Pencil 24
Sketch
PS451 Pencil 20
Sketch
SalesCod SalesName
e
EM003 Khamis
790 OL988 2
790 PS032 1
790 PS451 1
PS032 Pencil 24
Sketch
PS451 Pencil 20
Sketch
(b) (Suitable table names – 0.25 * 4 = 1 mark, Identifying correct primary key & foreign
key – 0. 5 *8 = 4 marks)
d. What is the highest normal form that this relation conforms to and why? [3 Marks]
e. Normalise this relation to 3NF, showing the new relations in the manner the
relation PROJECT_ALLOCATION as shown above. Make sure you identify the primary
key for each normalized relation by underlining it [6 Marks]
f. Write simple ‘select’ SQL queries to produce the required normalized relations [6
marks]
Answer