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

CHAPTER 3.2 Normalization

This document summarizes Chapter 3 part II which discusses functional dependencies and normalization. It begins by defining functional dependencies and providing examples. It then discusses different normal forms including first normal form, second normal form, and third normal form. For each normal form, it provides the definitions and requirements. It also gives examples of relations and how to normalize them into different normal forms to remove data redundancy and anomalies.

Uploaded by

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

CHAPTER 3.2 Normalization

This document summarizes Chapter 3 part II which discusses functional dependencies and normalization. It begins by defining functional dependencies and providing examples. It then discusses different normal forms including first normal form, second normal form, and third normal form. For each normal form, it provides the definitions and requirements. It also gives examples of relations and how to normalize them into different normal forms to remove data redundancy and anomalies.

Uploaded by

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

Chapter three:Part II

Functional Dependencies and


Normalization

• Functional Dependencies (FDs)


• Definition of FD
• Transitive dependent
• Trival and non-trival FD
• Normal Forms
• First Normal Form
• Second Normal Form
• Third Normal Form
• Boyce-Cod Normal Form
3.2.1. Functional dependency
• It is a r/ship that exists when one attribute uniquely
determines another attributes. Having some identification key
Example: if every attributes Y of R dependent of X, then
attribute X is primary key.
X Y
R
If R is a relation (table) with attributes X and Y the FD b/n X
and Y can be represented by:
XY, Y is functionally depends on X or X is uniquely
determines Y value.
OR Y attributes depends on X attributes.
 X is primary key (uniquely determines)
 Y is non primary key (dependent)
Chapter 3 part ii -2
…Cont’d
 FD is a set of constraints b/n two attributes in a relation.
XY, X is always determines or identification key.
Y is always dependent.
Example.
ID Name Age
I1 Abebe 30
I2 Melaku 25

IDName Functionally dependency


IDAge

Chapter 3 part ii -3
Fully Functional dependency: let a relation R contains a set
of attributes (ABCD) and (ABC) determines D.
ABCD, to be Fully Functional Dependent:
 D cannot depends on any subset of ABC.
That means:-
BCD BC,C,A are subset of ABC, so it is not possible
CD in case of FFD. Because BC,C,A cannot determines
AD D.

Chapter 3 part ii -4
…cont’d
Example: Attributes of a relation
IdStd Name IdInstr Grade
S1 Chala I1 A
s2 Lati I2 B

 If IdStd, IdInstr are Identification key.


IdStd, IdInstrGrade , FFD b/c Grade depends on the
combination of these two attributes.

Chapter 3 part ii -5
Transitive Dependent
• Consider attributes A, B and C
Where AB and BC
 If the above FD are transitive, also have the FD
AC.
 C is transitively dependent on A only through B.
Example: EmpNumDeptNum
EmpNumEmpEmail
DeptNumDeptName
then EmpNumDeptName
because EmplNum is indirectly determines DeptName through
DeptNum.

Chapter 3 part ii -6
…Cont’d

EmpNum EmpEmail DeptNum DeptName

Chapter 3 part ii -7
Trival and Non-trival FD
• Let relation R contains a set of attributes (title, year, title) and
title, year title
 An FD where the right hand side is contained with the left
hand side called trival FD.
 If there a least one element on the right hand side that is not
contained in the left hand side, it is called non-trival FD.

Chapter 3 part ii -8
3.2.2 Normal Forms
3.1 Normalization of Relations

