texas state technical college discover! third normal form - 3nf it’s all about the key, the...

11
Texas State Technical College DISCOVER! Third Normal Form - 3NF Third Normal Form - 3NF It’s all about the key, the whole key, and nothing but the key.

Upload: kristin-campbell

Post on 20-Jan-2018

212 views

Category:

Documents


0 download

DESCRIPTION

Texas State Technical College DISCOVER! In order for a table to be considered 3NF, it must be 2NF and, consequentially, 1NF. In order for a table to be considered 3NF, all fields in the table must have NO Functional dependence upon non-key fieldsFunctional dependence upon non-key fields Transitive relationships to the primary keyTransitive relationships to the primary key Essentially, all fields must be directly related to or dependent upon the primary key. The Technical Definition Third Normal Form (3NF)

TRANSCRIPT

Page 1: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

Third Normal Form - 3NFThird Normal Form - 3NF

It’s all about the key, the whole key, and nothing

but the key.

Page 2: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

Third Normal Form (3NF)

3NF is a sufficient level of normalization for 3NF is a sufficient level of normalization for most databases.most databases.

At this point, the data is sufficiently At this point, the data is sufficiently organized to be useful as information to organized to be useful as information to most organizations or entities.most organizations or entities.

The focus of 3NF is to eliminate The focus of 3NF is to eliminate dependencies among non-key fields.dependencies among non-key fields.

OverviewOverview

Page 3: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

In order for a table to be considered 3NF, it In order for a table to be considered 3NF, it must be 2NF and, consequentially, 1NF.must be 2NF and, consequentially, 1NF.

In order for a table to be considered 3NF, all In order for a table to be considered 3NF, all fields in the table must have fields in the table must have NONO• Functional dependence upon non-key fieldsFunctional dependence upon non-key fields• Transitive relationships to the primary keyTransitive relationships to the primary key

Essentially, all fields must be directly Essentially, all fields must be directly related to or dependent upon the primary related to or dependent upon the primary key.key.

The Technical DefinitionThe Technical DefinitionThird Normal Form

(3NF)

Page 4: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

Functional dependenceFunctional dependence• Field Order_Total is dependent upon fieldsField Order_Total is dependent upon fields

• Order_QuantityOrder_Quantity• Order_Item_PriceOrder_Item_Price

• The functional dependence is defined asThe functional dependence is defined as• Order_Total = Order_Quantity X Order_Item_PriceOrder_Total = Order_Quantity X Order_Item_Price

Transitive dependenceTransitive dependence• Field Ship_Company is directly dependent uponField Ship_Company is directly dependent upon

• Shipment_ID Shipment_ID (primary key)(primary key)• Field Ship_Company_Address is dependent uponField Ship_Company_Address is dependent upon

• Ship_Company Ship_Company to link or relate toto link or relate to

• Shipment_IDShipment_ID

The Layman’s DefinitionThe Layman’s DefinitionThird Normal Form

(3NF)

Page 5: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

Functional dependenceFunctional dependence• Increases data redundancy and reduces independenceIncreases data redundancy and reduces independence• An update to one field requires update to othersAn update to one field requires update to others

Transitive dependenceTransitive dependence• Indicates a field is not describing the object represented Indicates a field is not describing the object represented

by the record or tableby the record or table• Field describes another object and should be in that Field describes another object and should be in that

object’s tableobject’s table

Why Eliminate …Why Eliminate …Third Normal Form

(3NF)

Page 6: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

For Example…For Example…Order

Order_IDpk Quantity Price TotalText Number Currency Currency

19568 4 4.00 16.00

85466 13 2.00 26.00

77788 10 30.00 300.00

ShipmentIDpk Provider Weight $perLB CostText Text Number Currency Currency

65664 FedEx 4.00 16.00 48.00

55555 USPS 2.00 2.00 4.00

87954 USPS 30.00 2.00 60.00

Two examples of functional

dependence.

Third Normal Form (3NF)

Page 7: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

For Example…For Example…Item

IDpk Mfg Address WeightText Text Text Number

19568 Bins 812 Bins Rd. 16.00

85466 B&D 113 Sears St. 26.00

77788 Shallot 888 9th St. 300.00

VehicleIDpk Enginefk MaxHP Make ModelText Text Number Text Text

65664 SVT-V8 340 Ford Cobra

55555 COT-82 115 Mercury Cougar

87954 CMN-99 220 Dodge Ram

Two examples of transitive

dependence.

Third Normal Form (3NF)

Page 8: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

1.1. For each field, identify its dependencies and their type.For each field, identify its dependencies and their type.

2.2. If it is a functional dependency on a non-key field, If it is a functional dependency on a non-key field, simply delete the dependent field.simply delete the dependent field.If there is a functional dependence, the value can be computed If there is a functional dependence, the value can be computed when the information is retrieved from the table.when the information is retrieved from the table.

3.3. If it is transitive dependence, treat it as a partial If it is transitive dependence, treat it as a partial dependence in 2NF.dependence in 2NF.Handle like in 2NF. Either move to the parent table or create a new Handle like in 2NF. Either move to the parent table or create a new table.table.

4.4. Repeat the process until database is 3NF.Repeat the process until database is 3NF.The database is 3NF when all tables in the database are 3NF.The database is 3NF when all tables in the database are 3NF.

Converting to 3NFConverting to 3NFThird Normal Form

(3NF)

Page 9: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

Corrected Example…Corrected Example…Order

Order_IDpk Quantity PriceText Number Currency

19568 4 4.00

85466 13 2.00

77788 10 30.00

ShipmentIDpk Provider Weight $perLBText Text Number Currency

65664 FedEx 4.00 16.00

55555 USPS 2.00 2.00

87954 USPS 30.00 2.00

Functional dependence:The dependent field has been discarded.

FIXED: The tables are now 3NF!

Third Normal Form (3NF)

Page 10: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

Corrected Example…Corrected Example…

ItemIDpk Mfgfk WeightText Text Number

19568 Bins 16.00

85466 B&D 26.00

VehicleIDpk Enginefk Make ModelText Text Text Text

65664 SVT-V8 Ford Cobra

55555 COT-82 Mercury Cougar

87954 CMN-99 Dodge Ram

EngineIDpk MaxHPText Number

SVT-V8 340

COT-82 115

CMN-99 220

ManufacturerIDpk AddressText TextBins 812 Bins Rd.

B&D 113 Sears St.

Transitive dependence:The dependent field moved to own table.

FIXED: The tables are now 3NF!

Third Normal Form (3NF)

Page 11: Texas State Technical College DISCOVER! Third Normal Form - 3NF It’s all about the key, the whole…

Texas State Technical College

DISCOVER!

In Summary…In Summary…

• Third normal form (3NF) is defined asThird normal form (3NF) is defined as• 1NF and 2NF1NF and 2NF• Having no functional dependenciesHaving no functional dependencies• Having no transitive dependenciesHaving no transitive dependencies

• 3NF is a sufficient normalization for most 3NF is a sufficient normalization for most databases.databases.

• 3NF guarantees independence and 3NF guarantees independence and eliminates data redundancy.eliminates data redundancy.

Third Normal Form (3NF)