The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

Introduction to Normalization of Database Tables Database Tables and Normalization l Normalization is a process for assigning attributes to entities.

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by , 2016-05-05 23:00:03

Functional Dependency Examples of Functional Dependencies

Introduction to Normalization of Database Tables Database Tables and Normalization l Normalization is a process for assigning attributes to entities.

Normalization of Database Tables

Introduction to Normalization of Database Tables Introduction to l Objectives
Normalization Normalization 4 The idea of Dependencies of Attributes
of of 4 Normalization and Database Design
Database Database 4 Understand concepts of normalization
Tables Tables
(Higher-Level Normal Forms)
ISM 602 4 Learn how to normalize tables
Dr. Hamid Nemati 4 Understand normalization and database

design issues
4 Denomalization

Functional Dependency Examples of Functional Dependencies:

Introduction to l A Functional Dependency Is A Relationship Between Introduction to l If we know an ISBN, then we know the Book Title and
Normalization Or Among Attributes Such That The Values Of One Normalization the author(s)
of Attribute Depend On, Or Are Determined By, The of l ISBN è Book Title
Database Values Of The Other Attribute(s). Database l ISBN è Author(s)
Tables Tables
l Partial Dependency: Is A Relationship Between l If we know the VIN, then we know who is the Auto
Attributes Such That The Values Of One Attribute Is owner
Dependent On, Or Determined By, The Values Of l VIN è Auto_Owner
Another Attribute Which Is Part Of The Composite Key.
l If we know Student-ID (SID), then we can uniquely
l Partial Dependencies Are Not Good Due To duplication determine his/her Name
Of Data And Update Anomalies; l SID è S_Name

Transitive Dependencies So Now what is Normalization?

Introduction to l Is A Relationship Between Attributes Such That The Introduction to l GOLDEN RULE OF NORMALIZATION: Enter The
Normalization Values Of One Attribute Is Dependent On, Or Normalization Minimum Data Necessary, Avoiding Duplicate Entry
of Determined By, The Values Of Another Attribute of Of Information, With Minimum Risks To Data
Database Which Is Not A Part Of The Key. Database Integrity.
Tables Tables
l Exist when a nonkey attribute value is functionally l Goals Of Normalization:
dependent upon another nonkey value in the record. For
example: u Eliminate Redundancies Caused By:

l EMPLOYEE_ID --> JOB_CATEGORY l Fields Repeated Within A File
l Fields Not Directly Describing The Key Entity
l JOB_CATEGORY --> HOURLY_RATE l Fields Derived From Other Fields

l An employee data table that includes the “hourly pay u Avoid Anomalies In Updating (Adding, Editing,
rate” would require searching every employee record to Deleting)
properly update an hourly rate for a particular job
category. u Represent Accurately The Items Being Modeled

u Simplify Maintenance And Retrieval Of Info

Database Tables and Normalization Basic Rule for Normalization

Introduction to l Normalization is a process for assigning attributes Introduction to l The attribute values in a relational table should
Normalization to entities. It reduces data redundancies and helps Normalization be functionally dependent (FD) on the primary
of eliminate the data anomalies. of key value.
Database Database
Tables l Normalization works through a series of stages Tables u A relationship is functionally dependent when one
called normal forms: attribute value implies or determines the attribute
u First normal form (1NF) value for the other attribute.
u Second normal form (2NF)
l EM_SS_NUM --> EM_NAME
u Third normal form (3NF)
l Corollaries
l The highest level of normalization is not always
desirable. u Corollary 1: No repeating groups allowed in
relational tables.

u Corollary 2: A relational table should not have
attributes involved in a transitive dependency
relationship with the primary key.

Normalization Benefits Database Tables and Normalization

Introduction to l Facilitates data integration. Introduction to l The Need for Normalization
Normalization l Reduces data redundancy. Normalization
of l Provides a robust architecture for retrieving of u Case of a Construction Company
Database Database
Tables and maintaining data. Tables l Building project -- Project number, Name, Employees
l Compliments data modeling. assigned to the project.
l Reduces the chances of data anomalies
l Employee -- Employee number, Name, Job classification
occurring. l The company charges its clients by billing the hours spent

on each project. The hourly billing rate is dependent on the
employee’s position.

Database Tables and Normalization Deletion Anomaly

Introduction to l Problems with the Table 5.1 Introduction to l Occurs when the removal of a record results in a
Normalization u The project number is intended to be a primary key, Normalization loss of important information about an entity.
of but it contains nulls. of
Database u The table displays data redundancies. Database l Example:
Tables u The table entries invite data inconsistencies. Tables
l All the information about a customer is contained in an order
u The data redundancies yield the following file, if the order is canceled, all the customer information
anomalies: could be lost when the order record is deleted

l Update anomalies. l Solution:
l Addition anomalies.
l Deletion anomalies. l Create two tables--one table contains order information and
the other table contains customer information.

Update Anomaly Insertion Anomaly

Introduction to l Occurs when a change of a single attribute in one Introduction to l Occurs when there does not appear to be any
Normalization record requires changes in multiple records Normalization reasonable place to assign attribute values to
of of records in the database. Probably have
Database l Example: Database overlooked a critical entity.
Tables Tables
u A staff person changes their telephone number l Example:
and every potential customer that person ever
worked with has to have the corrected number u Adding new attributes or entire records when they
inserted. are not needed. Where do you place information
on new Evaluator’s? Do you create a dummy
l Solution: Lead.

u Put the employees telephone number in one l Solution:
location--as an attribute in the employee table.
u Create a new table with a primary key that
contains the relevant or functional dependent
attributes.

