0% found this document useful (0 votes)
43 views43 pages

Normalization of Database Models

This document discusses database normalization and the process of converting tables from lower normal forms to higher normal forms. It covers the concepts of 1NF, 2NF, 3NF, BCNF, and 4NF. An example of normalizing a database for a construction company is provided to demonstrate how to recognize and address issues like transitive dependencies and multi-valued dependencies through decomposition and conversion to higher normal forms. The document also notes that total normalization must be balanced with performance considerations, which may require some controlled denormalization.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views43 pages

Normalization of Database Models

This document discusses database normalization and the process of converting tables from lower normal forms to higher normal forms. It covers the concepts of 1NF, 2NF, 3NF, BCNF, and 4NF. An example of normalizing a database for a construction company is provided to demonstrate how to recognize and address issues like transitive dependencies and multi-valued dependencies through decomposition and conversion to higher normal forms. The document also notes that total normalization must be balanced with performance considerations, which may require some controlled denormalization.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

Chapter 4

Normalization of Database Tables

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

In this chapter, you will learn:

That normalization and E-R modeling are used concurrently to produce a good database design That some situations require denormalization to generate information efficiently

Database Tables and Normalization


Table is basic building block in database design Tables structure is of great interest Two cases:

possible poor table structures in good database design Modify existing database with existing poor table structure

Normalization can help recognize a poor table and convert to good tables with good structure
4

Database Tables and Normalization

Normalization is process for assigning attributes to entities


Reduces data redundancies Expending entities Helps eliminate data anomalies Produces controlled redundancies to link tables Cost more processing efforts Series steps called normal forms

Database Tables and Normalization

Normalization stages
1NF - First normal form 2NF - Second normal form 3NF - Third normal form 4NF - Fourth normal form

Business Bioinformatics Statistical data

Better in dependency

Worse in performance (I/O)


6

Database Tables and Normalization

Example: construction company

Building projects

Project number Project name Employees assigned Employee number Employee name Job classification
7

Employee

Table 4.1 should be here.

Figure 4.1 Observations

PRO_NUM intended to be primary key, but it contains null values. Table entries invite data inconsistencies

Figure 4.1 Observations

Table displays data redundancies which yield the following anomalies

Update

Modifying JOB_CLASS New employee must be assigned project (phantom project) If employee deleted, other vital data lost

Insertion

Deletion

10

Figure 4.2 is insert here.

Repeating group (any project can have a group of data entries) which should not to be appeared in relational table
11

Data Organization: 1NF


PK PK

Figure 4.3

12

Conversion to 1NF

Repeating groups must be eliminated

Proper primary key developed


Uniquely identifies attribute values (rows) Combination of PROJ_NUM and EMP_NUM

13

Conversion to 1NF

Repeating groups must be eliminated


Dependencies can be identified Desirable dependencies based on primary key Less desirable dependencies

Partial

based on part of composite primary key one nonprime attribute depends on another nonprime attribute
14

Transitive

Dependency Diagram (1NF)


Above: Desired Dependencies

Composite primary key Below: Less Desired Dependencies

Figure 4.4

15

PROJ_NUM,EMP_NUM PROJ_NAME, EMP_NAME, JOB_CLASS,CHG_HOUR, HOURS

DESIRED DEPENDENCIES

PROJ_NUM PROJ_NAME

PARTIAL DEPENDENCIES

EMP_NUM EMP_NAME, JOB_CLASS, CHG_HOUR

JOB_CLASS -> CHG_HOUR

TRANSITIVE DEPENDENCIES

16

1NF Summarized

All key attributes defined No repeating groups in table All attributes dependent on primary key

17

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)
18

2NF Conversion Results


Figure 4.5

19

2NF Summarized

In 1NF Includes no partial dependencies

No attribute dependent on a portion of primary key


Attributes may be functionally dependent on nonkey attributes
20

Still possible to exhibit transitive dependency

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)

21

3NF Summarized

In 2NF Contains no transitive dependencies

22

Additional DB Enhancements

Figure 4.6

23

24

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

25

3NF Table Not in BCNF

Figure 4.7

26

Decomposition of Table Structure to Meet BCNF

Figure 4.8
27

Example: BCNF conversion

28

Decomposition into BCNF

Figure 4.9
29

Normalization and Database Design

Normalization should be part of the design process Make sure the proposed entities meet the required normal form before the table structures are created Used to redesign or modify the existing table structures. E-R Diagram provides macro view
30

Normalization and Database Design

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
31

Normalization and Database Design

Contracting companys example:

PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, JOB_DESCRIPTION, JOB_CHG_HOUR);

32

Initial ERD for Contracting Company

Figure 4.10
There is a transitive dependency

Already 3NF
33

Removal
PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, JOB_CODE) JOB (JOB_CODE, JOB_DESCRIPTION, JOB_CHG_HOUR);

34

Modified ERD for Contracting Company

Figure 4.11
35

Final ERD for Contracting Company

Figure 4.12 (M:N) converting to (1:M)


36

PROJECT (PROJ_NUM, PROJ_NAME, EMP_NUM) EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, EMP_HIREDATE, JOB_CODE) JOB (JOB_CODE,, JOB_DESCRIPTION, JOB_CHG_HOUR); ASSIGN((ASSIGN_NUM, ASSIGN_DATE, ASSIGN_HOURS, ASSIGN_CHG_HOURS, ASSIGN_CHARGE, EMP_NUM, PROJ_JUM)

37

38

Higher-Level Normal Forms

Fourth Normal Form (4NF)


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

39

Conversion to 4NF

Figure 4.15 Set of Tables in 4NF

Figure 4.14 Multivalued Dependencies


40

Denormalization

Normalization is one of many database design goals Normalized table requirements


Additional processing Loss of system speed

41

Denormalization

Normalization purity is difficult to sustain due to conflict in:


Design efficiency Information requirements Processing

42

Unnormalized Table Defects


Data updates less efficient Indexing more cumbersome No simple strategies for creating views

43

You might also like