ch4 Slide
ch4 Slide
ch4 Slide
NORMALIZATION
AND
RELATIONAL ALGEBRA
Normalization
Deletion Anomalies
If employee with ID 16 is deleted then
every information about skill C++ and
the type of skill is deleted from the database.
Then we will not have any information about C++ and its skill type.
Insertion Anomalies
What if we have a new employee with a skill Pascal?
We cannot decide whether Pascal is allowed as a value for skill and
we have no clue about the type of skill that Pascal should be categorized as.
Modification Anomalies
if the address for Helico is changed from Piazza to Mexico?
We need to look for every occurrence of Helico School_Add from Piazza to
Mexico,
which is prone to error.
Functional Dependency (FD)
• Since both Wine type and Fork type are determined by the Dinner type, we say
Wine is functionally dependent on Dinner and
Fork is functionally dependent on Dinner.
Dinner → Wine
Dinner → Fork
Types of dependency
Partial Dependency
If an attribute which is not a member of the primary key is
dependent on some part of the primary key (if we have
composite primary key) then
that attribute is partially functionally dependent on the
primary key.
Let {A,B} is the Primary Key and C is non key attribute.
Then if {A, B} →C and B→C or A→C
Then C is partially functionally dependent on {A, B}
Types of dependency
Full Dependency
If an attribute which is not a member of the primary key is
not dependent on some part of the primary key but the
whole key (if we have composite primary key) then
that attribute is fully functionally dependent on the primary
key.
Let {A, B} is the Primary Key and C is a non key attribute
Then if {A, B} →C and B→C and A→C
Then C Fully functionally dependent on {A, B}
Types of dependency
Transitive Dependency
"If A implies B, and
if also B implies C, then
A implies C."
Example:
If Mr X is a Human, and if every Human is an Animal, then Mr X
must be an Animal.
Generalized way of describing transitive dependency is that:
If A functionally governs B, AND
If B functionally governs C
THEN A functionally governs C
Provided that neither C nor B determines A i.e. (B /→ A and C /→ A)
Types of dependency
Un-Normalized Form:
Identify all data elements
First Normal Form:
Find the key with which you can find all data
Second Normal Form:
Remove part-key dependencies.
Make all data dependent on the whole key.
Third Normal Form
Remove non-key dependencies.
Make all data dependent on nothing but the key.
For most practical purposes, databases are considered normalized
if they adhere to third normal form.
First Normal Form (1NF)
• since we don’t have any repeating groups or attributes with multi-valued property.
• This schema is in its 1NF
Second Normal Form (2NF)
To convert it to a 2NF
we need to remove all partial dependencies of non-key attributes on
part of the primary key.
{EmpID, ProjNo}→EmpName, ProjName, ProjLoc, ProjFund,
ProjMangID, Incentive
But in addition to this we have the following dependencies
FD1: {EmpID} → EmpName
FD2: {ProjNo} → ProjName, ProjLoc, ProjFund, ProjMangID
FD3: {EmpID, ProjNo} → Incentive
As we can see,
some non-key attributes are partially dependent on some part of the
primary key.
This can be witnessed by analyzing FD1 and FD2.
Second Normal Form (2NF)
• Generally, even though there are other four additional levels of Normalization, a table
is said to be normalized if it reaches 3NF.
• A database with all tables in the 3NF is said to be Normalized Database.
• Mnemonic for remembering the rationale for normalization up to 3NF could be the
following:
Other Examples on
normalization
Consider this Example:
Other Examples on normalization
Other Examples on
normalization
Other Examples on
normalization
Other Examples on
normalization
Other Examples on
normalization
Generally we can have this
Assignment