18
Normal Forms (Part 1) Steven Le ~ CS157B

Normal Forms (Part 1)

  • Upload
    vahe

  • View
    37

  • Download
    0

Embed Size (px)

DESCRIPTION

Normal Forms (Part 1). Steven Le ~ CS157B. Normalization is a systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain undesirable characteristics—insertion, update, and deletion anomalies—that could lead to a loss of data integrity. - PowerPoint PPT Presentation

Citation preview

Page 1: Normal Forms (Part 1)

Normal Forms (Part 1)

Steven Le ~ CS157B

Page 2: Normal Forms (Part 1)

• Normalization is a systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain undesirable characteristics—insertion, update, and deletion anomalies—that could lead to a loss of data integrity.

Page 3: Normal Forms (Part 1)

In English:

• Normalization is a well-defined way to structurea database so that weird things don’t happen to yourdata when you use it

Page 4: Normal Forms (Part 1)

Normal Forms

• Edgar Codd, the inventor of the relational model, also introduced the concept of Normalization and Normal Forms (NF)

• Normal Forms are criteria for determining a table's degree of vulnerability to logical inconsistencies and anomalies

Page 5: Normal Forms (Part 1)

Edgar Codd

• Created First Normal Form (1NF) in 1970

• Created Second Normal Form (2NF) and Third Normal Form (3NF) in 1971

• With Raymond Boyce, created Boyce-Codd Normal Form (BCNF) in 1974

Page 6: Normal Forms (Part 1)

• There also exists other Normal Forms invented by other people. These include 4NF, 5NF, and 6NF

• We will be looking at 1NF, 2NF, and 3NF

Page 7: Normal Forms (Part 1)

Normal Form Properties

• The higher the Normal Form a table has, the less vulnerable to inconsistencies and anomalies it is

• A table always meets the requirements of its Highest Normal Form (HNF), as well as all the requirements of all lower Normal Forms

• A table does not meet the requirements of Normal Forms higher than its HNF

Page 8: Normal Forms (Part 1)

• Achieving a NormalForm is NOT step-wisei.e. 1NF -> 2NF -> 3NF

• Rather, you design the table to be around 3NF on the first try. This is usually the minimum for a table to be considered “Normalized”. Once there, it should be easier to achieve higher Normal Forms

Page 9: Normal Forms (Part 1)

Vocab Overview

• Superkey• Candidate Key• Primary Key• Prime Attribute• Dependency

Page 10: Normal Forms (Part 1)

Superkey

• a set of attributes of a relation variable for which it holds that in all relations assigned to that variable there are no two distinct tuples (rows) that have the same values for the attributes in this set

Page 11: Normal Forms (Part 1)

Candidate/Primary Key

• Candidate Key: Superkey with no proper subsets that are also superkeys

• Primary Key: Candidate Key with no NULL values

• Prime Attribute: Attribute part of the Candidate Key

Page 12: Normal Forms (Part 1)

Dependency

• X → A: The attribute set “X” determines set “A”

• Trivial Functional Dependency: X → Y is called trivial if Y is a subset of X

Page 13: Normal Forms (Part 1)

First Normal Form

• A table is said to be in First Normal Form if it faithfully represents a relation

• No repeating groups

last Name First Name Nickname

Codd Edward E-Money

Davis Baron Boom Dizzle

Davis Baron BD

Page 14: Normal Forms (Part 1)

Second Normal Form

• A table is 2NF if given any candidate key and any attribute that is not a constituent of a candidate key, the non-key attribute depends upon the whole of the candidate key rather than just a part of it

Page 15: Normal Forms (Part 1)

Person (Not 2NF) Pet Veterinarian

John Cat Dr. Howard

John Dog Dr. Howard

Paul Bird Dr. Dre

Andy Cat Dr. Dre

Person (2NF) Pet

John Cat

John Dog

Paul Bird

Andy Cat

Person (2NF) Veterinarian

John Dr. Howard

Paul Dr. Dre

Andy Dr. Dre

Page 16: Normal Forms (Part 1)

Third Normal Form

• A table is in 3NF if for each of its functional dependencies X → A, at least one of the following conditions holds:

• X contains A (that is, X → A is trivial functional dependency), or

• X is a superkey, or• A is a prime attribute (i.e., A is contained

within a candidate key)

Page 17: Normal Forms (Part 1)

Tournament (2NF) Year Winner Winner DOB

Peruvian Open 1989 Tom 10/28/75

Westgate Masters 1993 Kurt 6/9/69

Bolivian Open 1986 Tom 10/28/75

Peruvian Open 1993 Blaire 5/7/90

Tournament (3NF) Year Winner

Peruvian Open 1989 Tom

Westgate Masters 1993 Kurt

Bolivian Open 1986 Tom

Peruvian Open 1993 Blaire

Player (3NF) Winner DOB

Tom 10/28/75

Kurt 6/9/69

Blaire 5/7/90

Page 18: Normal Forms (Part 1)

End

• Applause