0% found this document useful (0 votes)
11 views44 pages

Lecture11 Normalization

Uploaded by

enkherden2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views44 pages

Lecture11 Normalization

Uploaded by

enkherden2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Database design

Normalization

Б.Наранчимэг
Мэдээлэл, компьютерийн ухааны тэнхим
ХШУИС, МУИС
[email protected]
Summary
Objectives
• Purpose of normalization
• Problems associated with redundant data
• Identification of various types of update anomalies such as insertion,
deletion and modification anomalies.
• How to recognize appropriateness or quality of the design of
relations.
Objectives
• How functional dependencies can be used to group attributes into
relations that are in a known normal form
• How to undertake process of normalization
• How to identify most commonly used normal forms, namely 1NF,
2NF, 3NF and Boyce-Codd normal forms (BCNF)
• How to identify fourth (4NF) and fifth (5NF) normal forms.
Normalization
• Main objective in developing a
logical data model for relational
database systems is to create
accurate representation of data, its
relationships and constraints.
• To achieve this objective, must
identify a suitable set of relations.
How normalization can be used to support
database design
Conceptual Design Phase
TOP-DOWN Identify Entities

Identify Relationships

Identify Attributes

BOTTOM-UP

Identify Relationships

Identify Dependencies

DATA

Collect Data
Logical design phase

Conceptual
ER Model

1. REFINE THE CONCEPTUAL MODEL

Refined Conceptual Model

2.APPLY THE RULES OF NORMALIZATION

Logical
Data Model
Physical Database Design
Logical Data Model Logical Process Model
Track 01 Country

TR

Physical Database creation


Implementation CREATE DATABASE
CREATE TABLE
Process
LOAD
Normalization
• Four most commonly used normal forms are first (1NF), second (2NF),
third (3NF) normal forms, and Boyce-Codd normal form (BCNF).

• Based on functional dependencies among the attributes of relation.

• A relation can be normalized to a specific form to prevent possible


occurrence of update anomalies.
Data redundancy
• Major aim of relational database design is to group attributes into
relations to minimize data redundancy and reduce file storage space
required by base relations.
Staff, Branch vs. StaffBranch

Update anomalies

Staff (staffNo, sName, position, salary, branchNo)


Branch (branchNo, bAddress)
StaffBranch (staffNo, sName, position, salary, branchNo, bAddress)
Update anomalies
• Relations that contain redundant information may potentially suffer
from update anomalies.

• Types of update anomalies


• Insertion
• Deletion
• Modification
Staff, Branch vs. StaffBranch

Types of update anomalies


Insertion
Deletion
Modification
Loss-less and dependency preservation
properties
• Two important properties associated with decomposition of a larger
relation into smaller relations:
• The lossless-join property ensures that any instance of the original
relation can be identified from corresponding instances in the smaller
relations.
• The dependency preservation property ensures that a constraint on
the original relation can be maintained by simply enforcing some
constraint on each of the smaller relations.
Functional dependency
• Main concept associated with normalization

• Functional dependency
• Describes the relationship between attributes in a relation
• if A and B are attributes of relation R, B is functionally dependent on A
(denoted A → B), if each value of A is associated with exactly one value of B in
R.
Functional dependency
• Property of the meaning (or semantics) of the attributes in a relation.
• Diagrammatic representations:

• Determinant of a FD refers to a attribute of group of attributes on


left-hand side of the arrow.
An example of a functional dependency
1:1 relationship

1:M relationship

staffNo is the determinant of this functional dependency


Identifying a set of functional dependencies
for the StaffBranch relation

