You are on page 1of 48

Chapter 5: NORMALIZATION OF DATABASE TABLES Database Systems: Design, Implementation, and Management

Eighth Edition

Objectives

In this chapter, you will learn:


What normalization is and what role it plays in the database design process About the normal forms 1NF, 2NF and 3NF How normal forms can be transformed from lower normal forms to higher normal forms That normalization and ER modeling are used concurrently to produce a good database design

Database Systems, 8th Edition

Database Tables and Normalization

Normalization
Process for evaluating and correcting table structures to minimize data redundancies
Reduces data anomalies

Works through a series of stages called normal forms:


First normal form (1NF) Second normal form (2NF) Third normal form (3NF)

Database Systems, 8th Edition

Database Tables and Normalization (continued)

Normalization
2NF is better than 1NF; 3NF is better than 2NF For most business database design purposes, 3NF is as high as needed in normalization Highest level of normalization is not always most desirable

Denormalization produces a lower normal form


Will not be covered in this course
Database Systems, 8th Edition 4

Purpose of Normalization

Characteristics of a suitable set of relations include:


the minimal number of attributes necessary to support the data requirements of the enterprise; attributes with a close logical relationship are found in the same relation; minimal redundancy with each attribute represented only once with the important exception of attributes that form all or part of foreign keys.
Pearson Education Limited 1995, 2005 5

Purpose of Normalization

The benefits of using a database that has a suitable set of relations is that the database will be:
easier for the user to access and maintain the data; take up minimal storage space on the computer.

Pearson Education Limited 1995, 2005 6

How Normalization Supports Database Design

7 2005 Pearson Education Limited 1995,

Data Redundancy and Update Anomalies

Major aim of relational database design is to group attributes into relations to minimize data redundancy.

Pearson Education Limited 1995, 2005 8

Data Redundancy and Update Anomalies

Potential benefits for implemented database include:


Updates to the data stored in the database are achieved with a minimal number of operations thus reducing the opportunities for data inconsistencies. Reduction in the file storage space required by the base relations thus minimizing costs.

Pearson Education Limited 1995, 2005 9

Data Redundancy and Update Anomalies

Problems associated with data redundancy are illustrated by comparing the Staff and Branch relations with the StaffBranch relation.

Pearson Education Limited 1995, 2005 10

Data Redundancy and Update Anomalies

StaffBranch relation has redundant data; the details of a branch are repeated for every member of staff.

Pearson Education Limited 1995, 2005 11

Data Redundancy and Update Anomalies

Relations that contain redundant information may potentially suffer from the following anomalies.
Modification eg.modify Branch address Insertion inserting new branch requires staff data Deletion - if staff deleted, other vital data (branch) lost, eg SA9

12

Data Redundancy and Update Anomalies

Normalized tables

The branch information appears only once for each branch in the Branch relation and only the branch number (branchNo) is repeated in the Staff relation, to represent where each member of staff is located.
Pearson Education Limited 1995, 2005 13

The Need for Normalization (Another Example)

Example: company that manages building projects


Charges its clients by billing hours spent on each contract Hourly billing rate is dependent on employees position Periodically, report is generated that contains information such as displayed in Table 5.1

Database Systems, 8th Edition

14

Database Systems, 8th Edition

15

Database Systems, 8th Edition

16

PROJ_NUM intended to be primary key Table entries invite data inconsistencies Table displays data anomalies

Update / Modification
Modifying JOB_CLASS

Insertion
New employee must be assigned project

Deletion
Database Systems: Design,data lost If employee deleted, other vital Implementation, & Management, 5th Edition, Rob & Coronel 17

The Normalization Process


Each table represents a single subject No data item will be unnecessarily stored in more than one table All attributes in a table are dependent on the primary key Each table void of insertion, update, deletion anomalies

Database Systems, 8th Edition

18

Database Systems, 8th Edition

19

The Normalization Process (continued)


Objective of normalization is to ensure all tables in at least 3NF Higher forms not likely to be encountered in business environment Normalization works one relation at a time Progressively breaks table into new set of relations based on identified dependencies

Database Systems, 8th Edition

20

Database Systems, 8th Edition

21

The Process of Normalization

22 Pearson Education Limited 1995, 2005

Conversion to First Normal Form

Relational table must not contain repeating groups


Repeating group - Group of multiple entries of same type exist for any single key attribute occurrence E.g. : (PRO_NUM =15) shows five entries

Normalizing table structure will reduce data redundancies

Database Systems, 8th Edition

23

Database Systems, 8th Edition

24

Conversion to First Normal Form (continued)


