Sie sind auf Seite 1von 31

DATABASE NORMALIZATION

Normalization Objectives
Table should contain subject wise data.
Minimum controlled redundancy.
To eliminates redundancy.
To eliminates dependency.

Data Redundancy
Data redundancy is less desirable in database

environment.
Data redundancies yield the update, insert
and delete anomalies.

Update Anomaly
E_ID

E_ADDR

SKILL

426

87 Sycamore Grove

Typing

426

87 Sycamore Grove

Shorthand

519

94 Chestnut Street

Public Speaking

519

96 Walnut Avenue

Carpentry

Anupdateanomaly.Employee519isshownashavingdifferent
addressesondifferentrecords

Insert Anomaly
Faculty_ID

Faculty_Name

Faculty Hire
Date

Course Code

389

Dr. Giddens

10-Feb-2013

ENG-206

407

Dr. saperstein

15-JAN-2012

CMP-101

407

Dr. saperstein

15-JAN-2012

CMP-201

NewRecord?

424

Dr. New Son

29-MAR-2012

Aninsertionanomaly.Untilthenewfacultymember,Dr.Newsome,is
assignedtoteachatleastonecourse,hisdetailscannotberecorded.

Delete Anomaly
Faculty_ID

Faculty_Name

Faculty Hire
Date

Course Code

389

Dr. Giddens

10-Feb-2013

ENG-206

407

Dr. saperstein

15-JAN-2012

CMP-101

407

Dr. saperstein

15-JAN-2012

CMP-201

Adeletionanomaly.AllinformationaboutDr.Giddensislostifhe
temporarilyceasestobeassignedtoanycourses..

Normalization- definitions
Functional Dependency

An attribute A determines attribute B then


attribute B is functionally dependant on
attribute A. A B
Eg. Student(sid, sname, marks)
sid sname, sid ? marks
sid functionally determined sname

Normalization- definitions
Generalized functional dependency

attribute A determines attribute B if all of the


rows in the table that agree in value for
attribute A also agree in value for attribute B.

Normalization-definitions
Fully functionally dependency

If attribute B is functionally dependant on a


composite key A but not on any subset of that
composite key, the attribute B is fully
functionally dependant on A.

Normalization-definitions
Trivial functional dependency

A trivial functional dependency is a functional


dependency of an attribute on a superset of
itself.
{Employee ID, Employee Address} {Employee
Address}
is trivial,

Normalization-definitions
Transitive dependency

Atransitive dependencyis an indirect


functional dependency, one in whichXZonly
by virtue ofXYandYZ.
Multivalued dependency
Amultivalued dependencyis a constraint
according to which the presence of certain
rows in a table implies the presence of certain
other rows.

Normalization-definitions
Join dependency

A tableTis subject to ajoin dependencyifTcan always


be recreated by joining multiple tables each having a
subset of the attributes ofT.
Super key
Asuperkeyis a combination of attributes that can be
used to uniquely identify a database record. A table might
have many superkeys

Normalization-definitions
Candidate key

Acandidate keyis a special subset of superkeys


that do not have any extraneous information in
them: it is a minimal superkey.
A table with the fields <Name>, <Age>, <SSN>
and <Phone Extension> has many possible
superkeys. Three of these are <SSN>, <Phone
Extension, Name> and <SSN, Name>. Of those,
only <SSN> is a candidate key as the others
contain information not necessary to uniquely
identify records ('SSN' here refers to Social
Security Number, which is unique to each person).

Normalization-definitions
Non-prime attribute

A non-prime attribute is an attribute that


does not occur in any candidate key.
Employee Address would be a non-prime
attribute in the "Employees' Skills" table.
Prime attribute
A prime attribute, conversely, is an attribute
that does occur in some candidate key.

Normalization-definitions
Primary key

One candidate key in a relation may be


designated theprimary key. While that may
be a common practice (or even a required one
in some environments), it is strictly notational
and has no bearing on normalization. With
respect to normalization, all candidate keys
have equal standing and are treated the
same.

NORMAL FORMS
FIRST NORMAL FORM (1NF).
SECOND NORMAL FORM (2NF).
THRID NORMAL FORM (3NF).
BOYCE-CODD NORMAL FORM (BCNF).
FOURTH NORMAL FORM (4NF).

1NF
CHARACTERISTICS
Table Format.
No Multi valued attribute.
Primary Key Identified.

2NF
CHARACTERISTICS
1 NF.
No Partial Dependency.

3NF
CHARACTERISTICS
2 NF.
No Transitive Dependency.

BCNF
CHARACTERISTICS
Special Case of 3NF.
Every determinant is a candidate key.

4NF
CHARACTERISTICS
3NF
No independent multi valued dependencies

CONVERSION TO 1NF

Assumeavideolibrarymaintainsadatabaseofmoviesrentedout.Withoutany

normalizationallinformationisstoredinonetableasshown.
HereMoviesRentedcolumnhasmultiplevalues

CONVERSION TO 1NF
(Cntd)

1NF:EachtablecellshouldcontainsinglevalueandEachrecordneedstobeunique

CONVERSION TO 1NF
(Cntd)

HencewerequirebothFullNameandAddresstouniquelyidentifyarecord.Thisis
acompositekey.Soprimarykeyisidentified.

Assignment
If a table project has the information about the

projects and employees as shown.


Project (proj_num, proj_name, emp_num,
job_class, chg_hour, hours);
A group of employees are assigned to a given
project.
an employee can be assign to different projects.
Each employee charges according to his job class.
Then Convert the table in to first normal form?

CONVERSION TO 2NF
2NF Rules
Rule 1- Be in 1NF
Rule 2- Single Column Primary Key (no partial
dependency) .

CONVERSION TO 1NF
The primary key
PK=proj_num+emp_num
Dependencies
Proj_num,emp_num
proj_name,emp_name,job_class,chg_hour,hou
rs
Proj_num proj_name
Emp_num emp_name,job_class,chg_hour
Job_class chg_hour

Conversion to 1 NF
(cntd..)
1NF(Proj_num,emp_num
proj_name,emp_name,job_class,chg_hour,hours)
Partial dependency
Proj_num proj_name
Emp_num emp_name,job_class,chg_hour
Transitive Dependency
Job_class chg_hour

Conversion to 2
NF(cntd ..)
Key Components
proj_num
Emp_num
proj_num and emp_num
Assigning dependent attribute
project( proj_num, proj_name)
Employee(emp_num,
emp_name,job_class,chr_hour)
Assignment(proj_num,emp_num,assign_hours)

Conversion to 3 NF
3NF Rules
Rule 1- Be in 2NF
Rule 2- Has no transitive functional
dependencies

Conversion to 3 NF
(Cntd..)
Transitive dependency in the given project

table
Job_class chg_hour
Remove the dependent attribute
project( proj_num, proj_name)
Employee(emp_num, emp_name,job_class)
Job(Job_class, chg_hour)
Assignment(proj_num,emp_num,assign_hou
rs)

Das könnte Ihnen auch gefallen