Sie sind auf Seite 1von 33

NORMALIZATION

Normalization

! E.F. Codd

! Process for evaluating and correcting table structures.

! A series of tests
Normalization

! Three normal forms were initially proposed

− 1NF – first normal form

− 2NF – second normal form

− 3NF – third normal form


Normalization

! Boyce-Codd Normal Form

− Introduced by R. Boyce and E.F. Codd

− A stronger definition of third normal form

! Normal forms are based on functional dependencies


among attributes of a relation
Normalization

! 4NF and 5NF were later introduced, this normal


forms go beyond BCNF.
Data Redundancy and Update Anomalies

! Data redundancy = repeating data

! Redundant Data => Update anomalies

! Update anomalies

! insertion anomalies

! deletion anomalies

! modification anomalies
Example
StaffBranch
BranchAddres
StaffNo StaffName Position Salary BranchNo
s
27 Deer Rd.
GH121 Joel Reyes Manager 27000 B005
New York
22
Rico
GH321 Supervisor 16000 B002 Alexandria,
Bernardo
California
001
GH234 Julie Lee Assistant 10000 B003 Alexandria,
Texas
27 Deer Rd.
GH543 Cynthia Ong Assistant 9500 B005
New York
28 Riverside,
GH243 Joey Cuy Manager 25000 B001
New York
27 Deer Rd.
GH987 Grace de Jesus Assistant 9700 B005
New York
Insertion Anomalies

! What are the two type of insertion anomalies present


in the StaffBranch table in the following slide?
Example
StaffBranch
StaffNo StaffName Position Salary BranchNo BranchAddress

27 Deer Rd.
GH121 Joel Reyes Manager 27000 B005 New York

22 Alexandria,
GH321 Rico Bernardo Supervisor 16000 B002
California

001 Alexandria,
GH234 Julie Lee Assistant 10000 B003
Texas

27 Deer Rd.
GH543 Cynthia Ong Assistant 9500 B005 New York
28 Riverside,
GH243 Joey Cuy Manager 25000 B001 New York
27 Deer Rd.
GH987 Grace de Jesus Assistant 9700 B005 New York
Deletion anomalies

! If we delete a tuple in the StaffBranch relation


representing the last staff located at the branch, the
data regarding the branch is also lost from the entire
database
Modification anomalies

! If we change a tuple in the StaffBranch relation,


example the B005 in the BranchAddress, then all the
tuples associated to that branch needs to be modify.

! Failure to carry out this modification in all tuples in


the BranchAddress relation will make the database
inconsistent.
Process of Normalization

Unnormalized Table
customer customer property property rent rent owner owner
rent
no name no add start finish no name
6 Lawrence St.,
CUS23 Jason Uy PR1 Glasgow 01/10/03 06/15/05 600 OW78 Jerick Coo

5 Novar Dr.,
PR3 05/01/00 05/01/10 500 OW15 Wilma Diaz
Glasgow
Bernadete 2 Manor Rd.,
CUS98 Yoson PR2 Glasgow 06/08/01 06/08/02 1500 OW78 Jerick Coo

6 Lawrence St.,
PR1 06/09/89 08/09/08 600 OW15 Wilma Diaz
Glasgow

5 Novar Dr.,
PR3 Glasgow 04/07/08 06/07/09 500 OW78 Jerick Coo
1st Normal Form

! All the key attributes are defined

! There are no repeating groups in the table.

! All attributes are dependent on the primary key


1st Normal Form
1st Approach
customer customer propertyn property rent rent owner owner
no name o add start finish rent no name

6 Lawrence St.,
CUS23 Jason Uy PR1 Glasgow 01/10/03 06/15/05 600 OW78 Jerick Coo

5 Novar Dr.,
CUS23 Jason Uy PR3 05/01/00 05/01/10 500 OW15 Wilma Diaz
Glasgow

2 Manor Rd.,
CUS98 Bernadete Yoson PR2 06/08/01 06/08/02 1500 OW78 Jerick Coo
Glasgow

CUS98 Bernadete Yoson PR1 6 Lawrence St., 06/09/89 08/09/08 600 OW15 Wilma Diaz
Glasgow

5 Novar Dr.,
CUS98 Bernadete Yoson PR3 Glasgow 04/07/08 06/07/09 500 OW78 Jerick Coo
1st Normal Form
2nd Approach
customer customer propertyn property rent rent owner owner
no name o add start finish rent no name

6 Lawrence St.,
CUS23 Jason Uy PR1 Glasgow 01/10/03 06/15/05 600 OW78 Jerick Coo

5 Novar Dr.,
CUS23 Jason Uy PR3 05/01/00 05/01/10 500 OW15 Wilma Diaz
Glasgow

2 Manor Rd.,
CUS98 Bernadete Yoson PR2 06/08/01 06/08/02 1500 OW78 Jerick Coo
Glasgow

CUS98 Bernadete Yoson PR1 6 Lawrence St., 06/09/89 08/09/08 600 OW15 Wilma Diaz
Glasgow

5 Novar Dr.,
CUS98 Bernadete Yoson PR3 Glasgow 04/07/08 06/07/09 500 OW78 Jerick Coo
Dependency Diagram

customer customer property property rent rent owner owner


rent
no name no add start finish no name

Partial Partial Transitive


dependency dependency
dependency

! Remove the repeating group by placing the repeating


