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

Week5TutorialQuestion1Solution_91647

question

Uploaded by

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

Week5TutorialQuestion1Solution_91647

question

Uploaded by

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

Switch off your Mobiles Phones

or
Change Profile to Silent Mode
Tutorial Normalisation
Steps in Normalisation
Steps in Normalisation

Unnormalised
(UNF)
Remove Repeating Groups

First Normal Form


(1NF)

Remove Partial Dependencies

Second Normal
Form
(2NF)
Remove Transitive Dependencies

Third Normal Form


(3NF)
Functional Dependencies (FD)
■ Normalisation is based on analysis of Functional
Dependence.
■ Functional Dependency is particular
Relationship between two Attributes.
■ Attribute B is Functionally Dependent upon
Attribute A (or a collection of attributes) if a
value of A determines a single value of B at any
one time.
■ Value of one Attribute (collection of attributes)
determines value of another Attribute
Functional Dependencies (FD)
■ Notation for this Functional Dependency (FD)
is: A 🡪 B
■ Notation is read “A determines B” or “B is
Functionally Dependent on A”.
■ A is called Determinant and B is called object
of Determinant.
■ Composite Determinant is made up of more
than one attribute: X, Y 🡪 Z
Functional Dependencies (FD)
■ Two terms relevant with Composite
Determinants
■ Full Functional Dependency (FFD)
■ If it is necessary to use all the attributes of
Composite Determinant to identify its object
uniquely, we have Full Functional Dependency.
■ Partial Functional Dependency (PFD)
■ Dependency exists if it is necessary to use only a
subset of the Attributes of a Composite
Determinant to identify the object uniquely.
Transitive Dependency (TD)
■ Transitive Dependency exists when there is an
intermediate dependency. Assume three
attributes A, B and C. Further assume that the
following Functional Dependencies exist
■ A🡪B
■ B🡪C
■ Then it can be stated that the following
Transitive Dependency also holds
■ A🡪B🡪C
Question 1
■ Consider the student registration form below.
100
Ram Thapa
Ason

CC2E01 Employment Prabin Maskey


101
Skill
Prashant Thapa
CC2006 Databases 100
Software Rubin Aryal
CC2007 Engineering 102
■ Assumption
■ One Student can take multiple Module
■ One Module is taught by One Tutor
Question 1 – With Data
Question 1 – With Data
Question 1 – UNF
a. All attributes with repeating groups included in a
single Relation
■ Writing down all the attributes from the form
above – call this entity Student
Student(Student_No, Student_Name, Student_Address
Module_No, Module_Title, Tutor_Number, Tutor)
■ Choosing suitable identifier for this Student entity
Student(Student_No, Student_Name, Student_Address
Module_No, Module_Title, Tutor_Number, Tutor)
■ Find and show any repeating group (remember to
use { }).
Student(Student_No, Student_Name, Student_Address
{Module_No, Module_Title, Tutor_Number, Tutor})
Question 1 – UNF with Data

Repeating Repeating
Data Group
Question 1 - UNF
■ Note
■ We may not have any Repeating Group in the UNF
relation then this relation is already in 1NF.
■ We may have one Repeating Group and then
another Repeating Group in the UNF relation
■ We may have Repeating Group within another
Repeating Group in the UNF relation.
■ We may have Composite Unique Identifier in the
UNF relation
Question 1 – 1NF
b. 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)
■ Removing Repeating Group to write separate
relations (One Old and New). Name new relations
Student(Student_No, Student_Name, Student_Address
{Module_No, Module_Title, Tutor_Number, Tutor})

Student(Student_No, Student_Name, Student_Address)


