Академический Документы
Профессиональный Документы
Культура Документы
Normalization
Intro & 1NF
What is Normalization?
Database design may have some amount of
• Inconsistency
• Uncertainty
• Redundancy
2
Normalization
It is Defined as a step-by-step process of decomposing a
complex relation into a simple and stable data structure.
3
Functional dependency
• In a given relation R, X and Y are attributes. Attribute Y is
functionally dependent on attribute X if each value of X
determines EXACTLY ONE value of Y, which is
represented as X -> Y (X can be composite in nature).
4
Functional dependency
Types of functional dependencies:
5
Functional Dependencies
Consider the following Relation
• For each value of Course# the name of the course will be exactly
one value. So we observe the following Functional dependency
COURSE# CourseName,
• For each value of Marks the grade will be exactly one value. So we
observe the following functional dependency
Marks Grade
7
Functional Dependencies- From the previous example
STUDENT# StudentName
8
Full dependencies
X and Y are attributes.
X Functionally determines Y
Note: Subset of X should not functionally determine Y
Student#
Marks
Course#
In above example Marks is fully functionally dependent on STUDENT# COURSE#
and not on sub set of STUDENT# COURSE#. This means Marks can not be
determined either by STUDENT# OR COURSE# alone. It can be determined only
using STUDENT# AND COURSE# together. Hence Marks is fully functionally
dependent on STUDENT# COURSE#.
9
Full Functional Dependency
A functional dependency
𝑋→𝑌
Is a full functional dependency if removal of some attribute A
from X means that dependency does not hold any more.
i.e. for any attribute A, (𝑋 − {𝐴}) does not functionally
determine Y
11
Partial Dependency
A functional dependency
𝑋→𝑌
is a partial functional dependency if removal of some
attribute A Є X and the dependency still holds
i.e. for any attribute A, (𝑋 − {𝐴}) →Y also holds
13
Need for Normalization
Lets observe the Online Retail Application Table
Each row of the table Represents the information of a customer who has
purchased an item.
14
Need
In this Scenario
for Normalization
Can we Insert the record of an item which has not been purchased by any
customer?
The table is not to maintain the record of items but it is
to keep the record of purchase of item by customers
Can we delete the record of item which has been purchased by only one
customer? There will be information
Loss for that item
How many times we need to store the description of an item if the same
item is purchased many times? Depends upon the no of times
the item has been purchased
16
First Normal Form: 1NF
• A relation schema is in 1NF :
17
Online Retail Application Tables –
1NF Normalized
Observation on Un Normalized Retail Application Table
Customerdetails, Itemdetails and PurchaseDetails are composite
18
First Normal Form (1NF)
Disallow multivalued attribute, composite and their
combination
Attribute with single atomic (or indivisible) values
Consider the following relation
Student(SSN, sName, address)
Data in this table shows Steve with SSN SSN sName address
has his parental house in New York (NY), he
currently works at Los Angeles (LA), and he 109 Steve NY, LA, SJ
also has a house at San Jose (SA) 232 Larry LA, SJ
To represent all this information in relation
171 Bill NY
we need to have address as multivalued
attribute
First Normal Form (1NF)
For dealing with these situation we have 3 solutions
Solution 1: create column for each value
Consider the following relation SSN sName address
Student(SSN, sName, address) 109 Steve NY, LA, SJ
Suppose we are interested in storing only 232 Larry LA, SJ
some of information rather all values for e.g. 171 Bill NY
information of their permanent and
correspondence address is only we are 1NF
interested in then our relation be:
Student(SSN, sName, permanentAddress, correspondenceAddress)