Beruflich Dokumente
Kultur Dokumente
Normalization
Pengenalan Basisdata
Togu Turnip - Institut Teknologi Del
Minggu 10 Sesi 01
AGENDA
1 What is normalization
2 Goals of normalization
3 Functional Dependency
5 Denormalization
“
1
What is
Normalization?
Normalization
• Normalization is the process for evaluating and correcting
relation structures to minimize data redundancies.
• Normalization is a database design technique which
organizes tables in a manner that reduces redundancy and
dependency of data.
• A process that goes by levels, refining the design each time
• Although we deals with relation, the refinement is mostly on
the relationship level.
Normalization
• So what’s the point?
• Each level reduces more redundancy
• Each level also makes DB operation slower
• In other words, It divides larger tables to smaller tables and
links them using relationships.
• There are many levels of normalization, but the typical
stopping point is the 3 (3NF)
rd
The History of Normalization
• The inventor of the relational model Edgar Codd
proposed the theory of normalization with the
introduction of First Normal Form.
• He continued to extend theory with Second and
Third Requirement
Normal Form.StagesRequirement Stages
• Later he joined with Raymond F. Boyce to develop
the theory of Boyce-Codd Normal Form.
Requirement Stages
2 The Goal of
Normalization
Goals of Normalization
• Decide whether a particular relation R is in “good” form.
• In the case that a relation R is not in “good” form, decompose it
into a set of relations {R1, R2, ..., Rn} such that
• each relation is in good form
• the decomposition is a lossless-join decomposition
• A relation represents only a single theme and its attributes
• Data should be kept in one relation where possible (controlled
redundancy) to eliminate update anomalies
• All data in a row must depend on the PK
Modification Anomaly
• No update, insertion, or deletion anomalies so
integrity and consistency is ensured
• Our theory is based on:
• functional dependencies
• Relations are categorized as a normal form based
on which modification anomalies or other problems
they are subject to:
Example: Update Anomaly
• The
EQUIPMENT_REPAIR
table before and after
an incorrect update
operation on
AcquisitionCost for
Type = Drill Press:
Normal Form
Requirement Stages
3
Functional Dependency
* See the previous slide
“
4
Normalization by
Levels
1NF - 3NF
• Normalization that will be covered in these course:
• 1NF : No repeating elements or group of elements
• 2NF : No partial dependencies on a concatenated
key
• 3NF : No dependencies on non-key attributes
• Rule if the normalization fails:
“create a new table”
Problem:
Keeping Track of A Stack of Invoices
1 NF
• No repeating elements or group of elements
• Repeating group multiple entries exist for the same key
Step-by-Step 1 NF
• Those of us who have an ordered mind but aren’t quite aware of relational databases
might try to capture the Invoice data in a spreadsheet, such as Microsoft Excel
• Try to answer these questions:
• How many 3” Red Freen did Freen R Us order in 2002?
• What are total sales of 56” Blue Freens in the state of Texas?
• What items are sold on July 14, 2003?
• As the spreadsheet grows, it becomes increasingly difficult to ask the spreadsheet these
questions, we begin the NORMALIZATION process
Step-by-Step 1 NF
• Solutions:
• Create a new table, in which
• The first table : keep the attributes that doesn’t fail 1NF
• The second table : attributes that fails the 1NF, but the PK will be
concatenated(composite) key (key from non-fails attributes and key of fails
attributes).
The Result of 1 NF
Orders
Order_Items
2 NF
• A relation is in 2NF if all of its non-key attributes are
dependent on all of the primary keys.
• No partial dependencies on a concatenated key.
Step-by-Step 2 NF
• Questions:
• Do we have table with concatenated key?
• Named Tables with no concatenated key, is in 2NF
• Tables with concatenated key, we should check whether there
are partial dependencies on a concatenated key.
• From 1NF:
• Orders : is in 2NF
• Order_Items : check for 2NF
Step-by-Step 2 NF
• Questions:
• Is item_description wholly depends on order_id and item_id?
Or partiallly?
• Is item_qty wholly depends on order_id and item_id? Or
partiallly ?
• Is item_price wholly depends on order_id and item_id? Or
partiallly ?
Step-by-Step 2 NF
• Analysis
• If wholly depends than NO PROBLEM
• If any attributes are partially depend on PK then, it fails 2NF
Create a new table
• Solution
• Create a new table from Order_Items in which the new table
consists of attributes that fails and its PK.
The Result of 2 NF