Student_Module(Module_No, Module_Title, Tutor_Number,
Tutor)
Question 1 – 1NF
■ Carry forward Unique Identifier to new Relation
Student(Student_No, Student_Name, Student_Address)
Student_Module(Student_No, Module_No, Module_Title,
Tutor_Number, Tutor)
■ Choose Unique Identifier for this new Relation.
Student_Module(Student_No, Module_No, Module_Title,
Tutor_Number, Tutor)
Hint: Carry forwarded attribute will be part of the Unique
Identifier
■ Our 1 NF Relations are
Student(Student_No, Student_Name, Student_Address)
Student_Module(Student_No, Module_No, Module_Title,
Tutor_Number, Tutor)
Question 1 - 1NF with Data
Question 1 – 2NF
c. Any Partial Functional Dependencies have been
removed from the Relation
■ Finding any Partial Functional Dependencies
■ For Partial Functional Dependency, you must have
Composite Determinant.
■ If you do not have Composite Determinant, then
that relation is already in 2NF.
■ Relation with only Key Attribute (Single or
Composite) is already in Second Normal Form
■ Need to check for Partial Functional Dependency in
all Relation with Composite Key and at least One
Non Key.
Question 1 – 2NF
■ Here Student relation is already in 2NF
■ Check Student_Module relation by putting all the
combination of the Determinant (Full and Part)
Student_No, Module_No 🡪
Student_No 🡪
Module_No 🡪
■ Now check the Functional Dependency of Non key
attribute to these Determinant (Full and Part)
Student_Module(Student_No, Module_No, Module_Title,
Tutor_Number, Tutor)
Student_No, Module_No 🡪
Student_No 🡪
Module_No 🡪 Module_Title, Tutor_Number, Tutor
Question 1 – 2NF
■ If we have the Full Functional Dependency with
attributes then that will be our old relation with
only those attributes.
■ If we do not have Functional Dependency with Full
Unique Identifier even then we need this relation
as it is a old relation without Non Key attributes
(attribute remove), only with Unique Identifier.
■ Here Student_Module satisfies above condition,
so we will have Student_Module without Non Keys
Student_Module(Student_No, Module_No)
■ If we have Functional Dependency with part of the
Unique Identifier then we have Partial Functional
Dependencies
Question 1 – 2NF
■ Here we have Partial Functional Dependency for
Student_Module Relation.
■ Module_No is part of the Composite Key and
Module_Title, Tutor_Number, Tutor depends on
Module_No.
Module_No 🡪 Module_Title, Tutor_Number, Tutor
■ Separate this Partial Functional Dependency to
form a new relation and name it. The Determinant
will be the Unique Identifier.
Module(Module_No, Module_Title, Tutor_Number, Tutor)
Question 1 – 2NF
■ If we do not have any attribute with the Part of the
Unique Identifier, we do not have Partial
Dependency with this Determinant. So we do not
need this as a new relation, just discard it, So
Student_No 🡪 (Discard this)

■ Our 2NF relations are


Student(Student_No, Student_Name, Student_Address)
Student_Module(Student_No, Module_No)
Module(Module_No, Module_Title, Tutor_Number, Tutor)
Question 1 - 2NF with Data
Question 1 – 3NF
d. Any Transitive Dependencies have been removed
from the Relation
■ Finding Any Transitive Dependencies (remember to
use 🡪)
■ When Non Key determines another Non Key then
we have Transitive Dependency
■ Check in all relation with two or more Non Key
Attribute. If there are no Non Key Attribute or only
one Non Key then its in 3NF
■ Here Student_Module have only Key Attribute in
relation, which is in already in 3NF
Student_Module(Student_No, Module_No)
Question 1 – 3NF
■ Here we have more than one Non Key Attribute in
Student(Student_No, Student_Name, Student_Address)
Module(Module_No, Module_Title, Tutor_Number,Tutor)
■ Lets check for Transitive Dependency in Student
Student_No 🡪 Student_Name, Student_Address
■ Can Student_Name determine Student_Address or
can Student_Address determine Student_Name. If
the answer is No then we do not have Transitive
Dependency. Student is already in 3NF
Student(Student_No, Student_Name, Student_Address)
■ Lets check for Transitive Dependency in Module
Module_No 🡪 Module_Name
Module_No 🡪 Tutor_Number 🡪 Tutor
Question 1 – 3NF
■ Here we have Transitive Dependency in Module
■ Once we have Transitive Dependency, separate this
into Determinant determines Non Key and then the
Non Key determines another Non Key
Module_No 🡪 Tutor_Number 🡪 Tutor
■ Now separate this as
Module_No 🡪 Tutor_Number
Tutor_Number 🡪 Tutor
■ Module is our existing relation having Unique
Identifier as Module_No. So now we will have
Module with
Module(Module_No, Module_Name, Tutor_Number)
Question 1 – 3NF
■ We need to create a new relation for
Tutor_Number 🡪 Tutor
■ Lets create new relation Tutor with Tutor_Number
and Tutor as attributes.
Tutor(Tutor_Number, Tutor)
■ The determinant Tutor_Number will be the Unique
Identifier for this new relation Tutor
Tutor(Tutor_Number, Tutor)
Question 1 – 3NF
■ Our 3NF will be
Student(Student_No, Student_Name, Student_Address)
Module(Module_No, Module_Title , Tutor_Number)
Student_Module(Student_No, Module_No)
Tutor(Tutor_Number, Tutor)
Question 1 - 3NF with Data
Question 1
■ Consider the student registration form below.
100
Ram Thapa
Ason

CC2E01 Employment Skill 101 Prabin Maskey