Normalization:
• The process of decomposing unsatisfactory "bad" relations by
breaking up their attributes into smaller relations.
• To reduce data redundancy.
• Normal forms are defined that do not have certain types of
dependency.
• Redundancy is expressed in terms of dependencies.
Data Redundancy :
• Data redundancy is when the same piece of data is held in
two separate places in the same table.
• Redundant data can be determined by other data in the DB.
• this data redundant leads to various problems:
INSERT anomalies
UPDATE anomalies
DELETE anomalies
Consider the relation:
EMP_PROJ ( Emp#, Proj#, Ename, Pname, No_hours)

Chapter 3 part ii -10


• INSERT Anomalies:
 Attributes cannot insert without the presence of another
attributes.
 Cannot insert a project unless an employee is assigned to .
Inversely - Cannot insert an employee unless an he/she is
assigned to a project.
• DELETE Anomalies:
 When a project is deleted, it will result in deleting all the
employees who work on that project.
• UPDATE Anomalies:
 Changing the name of project number P1 from “Billing”
to “Customer-Accounting” may cause this update to be
made for all 100 employees working on project P1.
Chapter 3 part ii -11
Normalization is a method to remove all these anomalies and
bring the data base to a consistent or correct state.
Normal Forms:
• Condition using keys and FDs of a relation to certify whether
a relation schema is in a particular normal form.
 1NF,2NF, 3NF, BCNF based on keys and FDs of a
relation schema

Chapter 3 part ii -12


3.1.1. First Normal Form (1NF)
• Disallows composite attributes and multivalued attributes ,
whose values for an individual tuple are non-atomic.
• All attributes in a relation must have only atomic (indivisible)
domains.
Requirements to convert R to 1NF
1. Each table has primary key.
2. Value in each column of a table are atomic (no multivalued
and composite attributes allowed).
3. There are no repeating groups. Means two columns/attributes
do not store similar information in the same table

Chapter 3 part ii -13


…cont’d
1NF Decomposition:
a. Place all items that appear in the repeating group in a new table.
b. Identify primary key for each new table produced.
c. Duplicate in the new table the primary key of the table which
repeating groups was extracted or vice versa.
Example:
Un normalized relation R Normalized to 1NF relation R
Course Content Course Content
Programming Java, C++ Programming Java
Web HTML, PHP, Programming C++
ASP
Web HTML
Web PHP
Web ASP
Chapter 3 part ii -14
Disadvantages of INF
• Introduces redundancy
 Much of the data needs to be repeated
• Insert anomalies
• Delete anomalies
• Update anomalies

Chapter 3 part ii -15


3.1.2. Second Normal Form (2NF)
Definitions:
• Prime attribute - attribute that is member of the primary key
K
• Non-prime attribute – an attribute which is not a part of
primary key is called non-prime attribute.
Requirement of 2NF:
1. The table must be in 1NF.
2. A relation schema R is in second normal form (2NF) if
every non-prime attribute A in R is fully functionally
dependent on the primary key.
• Full functional dependency - a FD Y -> Z where removal
of any attribute from Y means the FD does not hold any more
Examples: - {SSN, PNUMBER} -> HOURS is a full FD
since neither SSN -> HOURS nor PNUMBER -> HOURS
hold
Chapter 3 part ii -16
…cont’d
 {SSN, PNUMBER} -> ENAME is not a full FD (it is called a
partial dependency ) since SSN -> ENAME also holds
Example 1: normalization process. a) Normalization EMP_PROJ
in to 2NF relations

Chapter 3 part ii -17


…cont’d
Example 2: a) un normalized relation b) normalized to 2NF relations
a)
StID StName InsID InsName Grade
1 Chala 11 Kiya 5
2 Kebede 22 Henok 4
3 Aster 33 Yonas 6

b) 2NF normalization

StID StName InsID InsName StID InsID Grade


1 Chala 11 Kiya 1 11 5
2 Kebede 22 Henok 2 22 4
3 Aster 33 Yonas 3 33 6

Chapter 3 part ii -18


…cont’d
Example 3: convert a given schema to 2NF.
Scheme – {City, Street, HNo, HColor, CityPopulation}
1. Key - {City, Street, HNo}
2. {City, Street, HNo}  {HColor}
3. {City}  {CityPopulation}
4. CityPopulation does not belongs to any key so, it is non prime
attribute.
5. CityPopulation is FD on city which is a proper subset of the key.
To convert to 2NF it must be in 1NF and fully FD
Old Scheme – {City, Street, HNo, HColor, CityPopulation}
2NF of the given Relation will be as follows:
New scheme – {City, Street, HNo, HColor} 1NF, fully FD so, this
New scheme – {City, CityPopulation} Relation is in 2NF
Chapter 3 part ii -19
Disadvantages of 2NF
• Second Normal Form only considers partial key dependencies
 And ignores any non-key dependencies
• Therefore 2NF may still result in the same problems
observed with 1NF, that is:
 Redundancy
 Insert, delete and update anomalies

Chapter 3 part ii -20


3.1.3. Third Normal Form (3NF)
Definition:
• Transitive functional dependency - a FD X -> Z that can be derived from two
FDs X -> Y and Y -> Z
Examples: a) Relation which is not normalized in 3NF. But normalized in 2NF
b) Relation which is normalized in 3NF.
- SSN -> DMGRSSN is a transitive FD since
SSN -> DNUMBER and DNUMBER -> DMGRSSN hold
- SSN -> ENAME is non-transitive since there is no set of attributes X where
SSN -> X and X -> ENAME

a)

b)

Chapter 3 part ii -21

You might also like