Вы находитесь на странице: 1из 24

SCHEMA REFINEMENT AND NORMALIZATION

Objectives
After completing this chapter, you will be able to:

Define Normalization List reason for Normalization

Refining a database
Defining Normal Form

Describe Types of Normal Forms

Normalization
Normalization is a step-by-step decomposition of complex records into simple records. It results in the formation of

tables that satisfy certain specified constraints, and


represent certain normal forms.

Normalization reduces redundancy using the principle of nonloss decomposition. A fully normalized record consists of: A primary key that identifies an entity

A set of attributes that describe the entity

Why Normalization?
Does the design ensure that all database operations will be efficiently performed and that the design does not make the DBMS perform expensive consistency checks which could be avoided? Is the information unnecessarily replicated?

Unless these issues are properly handled, several difficulties like redundancy and loss of information may arise. There are several methods to avoid the above mentioned problems. One such method is database decomposition through normalization.

The Evils of Redundancy

Redundancy is at the root of several problems associated with relational schemas

More seriously, data redundancy causes several anomalies:


Insert Update

Delete

Wastage of storage. Main refinement technique: decomposition (replacing ABCD with, say, AB and BCD, or ACD and ABD).

Refining an E-R Diagram Before


name ssn since dname did

lot

budget

Employee

Works_in

Department

Refining continued...

After
dname since did budget lot Employee

name
ssn

Works_in

Department

Normal Forms
Forms are designed to logically address potential problems in referring to and working with information stored in a

database.
A database is said to be in one of the Normal Forms, if it satisfies the rules required by that Form.

It also will not suffer from any of the problems addressed by


the Form.

Types of Normal Forms


Several normal forms have been identified, the most important and widely used of which are:

First normal form (1NF)


Second normal form (2NF) Third normal form (3NF)

Boyce-Codd normal form (BCNF)


Fourth normal form (4NF)

First Normal Form (1NF)


A table is in 1NF, if every row contains exactly one value for each attribute. Disallow multivalued attributes, composite attributes and their combinations. 1NF states that :

Domains of attributes must include only atomic (simple,


indivisible) values and that value of any attribute in a tuple must be a single value from the domain of that

attribute.
By definition, any relational table must be in 1NF.

Functional Dependency (FD)


They provide a formal mechanism to express

constraints between attributes.


Given a relation R, attribute Y of R is functionally dependent on the attribute X of R if and only if each X-value in R has associated with it precisely one Y-value in R.

The dependency is represented as Y X.

Full Dependency
An FD X Y is a full functional dependency if removal of any attribute A from X means that the dependency does not hold any more.

An attribute B of a relation R is fully functional


dependent on attribute A of R if it is functionally dependent on A and not functionally dependent on any proper subset of A.

Partial Dependency

A FD X Y is a partial dependency if there is some attribute A X that can be removed from X and the dependency will still hold.

Constraints on Entity Set


S N L 123- 22- 3666 Attishoo 48 231- 31- 5368 Smiley 22 131- 24- 3650 Smethurst 35 434- 26- 3751 Guldu 35 612- 67- 4134 Madayan 35 S N L 123- 22- 3666 Attishoo 48 231- 31- 5368 Smiley 22 131- 24- 3650 Smethurst 35 434- 26- 3751 Guldu 35 612- 67- 4134 Madayan 35 H 40 30 30 32 40 R 8 8 5 5 8 R 8 8 5 5 8 W 10 10 7 7 10 H 40 30 30 32 40

R W 5 7 8 10

Second Normal Form (2NF)


A relation schema R is in 2NF if:

It is in 1NF
Every non-prime attribute A in R is fully functionally dependent on the primary key of R. 2NF prohibits partial dependencies. If a relation is not in 2NF, it can be further normalized into a number of 2NF relations.

Converting a Database to 2NF


Find and remove attributes that are related to only a
part of the key. Group the removed items in another table. Assign the new table a key that consists of that part of the old composite key.

Transitive Dependency
An FD X Y in a relation schema R is a transitive
dependency if: There is a set of attributes Z that is not a subset of any key of R. Both X Z and Z Y hold.

Example

Emp{Eno, Dept, ProjCode, Hours}


Primary key: {Eno, ProjCode} {Eno} -> {Dept}, {Eno, ProjCode} -> {Hours}

Test of 2NF:
{Eno} -> {Dept}: partial dependency. Emp is in 1NF, but not in 2NF. Decomposition: Emp {Eno, Dept} Proj {Eno, ProjCode, Hours}

Third Normal Form (3NF)


A relation schema R is in 3NF if whenever a functional

dependency X A hold in R, then either:


X is a super key of R A is a prime attribute of R. If 3NF is violated by X A, one of the following holds: X is a subset of some key K

We store (X, A) pairs redundantly


X is not a proper subset of any key

Example

Emp{Eno, Dept, Dept_Head} Primary key: {Eno} {Eno} -> {Dept}, {Dept} -> {Dept_Head} Test of 3NF {Eno} -> {Dept} -> {Dept_Head}: Transitive dependency. Emp is in 2NF, but not in 3NF. Decomposition: Emp {Eno, Dept} Dept {Dept, Dept_Head}

Boyce-Codd Normal Form (BCNF)


A relation R is said to be in BCNF, if and only if every determinant is a candidate key. 3NF does not satisfactorily handle the case of a relation processing two or more composite or

overlapping candidate keys.

Decomposition of a Relation Schema

Suppose that relation R contains attributes A1... An. A decomposition of R consists of replacing R by two or more relations such that: Each new relation scheme contains a subset of

the attributes of R (and no attributes that do


not appear in R). Every attribute of R appears as an attribute of one of the new relations.

Fourth Normal Form (4NF)


Under fourth normal form (4NF): A record type should not contain two or more independent multi-valued facts about an entity. The record must satisfy 3NF.

Summary
You now should be able to:

Define Normalization List reason for Normalization

Refining a database
Defining Normal Form

Describe Types of Normal Forms

Вам также может понравиться