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

Week6TutorialQuestion1Solution_91647 (1)

The document outlines the process of normalizing a database schema through various normal forms, specifically focusing on the transition from Un Normal Form (UNF) to First Normal Form (1NF), Second Normal Form (2NF), and finally Third Normal Form (3NF). It details the identification and removal of repeating groups, partial functional dependencies, and transitive dependencies to achieve a well-structured database. The final relations after normalization include Week, Employee, WeekJob, Job, WeekJobTask, and Task, ensuring that all relations adhere to the rules of normalization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Week6TutorialQuestion1Solution_91647 (1)

The document outlines the process of normalizing a database schema through various normal forms, specifically focusing on the transition from Un Normal Form (UNF) to First Normal Form (1NF), Second Normal Form (2NF), and finally Third Normal Form (3NF). It details the identification and removal of repeating groups, partial functional dependencies, and transitive dependencies to achieve a well-structured database. The final relations after normalization include Week, Employee, WeekJob, Job, WeekJobTask, and Task, ensuring that all relations adhere to the rules of normalization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Week 6 Tutorial

Normalisation
Question Table
Business Rule
● There is precisely One Sheet for Each Employee
for Each Week.
● Sheets are not Numbered
● Each Employee belongs to One Department
● Employee No values and Department No values
are Unique.
Business Rule
● Employee Names are NOT Unique.
● Each Job is assign a Unique Job No and
corresponding Non Unique Job Description
● The Sheet gives Hours worked by the particular
Employee in the Week on a particular Task as part
of the Job
Table with Data
Un Normal Form (UNF)

Repeating
Data
Un Normal Form (UNF)
● All attributes with repeating groups included in a
single Relation
○ Write down all Attributes from the table above and
name this Relation.
Week(EmployeeName, EmployeeNo, DepartmentNo,
WeekNo, JobNo, JobDescription, Task, Rate, Hours)
○ Choose a suitable Unique Identifier for this
Relation
Week(EmployeeName, EmployeeNo, DepartmentNo,
WeekNo, JobNo, JobDescription, Task, Rate, Hours)
Un Normal Form (UNF)
● All attributes with repeating groups included in a
single Relation
○ Write down all Attributes from the table above and
name this Relation.
○ Choose a suitable Unique Identifier for this
Relation
○ Show Repeating Group within { } in this Relation
Week(EmployeeName, EmployeeNo, DepartmentNo,
WeekNo, {JobNo, JobDescription, {Task, Rate, Hours}})
Un Normal Form (UNF)
● All attributes with repeating groups included in a
single Relation
○ If we do not have Repeating Group in UNF, this
Relation is already in First Normal Form (1NF)
○ You may have one Repeating Group within another
Repeating Group
○ You may have one Repeating Group then another
Repeating Group.
○ You may even have Single or Composite Unique
key in UNF.
Un Normal Form (UNF)

Repeating
Data
First Normal Form (1NF)
● Any repeating groups have been removed, so that
there is a single value at the intersection of each
row and column of the Relation
○ Relation without Repeating Group is already in First
Normal Form (1NF)
○ Remove all Repeating Group forming new Relations
○ Step 1: Remove the Outer Most Repeating Group to
form new Relation and name it.
Week(EmployeeName, EmployeeNo, DepartmentNo, WeekNo)
WeekJob(JobNo, JobDescription, {Task, Rate, Hours})
First Normal Form (1NF)
● Any repeating groups have been removed, so that
there is a single value at the intersection of each
row and column of the Relation
○ Step 1: Remove the Outer Most Repeating Group to
form new Relation, name it.
○ Step 2: Carry forward Unique Identifier to this Relation.
Week(EmployeeName, EmployeeNo,WeekNo, DepartmentNo)

