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

Nomlization (Lecture#1)

IT

Uploaded by

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

Nomlization (Lecture#1)

IT

Uploaded by

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

4

Normalization of DB

Imran Khan

FCS-IBA-Karachi
4

In this chapter, you will learn:

• What normalization is and what role it plays in


database design
• About the normal forms 1NF, 2NF, 3NF, BCNF,
and 4NF
• How normal forms can be transformed from lower
normal forms to higher normal forms
• That normalization and E-R modeling are used
concurrently to produce a good database design
• That some situations require denormalization to
generate information efficiently

Chapter 4 Normalization of Database Tables 2


4
Database Tables and Normalization
• Table is basic building block in database design
• Normalization is process for assigning attributes
to entities
– Reduces data redundancies
– Helps eliminate data anomalies
– Produces controlled redundancies to link tables
• Normalization stages
– 1NF - First normal form
– 2NF - Second normal form
– 3NF - Third normal form
– 4NF - Fourth normal form
– 5NF – FIFTH normal form

Chapter 4 Normalization of Database Tables 3


4
Need for Normalization

• PRO_NUM intended to be primary key


• Table entries invite data inconsistencies Figure 4.1
• Table displays data anomalies
– Update
• Modifying JOB_CLASS
– Insertion
• New employee must be assigned project
– Deletion
• If employee deleted, other vital data lost
Chapter 4 Normalization of Database Tables 4
4
Conversion to 1NF

• Repeating groups must be eliminated


– Proper primary key developed
• Uniquely identifies attribute values (rows)
• Combination of PROJ_NUM and EMP_NUM
– Dependencies can be identified
• Desirable dependencies based on primary key
• Less desirable dependencies
– Partial
» based on part of composite primary key
– Transitive
» one nonprime attribute depends on another nonprime
attribute

Chapter 4 Normalization of Database Tables 5


4
Dependency Diagram (1NF)

Figure 4.4

Chapter 4 Normalization of Database Tables 6


4
Data Organization: 1NF

• All key attributes defined


Figure 4.3
• No repeating groups in table
• All attributes dependent on primary key

Chapter 4 Normalization of Database Tables 7


4
Conversion to 2NF

• Start with 1NF format:


• Write each key component on separate line
• Write original key on last line
• Each component is new table
• Write dependent attributes after each key

PROJECT (PROJ_NUM, PROJ_NAME)


EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS, CHG_HOUR)
ASSIGN (PROJ_NUM, EMP_NUM, HOURS)

Chapter 4 Normalization of Database Tables 8


2NF Conversion Results 4

Figure 4.5

• In 1NF
• Includes no partial dependencies
– No attribute dependent on a portion of primary key
• Still possible to exhibit transitive dependency
– Attributes may be functionally dependent on nonkey attributes

Chapter 4 Normalization of Database Tables 9


4
Conversion to 3NF

• Create separate table(s) to eliminate transitive


functional dependencies

PROJECT (PROJ_NUM, PROJ_NAME)


ASSIGN (PROJ_NUM, EMP_NUM, HOURS)
EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS)
JOB (JOB_CLASS, CHG_HOUR)

• In 2NF
• Contains no transitive dependencies

Chapter 4 Normalization of Database Tables 10


4
Additional DB Enhancements

Figure 4.6

Chapter 4 Normalization of Database Tables 11


4
Boyce-Codd Normal Form (BCNF)

• Every determinant in the table is a candidate key


– Determinant is attribute whose value determines
other values in row
– 3NF table with one candidate key is already in
BCNF

Chapter 4 Normalization of Database Tables 12


4
3NF Table Not in BCNF

Figure 4.7

Chapter 4 Normalization of Database Tables 13


4
Decomposition of Table
Structure to Meet BCNF

Figure 4.8

Chapter 4 Normalization of Database Tables 14


4
Decomposition into BCNF

Figure 4.9
Chapter 4 Normalization of Database Tables 15
4
Normalization and Database Design

• Normalization should be part of the design


process
• E-R Diagram provides macro view
• Normalization provides micro view of entities
– Focuses on characteristics of specific entities
– May yield additional entities
• Difficult to separate normalization from E-R
diagramming
• Business rules must be determined

Chapter 4 Normalization of Database Tables 16


4
Initial ERD for Contracting Company

Figure 4.10

Chapter 4 Normalization of Database Tables 17


4
Modified ERD for
Contracting Company

Figure 4.11 18
Chapter 4 Normalization of Database Tables
4
Final ERD for
Contracting Company

Figure 4.12

Chapter 4 Normalization of Database Tables 19


4

Higher-Level Normal Forms

• Fourth Normal Form (4NF)


– Table is in 3NF
– Has no multiple sets of multivalued dependencies

Chapter 4 Normalization of Database Tables 20


4
Conversion to 4NF

Figure 4.15 Set of Tables in 4NF

Figure 4.14 Multivalued Dependencies

Chapter 4 Normalization of Database Tables 21


4
An Example of 4NF
ProjectNo Developer Lead Developer

20020123 John Doe Elmer Fudd

20020123 Jane Doe Sylvester

20020123 Jimbo Elmer Fudd

20020124 John Doe Ms. Depesto

ProjectNo Lead Developer Lead Developer Developer


20020123 Elmer Fudd Elmer Fudd John Doe
20020123 Sylvester Elmer Fudd Jimbo
20020123 Elmer Fudd Sylvester Jane Doe
20020124 Ms. Depesto Ms. Depesto John Doe

Chapter 4 Normalization of Database Tables 22


4
5NF - Fifth Normal Form

• Reduce fourth normal form entities to fifth normal


form (5NF) by removing pairwise cyclic
dependencies (appearing within composite
primary keys with three or more component
attributes) to three or more parent entities

Chapter 4 Normalization of Database Tables 23


4
5 NF (CONT..)

• This addresses problems that arise from


representing associations between multiple
entities with interdependencies. Making it 5NF
consists of adding parent tables, one for each
meaningful combination that has children in the
original table.
• A table with such information is 5NF if the
information cannot be represented in multiple
smaller entities alone.

Chapter 4 Normalization of Database Tables 24


4
5 NF - EXAMPLE

• An example of such a situation may be the


representation of Actors, Plays, and Theaters. In
order to know who plays what and where, we
need the combination of these three attributes.
However, they each relate to each other
cyclically. So to resolve this, we would need to
establish parent tables with Actor - Play, Play -
Theater, and Theater - Actor. These would each
contain a portion of the Primary Key in the Actor,
Play, and Theater table.

Chapter 4 Normalization of Database Tables 25


4
5 NF - EXAMPLE

Actor Play Theater

Billy Bob Catcher in the Rye West 42nd

Ann Catcher in the Rye West 42nd

John Catch-22 Broadway

Lily Hamlet Broadway

Lisa Cats West 42nd

Andy Cats Darlington

Chapter 4 Normalization of Database Tables 26


4
5 NF - EXAMPLE

Chapter 4 Normalization of Database Tables 27


4
Denormalization

• Normalization is one of many database design


goals
• Normalized table requirements
– Additional processing
– Loss of system speed
• Normalization purity is difficult to sustain due to
conflict in:
– Design efficiency
– Information requirements
– Processing

Chapter 4 Normalization of Database Tables 28


4

Unnormalized Table Defects

• Data updates less efficient


• Indexing more cumbersome
• No simple strategies for creating views

Chapter 4 Normalization of Database Tables 29

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy