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

Lecture 7 DB

Uploaded by

heshamislam556
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)
6 views

Lecture 7 DB

Uploaded by

heshamislam556
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/ 34

Basics of Functional

Dependencies and
Normalization for Relational
Databases

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Chapter 15 Outline
▪ Informal Design Guidelines for Relation
Schemas
▪ Functional Dependencies
▪ Normal Forms Based on Primary Keys
▪ General Definitions of Second and Third
Normal Forms
▪ Boyce-Codd Normal Form

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Informal Design Guidelines
for Relation Schemas
▪ Measures of quality
1. Making sure attribute semantics are clear
2. Reducing redundant information in tuples
3. Reducing NULL values in tuples
4. Disallowing possibility of generating fake
tuples

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


A simplified COMPANY
relational database schema.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Sample database state for the relational
database schema in the previous Figure

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Reducing redundant information in tuples and
Update anomalies

▪ Information that stored redundantly


▪ Wastes storage
▪ Causes problems with update anomalies
• Insertion anomalies
• Deletion anomalies
• Modification anomalies

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Reducing redundant information in tuples and
Update anomalies

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Reducing redundant information in tuples and
Update anomalies

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Normalization
▪ Normalization of data can be considered a process of
analyzing the given relation schemas based on their FDs
(Functional Dependencies) and primary keys to achieve
the desirable properties of
1. minimizing redundancy and
2. minimizing the insertion, deletion, and update
anomalies discussed.
▪ It can be considered as a “filtering” or “purification”
process to make the design have successively better
quality.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Functional Dependencies
▪ Formal tool for analysis of relational
schemas
▪ Enables us to detect and describe some of
the above-mentioned problems in precise
terms
▪ Theory of functional dependency

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Definition of Functional
Dependency
▪ Constraint between two sets of attributes
from the database

▪ Property of semantics or meaning of the


attributes
▪ Legal relation states
▪ Satisfy the functional dependency constraints

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Definition of Functional Dependency

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Normalization of Relations
▪ Takes a relation schema through a series
of tests
▪ Certify whether it satisfies a certain normal
form
▪ Proceeds in a top-down fashion

▪ Normal form tests

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Normalization of Relations
▪ There are various levels of normalizations.
▪ First Normal Form (1NF)
▪ Second Normal Form (2NF)
▪ Third Normal Form (3NF)
▪ Boyce–Codd Normal Form (BCNF)
▪ Fourth normal form (4NF)
▪ Fifth normal form (5NF)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Practical Use of Normal Forms
▪ Normalization carried out in practice
▪ Resulting designs are of high quality and meet
the desirable properties stated previously
▪ Pays particular attention to normalization only
up to 3NF, BCNF, or at most 4NF
▪ Do not need to normalize to the highest
possible normal form

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Definitions of Keys and
Attributes Participating in Keys
▪ Definition of superkey and key
▪ Candidate key
▪ If more than one key in a relation schema
• One is primary key
• Others are secondary keys

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


First Normal Form
▪ Part of the formal definition of a relation in
the basic (flat) relational model
▪ Only attribute values permitted are single
atomic (or indivisible) values
▪ Techniques to achieve first normal form
▪ Remove attribute and place in separate
relation
▪ Expand the key
▪ Use several atomic attributes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


First Normal Form
▪ Disallows
▪ Composite attributes
▪ Multivalued attributes
▪ Nested relation

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


First Normal Form (cont’d.)
▪ Does not allow nested relations
▪ Each tuple can have a relation within it
▪ To change to 1NF:
▪ Remove nested relation attributes into a new
relation
▪ Propagate the primary key into it
▪ Unnest relation into a set of 1NF relations

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Second Normal Form
▪ Based on concept of full functional
dependency
▪ Versus partial dependency

▪ Second normalize into a number of 2NF


relations
▪ Nonprime attributes are associated only with
part of primary key on which they are fully
functionally dependent

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
General Definitions of Second
and Third Normal Forms
(cont’d.)
▪ Prime attribute
▪ Part of any candidate key will be considered as
prime
▪ Consider partial, full functional, and
transitive dependencies with respect to all
candidate keys of a relation

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


General Definition of Second
Normal Form

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Third Normal Form
▪ Based on concept of transitive dependency

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


What is Transitive Dependency?
▪ Consider a relation R(A B C).
▪ When the following condition arises;
1. A → B,
2. B → C.

▪ Therefore, the condition becomes A → C. in


transitive functional dependencies, a
dependent is directly dependent on the
determinant.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Third Normal Form

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
General Definition of Third
Normal Form

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Boyce-Codd Normal Form
▪ Every relation in BCNF is also in 3NF
▪ Relation in 3NF is not necessarily in BCNF

▪ Difference:
▪ Condition which allows A to be prime is absent
from BCNF
▪ Most relation schemas that are in 3NF are
also in BCNF

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Join Dependencies

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Summary
▪ Informal guidelines for good design
▪ Functional dependency
▪ Basic tool for analyzing relational schemas
▪ Normalization:
▪ 1NF, 2NF, 3NF, BCNF, 4NF, 5NF

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

You might also like