Sei sulla pagina 1di 15

Relational Database Management Systems

Objectives

In this session, you will learn to:


Describe data redundancy Describe the first, second, and third normal forms Describe the Boyce-Codd Normal Form Appreciate the need for denormalization

Ver. 1.0

Session 3

Slide 1 of 15

Relational Database Management Systems


Understanding Data Redundancy

Redundancy means repetition of data. Redundancy increases the time involved in updating, adding, and deleting data. It also increases the utilization of disk space and hence, disk I/O increases. Redundancy can lead to the following problems:
Inserting, modifying, and deleting data may cause inconsistencies Errors are more likely to occur when facts are repeated Unnecessary utilization of extra disk space

Ver. 1.0

Session 3

Slide 2 of 15

Relational Database Management Systems


Definition of Normalization

Normalization is a scientific method of breaking down complex table structures into simple table structures by using certain rules. It allows you to reduce redundancy in a table and eliminate the problems of inconsistency and disk space usage. Normalization results in the formation of tables that satisfy certain specified rules and represent certain normal forms. The most important and widely used normal forms are:
First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce-Codd Normal Form (BCNF)

Ver. 1.0

Session 3

Slide 3 of 15

Relational Database Management Systems


First Normal Form (1 NF)

A table is said to be in the 1NF when each cell of the table contains precisely one value. Functional Dependency:
The normalization theory is based on the fundamental notion of functional dependency. Given a relation R, attribute A is functionally dependent on attribute B if each value of A in R is associated with precisely one value of B.

Ver. 1.0

Session 3

Slide 4 of 15

Relational Database Management Systems


Second Normal Form (2 NF)

A table is said to be in 2NF when it is in 1NF and every attribute in the row is functionally dependent upon the whole key, and not just part of the key. To ensure that a table is in 2NF, you should:
Find and remove attributes that are functionally dependent on only a part of the key and not on the whole key and place them in a different table. Group the remaining attributes.

Ver. 1.0

Session 3

Slide 5 of 15

Relational Database Management Systems


Third Normal Form (3 NF)

A relation is said to be in 3NF when it is in 2NF and every non-key attribute is functionally dependent only on the primary key. To ensure that a table is in 3NF, you should:
Find and remove non-key attributes that are functionally dependent on attributes that are not the primary key and place them in a different table. Group the remaining attributes.

Ver. 1.0

Session 3

Slide 6 of 15

Relational Database Management Systems


Boyce-Codd Normal Form (BCNF)

The original definition of 3NF was inadequate in some situations. It was not satisfactory for the tables:
that had multiple candidate keys where the multiple candidate keys were composite where the multiple candidate keys overlapped

Therefore, a new normal form-the BCNF was introduced:


A relation is in the BCNF if and only if every determinant is a candidate key.

Ver. 1.0

Session 3

Slide 7 of 15

Relational Database Management Systems


Boyce-Codd Normal Form (BCNF) (Contd.)

In order to ensure that a table is in BCNF, you should:


Find and remove the overlapping candidate keys. Place the part of the candidate key and the attribute it is functionally dependent on, in a different table. Group the remaining items into a table.

Ver. 1.0

Session 3

Slide 8 of 15

Relational Database Management Systems


Just a minute

Which of the following help in achieving a good database design?


1. A table should store data for all the related entities together. 2. Each table should have an identifier. 3. Columns that contain NULL values should be created.

Answer:
2. Each table should have an identifier.

Ver. 1.0

Session 3

Slide 9 of 15

Relational Database Management Systems


Just a minute

For which normal form you need to remove non-key attributes that are functionally dependent on attributes that are not primary key?

Solution:
Third normal form

Ver. 1.0

Session 3

Slide 10 of 15

Relational Database Management Systems


Understanding Denormalization

The end product of normalization is a set of related tables that comprise the database. However, in the interests of speed of response to critical queries, which demand information from more than one table, it is sometimes wiser to introduce a degree of redundancy in tables. The intentional introduction of redundancy in a table to improve performance is called denormalization.

Ver. 1.0

Session 3

Slide 11 of 15

Relational Database Management Systems


Just a minute In the reporting system, the total amount paid to a contract recruiter is often required. The required result can be calculated using the two tables, ContractRecruiter and Payment.
ContractRecruiter Payment

cContractRecruiterCode
cName vAddress cCity siPercentageCharge

cSourceCode
mAmount cChequeNo dDate

Since the size of the Payment table is large, the join between the two tables takes time to generate the required output. It is, therefore, necessary to improve the performance of this query.

Ver. 1.0

Session 3

Slide 12 of 15

Relational Database Management Systems


Just a minute

Answer:
Denormalize the tables. Add a column called mTotalPaid to the ContractRecruiter table.
ContractRecruiter cContractRecruiterCode cName vAddress cCity siPercentageCharge mTotalPaid

Ver. 1.0

Session 3

Slide 13 of 15

Relational Database Management Systems


Summary

In this session, you learned that:


Normalization is used to simplify table structures. Normalization results in the formation of tables that satisfy certain specified constraints, and represent certain normal forms. The normal forms are used to ensure that various types of anomalies and inconsistencies are not introduced in the database. A table structure is always in a certain normal form. Several normal forms have been identified. The most important and widely used of these are:
First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce Codd Normal Form (BCNF)

Ver. 1.0

Session 3

Slide 14 of 15

Relational Database Management Systems


Summary (Contd.)

The intentional introduction of redundancy in a table in order to improve performance is called denormalization. The decision to denormalize results in a trade-off between performance and data integrity. Denormalization increases disk space utilization.

Ver. 1.0

Session 3

Slide 15 of 15

Potrebbero piacerti anche