CC2006 Databases
Software 100 Prashant Thapa
CC2007 Engineering 102 Rubin Aryal
CC2006 Databases 103 Gopal Thapa
■ Assumption
■ One Student can take multiple Module
■ One Module is taught by multiple Tutor
Question 1 – With Data
Question 1 – UNF
a. All attributes with repeating groups included in a
single Relation
■ Writing down all the attributes from the form
above – call this entity Student
Student(Student_No, Student_Name, Student_Address
Module_No, Module_Title, Tutor_Number, Tutor)
■ Choosing suitable identifier for this Student entity
Student(Student_No, Student_Name, Student_Address
Module_No, Module_Title, Tutor_Number, Tutor)
■ Find and show any repeating group (remember to
use { }).
Student(Student_No, Student_Name, Student_Address
{Module_No, Module_Title, {Tutor_Number, Tutor}})
Question 1 – UNF with Data
Question 1 – UNF with Data
Question 1 - UNF
■ Note
■ We may not have any Repeating Group in the UNF
relation then this relation is already in 1NF.
■ We may have one Repeating Group and then
another Repeating Group in the UNF relation
■ We may have Repeating Group within another
Repeating Group in the UNF relation.
■ We may have Composite Unique Identifier in the
UNF relation
Question 1 – 1NF
b. 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)
■ Removing all the Repeating Group by separating
and creating new entities. For new entity Name it.
■ If we have Repeating Group within another
Repeating Group the follow the steps below.
Question 1 – 1NF
■ Step 1: Remove the Outer Most Repeating Group
to form new Relation and name it.
Student(Student_No, Student_Name, Student_Address
{Module_No, Module_Title, {Tutor_Number, Tutor}})

Student(Student_No, Student_Name, Student_Address)


Student_Module(Module_No, Module_Title, {Tutor_Number,
Tutor})
Question 1 – 1NF
■ Step 2: Carry forward Unique Identifier to this
Relation.
Student(Student_No, Student_Name, Student_Address)
Student_Module(Student_No, Module_No, Module_Title,
{Tutor_Number, Tutor})
■ Step 3: Choose Unique Identifier for this new
Relation.
Student_Module(Student_No, Module_No, Module_Title,
{Tutor_Number, Tutor})
Hint: Carry forwarded attribute will be part of the Unique
Identifier
Question 1 – 1NF
■ Step 4: Repeat Step 1 to Step 3 till all Repeating
Groups have been removed
■ Here we still have Repeating Group so perform
Step 1 to Step 3.
Student_Module(Student_No, Module_No, Module_Title)
Student_Module_Tutor(Student_No,Module_No,Tutor_Number,
Tutor)
■ Our 1 NF Relations are.
Student(Student_No, Student_Name, Student_Address)
Student_Module(Student_No, Module_No, Module_Title)
Student_Module_Tutor(Student_No,Module_No,Tutor_Number,
Tutor)
Question 1 – 1NF with Data
Question 1 - 1NF with Data
Question 1 – 2NF
c. Any Partial Functional Dependencies have been
removed from the Relation
■ For Partial Functional Dependency, we must have
Composite Determinant.
■ If we do not have Composite Determinant, then
that relation is already in 2NF.
■ Relation with only Key Attribute (Single or
Composite) is already in Second Normal Form
■ Here Student relation is already in 2NF
Student(Student_No, Student_Name, Student_Address)
■ Need to check for Partial Functional Dependency in
all Relation with Composite Key and at least One
Question 1 – 2NF
■ Student_Module and Student_Module_Tutor
relations have Composite Unique Identifier
■ Check in Student_Module by putting all the
combination of the Determinant (Full and Part)
Student_No, Module_No 🡪
Student_No 🡪
Module_No 🡪
■ Now check the Functional Dependency of Non key
attribute to these Determinant (Full and Part)
Student_Module(Student_No, Module_No, Module_Title)
Student_No, Module_No 🡪
Student_No 🡪
Module_No 🡪 Module_Title
Question 1 – 2NF
■ If we have the Full Functional Dependency with
attributes then that will be our old relation with
only those attributes.
■ If we not have Functional Dependency with Full
Unique Identifier even then we need this relation
as it is a old relation without Non Key attributes
(attribute remove), only with Unique Identifier.
■ Here Student_Module satisfies above condition,
so we will have Student_Module without Non Keys
Student_Module(Student_No, Module_No)
■ If we have Functional Dependency with part of the
Unique Identifier then we have Partial Functional
Dependencies
Question 1 – 2NF
■ Here we have Partial Functional Dependency for
Student_Module Relation.
■ Module_No is part of the Composite Key and
Module_Title depends on Module_No.
Module_No 🡪 Module_Title
■ Separate this Partial Functional Dependency to
form a new relation and name it. The Determinant
will be the Unique Identifier.
Module(Module_No, Module_Title)
Question 1 – 2NF
■ If we do not have any attribute with the Part of the
Unique Identifier, we do not have Partial
Dependency with this Determinant. So we do not
need this as a new relation, just discard it, So
Student_No 🡪 (Discard this)