Database Tables and Normalization Database Tables and Normalization

Introduction to l Conversion to First Normal Form Introduction to l Dependency Diagram
Normalization Normalization
of u A relational table must not contain repeating groups. of u The arrows above the entity indicate that the entity’s
Database Database attributes are dependent on the combination of
Tables u Repeating groups can be eliminated by adding the Tables PROJ_NUM and EMP_NUM.
appropriate entry in at least the primary key
column(s). (See Database Table 5.3) u The arrows below the dependency diagram indicate
less desirable dependencies based on only a part of
the primary key -- partial dependencies.

Database Table 5.2 The Evergreen Data

Figure 5.1 A Dependency Diagram: First Normal Form

Database Tables and Normalization Database Tables and Normalization

Introduction to l 1NF Definition Introduction to l Conversion to Second Normal Form
Normalization u The term first normal form (1NF) describes the Normalization
of tabular format in which: of u Starting with the 1NF format, the database can be
Database Database converted into the 2NF format by
Tables l All the key attributes are defined. Tables
l There are no repeating groups in the table. l Writing each key component on a separate line, and then
l All attributes are dependent on the primary key. writing the original key on the last line and

l Writing the dependent attributes after each new key.

PROJECT (PROJ_NUM, PROJ_NAME)
EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS,

CHG_HOUR)

ASSIGN (PROJ_NUM, EMP_NUM, HOURS)

Database Tables and Normalization Database Tables and Normalization

Introduction to l 2NF Definition Introduction to l Conversion to Third Normal Form
Normalization Normalization u Create a separate table with attributes in a transitive
of u A table is in 2NF if: of functional dependence relationship.
Database Database
Tables l It is in 1NF and Tables PROJECT (PROJ_NUM, PROJ_NAME)
l It includes no partial dependencies; that is, no ASSIGN (PROJ_NUM, EMP_NUM, HOURS)
EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS)
attribute is dependent on only a portion of the primary JOB (JOB_CLASS, CHG_HOUR)
key.

u Note:

It is still possible for a table in 2NF to exhibit
transitive dependency; that is, one or more attributes
may be functionally dependent on nonkey attributes.

u See figure 5.2 page 290.

Database Tables and Normalization Normalization and Database Design

Introduction to l 3NF Definition Introduction to l Database Design and Normalization Example:
Normalization u A table is in 3NF if: Normalization (Construction Company)
of of
Database l It is in 2NF and Database u Summary of Operations:
Tables l It contains no transitive dependencies. Tables
l The company manages many projects.
l Each project requires the services of many employees.

l An employee may be assigned to several different projects.
l Some employees are not assigned to a project and perform

duties not specifically related to a project. Some employees
are part of a labor pool, to be shared by all project teams.
l Each employee has a (single) primary job classification.
This job classification determines the hourly billing rate.
l Many employees can have the same job classification.

Normalization and Database Design Normalization and Database Design

Introduction to l Two Initial Entities: Introduction to l Three Entities After Transitive Dependency
Normalization Normalization Removed
of PROJECT (PROJ_NUM, PROJ_NAME) of
Database Database PROJECT (PROJ_NUM, PROJ_NAME)
Tables EMPLOYEE (EMP_NUM, EMP_LNAME, EMP_FNAME, Tables
EMP_INITIAL, JOB_DESCRIPTION, EMPLOYEE (EMP_NUM, EMP_LNAME, EMP_FNAME,
JOB_CHG_HOUR) EMP_INITIAL, JOB_CODE)

JOB (JOB_CODE, JOB_DESCRIPTION,
JOB_CHG_HOUR)

Figure 5.7 The Initial E-R Diagram for a Contracting Company

Normalization and Database Design Normalization and Database Design

Introduction to l Creation of the Composite Entity ASSIGN
Normalization
of Introduction to
Database Normalization
Tables of
Database
Tables

Figure 5.8 The Modified E-R Diagram for a Contacting Company

Figure 5.9 The Final (Implementable) E-R Diagram
for the Contracting Company

Normalization and Database Design Normalization and Database Design

Introduction to l Attribute ASSIGN_HOUR is assigned to the Introduction to
Normalization composite entity ASSIGN. Normalization
of of
Database l “Manages” relationship is created between Database
Tables EMPLOYEE and PROJECT. Tables

PROJECT (PROJ_NUM, PROJ_NAME, EMP_NUM) Figure 5.10 The Relational Schema for the Contracting Company
EMPLOYEE (EMP_NUM, EMP_LNAME, EMP_FNAME,

EMP_INITIAL, EMP_HIREDATE, JOB_CODE)
JOB (JOB_CODE, JOB_DESCRIPTION,

JOB_CHG_HOUR)
ASSIGN (ASSIGN_NUM, ASSIGN_DATE, PROJ_NUM,

EMP_NUM, ASSIGN_HOURS)

Summary Denormalization
A Journey of Normalization

Introduction to First Normal Form Remove Introduction to l Normalization is only one of many database design
Normalization (1NF) “Repeating Groups” Normalization goals.
of of
Database Second Normal Form Remove Database l Normalized (decomposed) tables require additional
Tables (2NF) “Partial Functional Tables processing, reducing system speed.

Third Normal Form Dependency” l Normalization purity is often difficult to sustain in
(3NF) the modern database environment. The conflict
Remove between design efficiency, information
“Transitive Functional requirements, and processing speed are often
resolved through compromises that include
Dependency” denormalization.

Higher order Normal Remove
Forms “All Remaining Functional

Dependency”


Click to View FlipBook Version