data, along with a copy of the original key attribute(s),
as a separate relation. A primary key is identified for
the new relation.
1st Normal Form

PROPERTY_RENT_OWNER CUSTOMER
custom proper property rent rent ren owne owner customer no customer
er no tyno add start finish t r name name
no CUS23 Jason Uy
6 Lawrence
CUS23 PR1
St., Glasgow
01/10/03 06/15/05 600 OW78 Jerick Coo
CUS98 Bernadete Yoson

5 Novar Dr.,
CUS23 PR3
Glasgow
05/01/00 05/01/10 500 OW15 Wilma Diaz

2 Manor Rd.,
CUS98 PR2 Glasgow 06/08/01 06/08/02 1500 OW78 Jerick Coo

6 Lawrence
CUS98 PR1 St., Glasgow 06/09/89 08/09/08 600 OW15 Wilma Diaz

5 Novar Dr.,
CUS98 PR3
Glasgow
04/07/08 06/07/09 500 OW78 Jerick Coo
1st Normal Form

! A relation is in 1NF if they contain no repeating


groups

! Both approaches are correct, however the second


approach initially give a relation in 1NF and with the
less redundancy
2nd Normal Form

! full functional dependence


2nd Normal Form

! Second normal form applies to relations with


composite keys, meaning a primary key composed of
two or more attributes

! A relation with a single primary key is automatically in


2NF
2nd Normal Form

! Relation not in 2NF may suffer in update anomalies

! 2NF is a relation that is in 1NF and every non- primary-key


attribute is fully functionally dependent on the primary key.

! 1NF can be normalize to 2NF by the removal of partial


dependencies. In the existence of partial dependency, we eliminate
the functionally dependent attributes from the relation by placing
them in a new relation along with a copy of their determinant
Dependency Diagram

customer customer property property rent rent owner owner


rent
no name no add start finish no name

Partial Partial Transitive


dependency dependency
dependency
2nd Normal Form
CUSTOMER RENT
customer
customer no name customer propert rent rent
no yno start finish
CUS23 Jason Uy CUS23 PR1 01/10/03 06/15/05

CUS23 PR3 05/01/00 05/01/10


CUS98 Bernadete Yoson

CUS98 PR2 06/08/01 06/08/02

CUS98 PR1 06/09/89 08/09/08

CUS98 PR3 04/07/08 06/07/09

PROPERTY_OWNER
property property owner owner
no add rent no name
PR1 6 Lawrence St., Glasgow 600 OW78 Jerick Coo

PR3 5 Novar Dr., Glasgow 500 OW15 Wilma Diaz

PR2 2 Manor Rd., Glasgow 1500 OW78 Jerick Coo

PR1 6 Lawrence St., Glasgow 600 OW15 Wilma Diaz

PR3 5 Novar Dr., Glasgow 500 OW78 Jerick Coo


2nd Normal Form

! A table is in 2NF when

! it is in 1NF

! it includes no partial dependencies


3rd Normal Form

! Is a relation that is in 1NF and 2NF, and in which no


non-primary-key attribute is transitive dependent on
the primary key

! Transitive dependency is a type of functional


dependency
Dependency Diagram

customer customer property property rent rent owner owner


rent
no name no add start finish no name

Partial Partial Transitive


dependency dependency
dependency
3rd Normal Form
RENT CUSTOMER
customer propert rent rent customer
no yno start finish customer no name
CUS23 PR1 01/10/03 06/15/05
CUS23 Jason Uy
CUS23 PR3 05/01/00 05/01/10
CUS98 Bernadete Yoson
CUS98 PR2 06/08/01 06/08/02

CUS98 PR1 06/09/89 08/09/08

OWNER
CUS98 PR3 04/07/08 06/07/09

owner owner
PROPERTY no name
property owner
propertyno rent OW78 Jerick Coo
add no
OW15 Wilma Diaz
PR1 6 Lawrence St., Glasgow 600 OW78

OW78 Jerick Coo


PR3 5 Novar Dr., Glasgow 500 OW15

OW15 Wilma Diaz


PR2 2 Manor Rd., Glasgow 1500 OW78

OW78 Jerick Coo


PR1 6 Lawrence St., Glasgow 600 OW15

PR3 5 Novar Dr., Glasgow 500 OW78


3rd Normal Form

! A table is in 3NF when

! It is in 2NF

! It contains no transitive dependencies


end...

:)
Acc. No Barcode Title Publisher Ed Author Subject Loc Year

Information
acc01 B00123 Harry Cenage 2nd Cruz, Harry SLIS 1985
Technology

acc02 B00124 Information SLIS;


I.T. Adarna 7th David, Jessie 2007
Technology; Science
acc02-2 B00124-2 CBA

acc091 B00768 CS;


Science Cenage 2nd Sebastian, Jess Science; Biology 2007
acc091-2 B00768-2 CHK

acc218 B00234 CS;


Physical
Science Direct 4th David, Jessie Science; Anatomy 2009
Therapy
acc218-2 B00234-2 CHE
Home Work

• 1. Identify the attributes needed in your library function.

• 2. Create an unnormalized table for your library function.

• 3. Draw a dependency diagram of your unnormalized


table.

• 4. Normalized your table (3NF)


Activity

• 1. Write down the business rules for your project.

• 2. Identify the entities needed in your project.

• 3. Create a ER Model.

Das könnte Ihnen auch gefallen