■ Our 2NF for Student_Module relations are


Student_Module(Student_No, Module_No)
Module(Module_No, Module_Title)
Question 1 – 2NF
■ Check in Student_Module_Tutor by putting all
the combination of the Determinant (Full and Part)
Student_No, Module_No, Tutor_No 🡪
Student_No, Module_No 🡪
Module_No, Tutor_No 🡪
Student_No, Tutor_No 🡪
Student_No 🡪
Module_No 🡪
Tutor_No 🡪
Question 1 – 2NF
■ Now check the Functional Dependency of Non key
attribute to these Determinant (Full and Part)
Student_Module_Tutor(Student_No,Module_No,Tutor_Number,
Tutor)
Student_No, Module_No, Tutor_No 🡪
Student_No, Module_No 🡪
Module_No, Tutor_No 🡪
Student_No, Tutor_No 🡪
Student_No 🡪
Module_No 🡪
Tutor_No 🡪 Tutor
Question 1 – 2NF
■ Here we have Partial Functional Dependency for
Student_Module_Tutor Relation.
■ Tutor_Number is part of the Composite Key and
Tutor depends on Tutor_Number.
Tutor_Number 🡪 Tutor
■ Separate this Partial Functional Dependency to
form a new relation and name it. The Determinant
will be the Unique Identifier.
Tutor(Tutor_Number, Tutor)
Question 1 – 2NF
■ If we have the Full Functional Dependency with
attributes then that will be your old relation with
only those attributes.
■ If we not have Functional Dependency with Full
Unique Identifier even then we need this relation
as it is a old relation without Non Key attributes
(attribute remove), only with Unique Identifier.
■ Here Student_Module_Tutor satisfies above
condition, so we will have Student_Module_Tutor
without Non Keys
Student_Module_Tutor(Student_No,Module_No,Tutor_Number)
Question 1 – 2NF
■ If we do not have any attribute with the Part of the
Unique Identifier, we do not have Partial
Dependency with this Determinant. So you do not
need this as a new relation, just discard it, So
Student_No, Module_No 🡪 (Discard this)
Module_No, Tutor_No 🡪 (Discard this)
Student_No, Tutor_No 🡪 (Discard this)
Student_No 🡪 (Discard this)
Module_No 🡪 (Discard this)
■ Our 2NF relations for Student_Module_Tutor are
Student_Module_Tutor(Student_No,Module_No,Tutor_Number)
Tutor(Tutor_Number, Tutor)
Question 1 – 2NF
■ Our Final 2NF relations are
Student(Student_No, Student_Name, Student_Address)
Student_Module(Student_No, Module_No)
Module(Module_No, Module_Title)
Student_Module_Tutor(Student_No,Module_No,Tutor_Number)
Tutor(Tutor_Number, Tutor)
Question 1 - 2NF with Data
Question 1 – 3NF
b. Any Transitive Dependencies have been removed
from the Relation
■ Finding Any Transitive Dependencies (remember to
use 🡪)
■ When Non Key determines another Non Key then
we have Transitive Dependency
■ If we have only Unique Identifier or only one Non
Key Attribute, then that relations is in 3NF
■ Student_Module and Student_Module_Tutor
have only Key Attribute in relation, and Module
and Tutor have only one Non Key Attribute in
relation, so its already in 3NF
Question 1 – 3NF
■ Student relation have more than one Non Key
■ Lets check for Transitive Dependency in Student
Student_No 🡪 Student_Name, Student_Address
■ Can Student_Name determine Student_Address or
can Student_Address determine Student_Name. If
the answer is No then we do not have Transitive
Dependency. Student is already in 3NF
Student(Student_No, Student_Name, Student_Address)
■ All the Relations in Second Normal Form does not
have Transitive Functional Dependency so all are in
Third Normal Form.
Question 1 – 3NF
■ Our 3NF will be
Student(Student_No, Student_Name, Student_Address)
Module(Module_No, Module_Title)
Student_Module(Student_No,Module_No)
Student_Module_Tutor(Student_No,Module_No,Tutor_Number)
Tutor(Tutor_Number, Tutor)
Question 1 - 3NF with Data

You might also like