Docsity

Understanding Normal Forms: 3NF and BCNF, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Understanding Normal Forms: 3NF and BCNF and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

The Normal Forms

3NF and BCNF

Preview

• Normalization

• Solution: Normal Forms

• Introducing 3NF and BCNF

• 3NF

• Examples

• BCNF

Benefits of Normalization

• Less storage space

• Quicker updates

• Less data inconsistency

• Clearer data relationships

• Easier to add data

• Flexible Structure

The Solution: Normal Forms

• Bad database designs results in:

– redundancy: inefficient storage.

– anomalies: data inconsistency, difficulties in

maintenance

• 1NF, 2NF, 3NF, BCNF are some of the early

forms in the list that address this problem

1) First normal form -1NF

• The following table is not in 1NF

DPT_NO MG_NO EMP_NO EMP_NM
D101 12345 20000

Carl Sagan Mag James Larry Bird

D102 13456 30000 30001

Jim Carter Paul Simon

• 1NF : if all attribute values are

atomic: no repeating group, no

composite attributes.

Table in 1NF

  • all attribute values are atomic because there are no repeating

group and no composite attributes.

DPT_NO MG_NO EMP_NO EMP_NM

D101 12345 20000 Carl Sagan

D101 12345 20001 Mag James

D101 12345 20002 Larry Bird

D102 13456 30000 Jim Carter

D102 13456

Paul Simon

No dependencies on non-key attributes

Inventory

Description Supplier Cost Supplier Address

Inventory

Description Supplier Cost

There are two non-key fields. So, here are the questions:

  • If I know just Description, can I find out Cost? No, because

we have more than one supplier for the same product.

  • If I know just Supplier, and I find out Cost? No, because I

need to know what the Item is as well.

Therefore, Cost is fully, functionally dependent upon the

ENTIRE PK (Description-Supplier) for its existence.

CONTINUED…

Supplier

Name Supplier Address

Inventory

Description Supplier Cost Supplier Address

  • If I know just Description, can I find out Supplier Address? No,

because we have more than one supplier for the same product.

  • If I know just Supplier, and I find out Supplier Address? Yes.

The Address does not depend upon the description of the item.

Therefore, Supplier Address is NOT functionally dependent upon

the ENTIRE PK (Description-Supplier)

for its existence.

3) Remove columns that are not dependent upon

the primary key.

So for every nontrivial functional dependency X --> A,

(1) X is a superkey, or

(2) A is a prime (key) attribute.

Books

Name Author's Name

Author's Non-de

Plume

# of Pages

Books

Name Author's Name # of Pages

  • If I know # of Pages, can I find out Author's Name? No. Can I find out

Author's Non-de Plume? No.

  • If I know Author's Name, can I find out # of Pages? No. Can I find out

Author's Non-de Plume? YES.

Therefore, Author's Non-de Plume is functionally dependent upon Author's

Name, not the PK for its existence. It has to go.

Author

Name Non-de Plume

Example of 3NF

The table in 3NF

SUPP# SNAME PART# QTY
S

Yues

P

S1 Yues P2 200

S2 Yues P3 250

S2 Jones P1 300

Example with first three forms

Suppose we have this Invoice Table

First Normal Form: No repeating groups.

  • The above table violates 1NF because it has columns

for the first, second, and third line item.

  • Solution: you make a separate line item table, with

it's own key, in this case the combination of invoice

number and line number

Second Normal Form:

Each column must depend on the entire primary key.

Third Normal Form:

Each column must depend on directly on the primary key.