WeekJob(EmployeeNo, WeekNo, JobNo, JobDescription, {Task,


Rate, Hours})
First Normal Form (1NF)
● Any repeating groups have been removed, so that
there is a single value at the intersection of each
row and column of the Relation
○ Step 1: Remove the Outer Most Repeating Group to
form new Relation, name it.
○ Step 2: Carry forward Unique Identifier to this Relation.
○ Step 3: Choose Unique Identifier for this new Relation.
Week(EmployeeName, EmployeeNo, DepartmentNo, WeekNo)
WeekJob(EmployeeNo, WeekNo, JobNo, JobDescription, {Task,
Rate, Hours}) Hint: Carry forwarded Unique Identifier will be part of the Unique Identifier of the
new Relation. Choose attribute of this Relation to form Unique Identifier
First Normal Form (1NF)
● Any repeating groups have been removed, so that
there is a single value at the intersection of each
row and column of the Relation
○ Step 4: Repeat Step 1 to Step 3 till all Repeating
Groups have been removed
○ Here you still have Repeating Group so perform Step 1
to Step 3.
WeekJob(EmployeeNo, WeekNo, JobNo, JobDescription)
WeekJobTask(EmployeeNo, WeekNo, JobNo, Task, Rate, Hours)
First Normal Form (1NF)
Final First Normal Form
Week(EmployeeName, DepartmentNo, EmployeeNo,
WeekNo)
WeekJob(EmployeeNo, WeekNo, JobNo, JobDescription)
WeekJobTask(EmployeeNo, WeekNo, JobNo, Task, Rate,
Hours)
First Normal Form (1NF)
Second Normal Form (2NF)
● Any Partial Functional Dependencies have been
removed from the Relation
○ Find and Separate Partial Functional Dependency.
○ Need to check for Partial Functional Dependency
in all Relation with Composite Key
○ Relation without Composite Key is already in
Second Normal Form
Second Normal Form (2NF)
● Any Partial Functional Dependencies have been
removed from the Relation
○ Relation with only Key Attribute (Single or
Composite) is already in Second Normal Form
○ Needs to check for Partial Functional Dependency
for Week, WeekJob and WeekJobTask Relations
Second Normal Form (2NF)
Week
EmployeeNo, WeekNo 🡪
EmployeeNo 🡪 EmployeeName, DepartmentNo
WeekNo 🡪
■ Here we have Partial Functional Dependency for Week
Relation.
■ EmployeeNo is part of the Composite Key and
EmployeeName, DepartmentNo depends on
EmployeeNo.
■ Separate this to form a new relation and name it.
■ The determinant EmployeeNo will be the Unique
Identifier for this relation.
Second Normal Form (2NF)
Week
EmployeeNo, WeekNo 🡪
EmployeeNo 🡪 EmployeeName, DepartmentNo
WeekNo 🡪
■ The Composite Key EmployeeNo, WeekNo does not
determine any attribute. But this is from the existing
Relation so it will exist as the old Relation Week, with
only having the Composite Key EmployeeNo, WeekNo
■ WeekNo is part of the Composite Key but it does not
determine any attribute so need not create this as new
Relation.
Second Normal Form (2NF)
From Relation Week of 1NF to
Week(EmployeeNo, WeekNo)
Employee(EmployeeNo, EmployeeName, DepartmentNo)
Second Normal Form (2NF)
WeekJob
EmployeeNo, WeekNo, JobNo 🡪
EmployeeNo, WeekNo 🡪
EmployeeNo, JobNo 🡪
WeekNo, JobNo 🡪
EmployeeNo 🡪
WeekNo 🡪
JobNo 🡪 JobDescription
■ Here we have Partial Functional Dependency for
WeekJob Relation.
Second Normal Form (2NF)
■ JobNo is part of the Composite Key and JobDescription
depends on JobNo.
■ Separate this to form a new relation and name it.
■ Determinant JobNo will be Key Attribute for this relation.
■ Composite Key EmployeeNo, WeekNo, JobNo does not
determine any attribute. But this is from the existing
Relation WeekJob so it exist as old Relation with only
having Composite Key EmployeeNo, WeekNo, JobNo
■ Part of the Composite Keys EmployeeNo, WeekNo;
EmployeeNo, JobNo; WeekNo, JobNo; WeekNo;
EmployeeNo but it does not determine any attribute so
need not create new Relations.
Second Normal Form (2NF)
From Relation WeekJob of 1NF to
WeekJob(EmployeeNo, WeekNo, JobNo)
Job(JobNo, JobDescription)
Second Normal Form (2NF)
WeekJobTask
EmployeeNo, WeekNo, JobNo, Task 🡪 Hours
EmployeeNo, WeekNo, JobNo 🡪
EmployeeNo, WeekNo, Task 🡪
EmployeeNo, JobNo, Task 🡪
WeekNo, JobNo, Task 🡪
EmployeeNo, WeekNo 🡪
EmployeeNo, JobNo 🡪
EmployeeNo, Task 🡪
WeekNo, JobNo 🡪
WeekNo, Task 🡪
Second Normal Form (2NF)
WeekJobTask
JobNo, Task 🡪
EmployeeNo 🡪
WeekNo 🡪
JobNo 🡪
Task 🡪 Rate
■ Here we have Partial Functional Dependency for
WeekJobTask Relation.
■ Task is part of the Composite Key and Rate depends on
Task
■ Separate this to form a new relation and name it.
Second Normal Form (2NF)
■ Determinant Task will be Key Attribute for this relation.
■ Composite Key EmployeeNo, WeekNo, JobNo, Task is
from existing Relation WeekJobTask and determines
Hours.
■ Part of the Composite Keys EmployeeNo, WeekNo,
JobNo; EmployeeNo, WeekNo, Task; EmployeeNo,
JobNo, Task; WeekNo, JobNo, Task; EmployeeNo,
WeekNo; EmployeeNo, JobNo; EmployeeNo, Task;
WeekNo, JobNo; WeekNo, Task; JobNo, Task;
EmployeeNo; WeekNo and JobNo but it does not
determine any attribute so need not create new
Relations.
Second Normal Form (2NF)
From Relation WeekJobTask of 1NF to
WeekJobTask(EmployeeNo, WeekNo, JobNo, Task, Hours)
Task(Task, Rate)
Second Normal Form (2NF)
Final Second Normal Form
Week(EmployeeNo, WeekNo)
Employee(EmployeeNo, EmployeeName, DepartmentNo)
WeekJob(EmployeeNo, WeekNo, JobNo)
Job(JobNo, JobDescription)
WeekJobTask(EmployeeNo, WeekNo, JobNo, Task, Hours)
Task(Task, Rate)
Second Normal Form (2NF)
Third Normal Form (3NF)
● Any Transitive Dependencies have been removed
from the Relation
○ Find and Separate Transitive Functional Dependency.
○ Need to check for Transitive Functional Dependency in
all Relation with more than one Non Key Attribute
○ Relation with only one Non Key Attribute is already in
Third Normal Form
■ Here Job, WeekJobTask and Task Relations are already
in Third Normal Form
Third Normal Form (3NF)
● Any Transitive Dependencies have been removed
from the Relation
○ Relation with only Key Attribute (Single or Composite
Key) is already in Third Normal Form
■ Here Week and WeekJob Relations are already in

Third Normal Form


○ Needs to check for Transitive Functional Dependency

for Employee Relation


EmployeeNo 🡪 EmployeeName
Third Normal Form (3NF)
EmployeeNo 🡪 DepartmentNo
So
EmployeeNo 🡪 EmployeeName, DepartmentNo
■ Employee Relation does not have Transitive Functional
Dependency so is already in Third Normal Form
○ All the Relations in Second Normal Form does not
have Transitive Functional Dependency so all are
in Third Normal Form.
Third Normal Form (3NF)
Final Third Normal Form
Week(EmployeeNo, WeekNo)
Employee(EmployeeNo, EmployeeName, DepartmentNo)
WeekJob(EmployeeNo, WeekNo, JobNo)
Job(JobNo, JobDescription)
WeekJobTask(EmployeeNo, WeekNo, JobNo, Task, Hours)
Task(Task, Rate)
Third Normal Form (3NF)
Thank You

You might also like