Five determinant
staffNo
staffNo →sName, position, salary, branchNo, bAddress branchNo
branchNo →bAddress
bAddress →branchNo
bAddress
branchNo, position →salary (branchNo, position)
bAddress, position →salary (bAddress, position)
Functional dependency
• Set of all functional dependencies implied by a given set of functional
dependency X called closure of X
• Set of inference rules, called Armstrong’s axioms, specifies how new
functional dependencies can be inferred from given ones.
Functional dependency
• Let A,B and C be subsets of the attributes of relation R. Armstrong’s
axioms are as follows:
• 1. Reflexivity
• If B is a subset of A then A → B
• 2. Augmentation
• If A → B, then A, C → B, C
• 3. Transitivity
• If A → B and B → C, then A → C
Functional dependency
• 4. Self-determination
• A→A
• Decomposition
• If A → B, C then A → B, A → C
• Union
• If A → B and A → C, then A → B, C
• Composition
• If A → B and C → D then A, C → B, D
Functional dependency
• Full functional dependency - A → B is a full functional dependency if
removal of any attribute from A results in the dependency no longer
existing.
• Partial dependency - A functional dependency A→B is a partially
dependency if there is some attribute that can be removed from A
and yet the dependency still holds.
Functional dependency
• Let R(A,B,C) and AB=candidate key.
• A-> C is a partial dependency (where C depends on a part of the
candidate key).
• AB->C is a full dependency (where c depends on the entire candidate
key).
• A Functional dependency X->Y is a partial dependency if,
• X is a part of candidate key and
• Y is a non-key attribute(s).
Process of Normalization
• Normalization is a formal technique for analyzing relations based on
their primary key (or candidate keys) and functional dependencies
• Often executed as a series of steps. Each step corresponds to a
specific normal form, which has known properties.
• As Normalization proceeds, relations become progressively more
restricted (stronger) in format and also less vulnerable to update
anomalies.
Relationship between normal forms
Unnormalized forms (UNF)
• A table that contains one or more repeating groups.

• To create an unnormalized table:


• Transform data from information source (e.g. form) into table format with
columns and rows.
First Normal Forms (1NF)
• A relation in which the intersection of each row and column contains
one and only one value.
• UNF to 1NF
• Nominate an attribute or group of attributes to act as the key for the
unnormalized table.
• Identify repeating group(s) in unnormalized table which repeats for the key
attributes.
• Remove repeating group by entering appropriate data into empty fields
Example: First Normal Form (1NF)
Example: First Normal Form (1NF)

ClientRental unnormalized table.


First Normal Form ClientRental relation
Second normal forms (2NF)
• Based on concept of Full functional dependency:
• Indicates that if A and B are attributes of a relation, B is fully functionally
dependent on A if B is functionally dependent on A, but not on any proper
subset of A.

• A relation that is in First Normal Form and every non-primary-key


attribute is fully functionally dependent on the primary key.
1NF to 2NF
• Identify PK for the 1NF.
• Identify functional dependency in the relation.
• If partial dependencies exist on the PK remove them by placing then
in a new relation along with copy of their determinant.
Functional dependencies of the ClientRental
relation

fd1 clientNo, propertyNo → rentStart, rentFinish (Primary key)


fd2 clientNo → cName (Partial dependency)
fd3 propertyNo → pAddress, rent, ownerNo, oName (Partial dependency)
fd4 ownerNo → oName (Transitive dependency)
fd5 clientNo, rentStart → propertyNo, pAddress,
rentFinish, rent, ownerNo, oName (Candidate key)
fd6 propertyNo, rentStart → clientNo, cName, rentFinish (Candidate key)
Second Normal Form relations derived from
the ClientRental relation.

Client (clientNo, cName)


Rental (clientNo, propertyNo, rentStart, rentFinish)
PropertyOwner (propertyNo, pAddress, rent, ownerNo, oName)
Third normal forms (3NF)
• Based on concept of transitive dependency:
• If A → B and B → C, then A → C
• A relation that is in First and Second Normal Form and in which no
non-primary-key attribute is transitively dependent on the primary
key.
2NF to 3NF
• Identify the primary key in the 2NF relation
• Identify functional dependencies in the relation.
• If transitive dependencies exists on the PK remove them by placing
them in a new relation along with copy of their determinant.
Third normal forms (3NF)
• Client
• fd2 clientNo → cName (Primary key)
• Rental
• fd1 clientNo, propertyNo → rentStart, rentFinish (Primary key)
• fd5 clientNo, rentStart → propertyNo, rentFinish (Candidate key)
• fd6 propertyNo, rentStart → clientNo, rentFinish (Candidate key)
• PropertyOwner
• fd3 propertyNo → pAddress, rent, ownerNo, oName (Primary
key)
• fd4 ownerNo → oName (Transitive dependency)
Third normal forms (3NF)

PropertyForRent (propertyNo, pAddress, rent, ownerNo)


Owner (ownerNo, oName)
The decomposition of the ClientRental 1NF
relation into 3NF relations.
UNF
3NF
Next Advanced normal forms
• BCNF
• 4NF
• 5NF

You might also like