Normalization is a three-step procedure Step 1: Eliminate the Repeating Groups
By eliminating nulls each repeating group attribute contains an appropriate data value Convert table 5.1 to 5.2

Step 2: Identify the Primary Key


Must uniquely identify attribute value New key must be composed

Step 3: Identify All Dependencies


Can be depicted with a diagram Database Systems, 8
th

Edition

25

Database Systems, 8th Edition

26

Database Systems, 8th Edition

27

Conversion to First Normal Form (continued)

Dependency diagram:
Depicts all dependencies found within given table structure Helpful in getting birds-eye view of all relationships among tables attributes Makes it less likely that you will overlook an important dependency

Database Systems, 8th Edition

28

PK bold, underlined, different shade of color Arrow above indicate all desirable dependenies based on the PKs (composite PK) Arrow below indicate less desirable dependencies: Partial dependency - dependencies based on part of the PK Transitive dependency nonprime attributes are dependent one Database Systems, 8th Edition another nonprime attribute

29

Conversion to First Normal Form (continued)

First normal form describes tabular format in which:


All key attributes are defined There are no repeating groups in the table All attributes are dependent on primary key

Database Systems, 8th Edition

30

Conversion to Second Normal Form


Two steps: Step 1: Write Each Key Component on a Separate Line
Write each key component on separate line, then write original (composite) key on last line
PROJ_NUM EMP_NUM PRO_NUM EMP_NUM

Each component will become the key in new table The ori table is now divided into 3 tables PROJECT, EMPLOYEE & ASSIGNMENT Database Systems, 8 Edition
th

31

Conversion to Second Normal Form

Step 2: Assign Corresponding Dependent Attributes


Determine those attributes that are dependent on other attributes
PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS, CHG_HOUR) ASSIGNMENT(PROJ_NUM, EMP_NUM, ASSIGN_HOURS)

At this point, most anomalies have been eliminated

Database Systems, 8th Edition

32

Database Systems, 8th Edition

33

Conversion to Second Normal Form (continued)

Table is in second normal form (2NF) when:


It is in 1NF and It includes no partial dependencies:
No attribute is dependent on only portion of primary key

Database Systems, 8th Edition

34

Conversion to Third Normal Form


3 steps: Step 1: Identify Each New Determinant
For every transitive dependency, write its determinant as PK for new table Determinant: any attribute whose value determines other values within a row Transitive dependency: JOB_CLASS CHG_HOUR JOB_CLASS = determinant =PK

Step 2: Identify the Dependent Attributes


Identify attributes dependent on each determinant identified in Step 1 and identify the dependency Name the table to reflect its contents and functionJOB
Database Systems, 8th Edition 35

JOB_CLASS CHG_HOUR

Conversion to Third Normal Form (continued)

Step 3: Remove the Dependent Attributes from Transitive Dependencies


Eliminate all dependent attributes in transitive relationship(s) from each of the tables Draw new dependency diagram to show all tables defined in Steps 13 Check new tables as well as tables modified in Step 3
Each table has determinant No table contains inappropriate dependencies
Database Systems, 8th Edition 36

Database Systems, 8th Edition

37

Conversion to Third Normal Form (continued)

A table is in third normal form (3NF) when both of the following are true:
It is in 2NF It contains no transitive dependencies

Database Systems, 8th Edition

38

Database Systems, 8th Edition

39

Normalization and Database Design


Normalization should be part of the design process Make sure that proposed entities meet required normal form before table structures are created Many real-world databases have been improperly designed or burdened with anomalies You may be asked to redesign and modify existing databases

Database Systems, 8th Edition 40

Normalization and Database Design (continued)

ER diagram
Identify relevant entities, their attributes, and their relationships Identify additional entities and attributes

Normalization procedures
Focus on characteristics of specific entities Micro view of entities within ER diagram

Difficult to separate normalization process from ER modeling process


Database Systems, 8th Edition 41

Database Systems, 8th Edition

42

Database Systems, 8th Edition

43

Database Systems, 8th Edition

44

Database Systems, 8th Edition

45

Database Systems, 8th Edition

46

Summary
Normalization is used to minimize data redundancies First three normal forms (1NF, 2NF, and 3NF) are most commonly encountered Table is in 1NF when:

All key attributes are defined All remaining attributes are dependent on primary key

Database Systems, 8th Edition

47

Summary (continued)

Table is in 2NF when it is in 1NF and contains no partial dependencies Table is in 3NF when it is in 2NF and contains no transitive dependencies Table that is not in 3NF may be split into new tables until all of the tables meet 3NF requirements Normalization is important partbut only partof the design process

Database Systems, 8th Edition

48

You might also like