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

A - Quick Look at Normalization

The document provides an overview of database normalization through Boyce-Codd Normal Form (BCNF). It defines common anomalies in data and explains how normalization addresses these issues through decomposing relations. The steps of normalization - 1NF, 2NF, 3NF and BCNF - are outlined and illustrated with examples showing how functional dependencies are used to decompose relations into multiple tables to eliminate anomalies.

Uploaded by

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

A - Quick Look at Normalization

The document provides an overview of database normalization through Boyce-Codd Normal Form (BCNF). It defines common anomalies in data and explains how normalization addresses these issues through decomposing relations. The steps of normalization - 1NF, 2NF, 3NF and BCNF - are outlined and illustrated with examples showing how functional dependencies are used to decompose relations into multiple tables to eliminate anomalies.

Uploaded by

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

Quick Look at Normalization

Dr. Bassam Hammo


Normalization
1NF
2NF
3NF
BCNF
Decomposition
Anomalies (Review)
Anomalies are inconsistencies in data that occur due to
unnecessary redundancy.
Update anomaly
Some copies of a data item are updated, but others are
not.
Insertion anomaly
Can’t insert “real” data without also inserting unrelated
or “made up” data
Deletion anomaly
Can’t delete some data without also deleting other,
unrelated data
Data Normalization

Primarily a tool to validate and improve a logical


design so that it satisfies certain constraints that avoid
unnecessary duplication of data.
The process of decomposing relations with anomalies
to produce smaller, well-structured relations.
Anomaly Examples
OID ODate CID CName
1 8/10/2004 2 ABC Inc
2 8/10/2004 2 ABC Inc
3 8/11/2004 3 XZY Co
4 8/11/2004 4 QWE Inc
5 8/12/2004 4 QWE Inc
Add a customer: Must also add an order

Update the name of Customer #2: Must update multiple rows

Delete Order #3: Must also delete info about Customer #3


Functional Dependencies and Keys
Functional Dependency: The value of one attribute (the
determinant) determines the value of another attribute.
Candidate Key: A possible key.
 Each non-key field is functionally dependent on every
candidate key.
No attribute in the key can be deleted without destroying the
property of unique identification.
Functional Dependencies

EMPLOYEE
Emp_ID Last_Name First_Name M_I

Alternate way to show dependencies


Emp_ID  Last_Name, First_Name, M_I
Steps in Normalization
(doesn’t meet the
definition of a Entity
Remove multivalued &
relation) composite attributes.
First Normal Meet definition of relation
Form
Remove partial
dependencies
Second
Normal Form
Remove transitive
dependencies
Third Normal
Form
Remove any remaining
functional dependencies
Boyce-Codd
Normal Form
First Normal Form (1NF)
If a table of data meets the definition of a relation, it is in first
normal form.
Every relation has a unique name.
Every attribute value is atomic (single-valued).
Every row is unique.
Attributes in tables have unique names.
The order of the columns is irrelevant.
The order of the rows is irrelevant.
Second Normal Form (2NF)

1NF and no partial functional dependencies.


Partial functional dependency: when one or more non-
key attributes are functionally dependent on part of the
primary key.
Every non-key attribute must be defined by the entire
key, not just by part of the key.
If a relation has a single attribute as its key, then it is
automatically in 2NF.
Second Normal Form (2NF)
ACTIVITY Key: Student_ID, Activity
Student_ID Activity Fee Activity  Fee
A relation
that is not
in 2NF
Fee is determined by Activity
Student_ID Activity Fee
222-22-2020 Swimming 30
232-22-2111 Golf 100
222-22-2020 Golf 100
255-24-2332 Hiking 50
Second Normal Form (2NF)
Divide the STUDENT_ACTIVITY
relation into Student_ID Activity Key: Student_ID and Activity
two relations
that now
meet 2NF ACTIVITY_COST Key: Activity
Activity Fee Activity  Fee

Student_ID Activity Activity Fee


222-22-2020 Swimming Swimming 30
232-22-2111 Golf Golf 100
222-22-2020 Golf Hiking 50
255-24-2332 Hiking
Third Normal Form (3NF)
2NF and no transitive dependencies
Transitive dependency: a functional dependency
between two or more non-key attributes.
Third Normal Form (3NF)

HOUSING Key: Student_ID


Student_ID Building Fee Building  Fee
A relation Student_ID  Building Fee
with a
transitive
dependency
Student_ID Building Fee
222-22-2020 Dabney 1200
232-22-2111 Liles 1000
222-22-5554 The Range 1100
255-24-2332 Dabney 1200
330-25-7789 The Range 1100
Third Normal Form (3NF)
STUDENT_HOUSING Key: Student_ID
Divide the Student_ID Building Student_ID  Building
relation into
two relations BUILDING_COST
that now Key: Building
Building Fee
meet 3NF Building  Fee

S
2
tu
2 2
d e n t_
-2 2 -2 0
ID
2 0
B u ild in g
D a b n e y Building Fee
2
2
3 2
2 2
-2 2 -2 1
-2 2 -5 5
1 1
5 4
L ile s
T h e R a n g e
Dabney 1200
2 5 5 -2 4 -2 3 3 2 D a b n e y Liles 1000
3 3 0 -2 5 -7 7 8 9 T h e R a n g e
The Range 1100
Boyce-Codd Normal Form (BCNF)
3NF and every determinant is a candidate key.
Boyce-Codd Normal Form (BCNF)
STUDENT_ADVISOR
Primary Key: Student_ID, Major
Student_ID Advisor Major
Candidate Key: Student_ID, Advisor
Advisor  Major
A relation
where a
determinant is Student_ID Major Advisor
not a 222-22-2020 MIS Leigh
candidate key 232-22-2111 Management Gowan
222-22-2020 MIS Roberts
222-22-2111 Marketing Reynolds
255-24-2332 Marketing Reynolds
Note: Students can have a double major and have an advisor
for each major. An advisor works only with students in their
assigned area.
Boyce-Codd Normal Form (BCNF)
STUDENT_ADVISOR
Divide the Key: Student_ID, Advisor
Student_ID Advisor
relation into two
relations that
ADVISOR_MAJOR Key: Advisor
meet BCNF
Advisor Major Advisor  Major

Student_ID Advisor Advisor Major


222-22-2020 Leigh Leigh MIS
232-22-2111 Gowan Gowan Management
222-22-2020 Roberts Roberts MIS
222-22-2111 Reynolds
Reynolds Marketing
255-24-2332 Reynolds

You might also like