Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 5 Part II
Southern Methodist University CSE Overview Functional Dependencies Primary Keys (and others) Normal Forms Problems with un-normalized forms Normalization in the design process
Southern Methodist University CSE NF Review Eliminate repeating groups
Southern Methodist University CSE NF – More Un-normalized to 1NF –Primary key will usually include the original primary key concatenated with the key to the repeating group –The key to the repeating group is the column that distinguished one occurrence of the repeating group from another on a given row.
Southern Methodist University CSE Problems with 1NF Still an issue with Redundancy Problems with update anomalies –Updates –Inconsistent Data –Additions –Deletions
Southern Methodist University CSE Problems with 1NF Update –Information in multiple rows and therefore difficult to update Inconsistency –Because of redundancy, a row that isn’t updated causes inconsistent data Additions –Dummy records are required to add new and unused dependent rows Deletions –May loose information that is still needed
Southern Methodist University CSE NF Problems with 1NF happen (mostly) because a column is dependent on only a portion of the primary key and not the complete primary key for the table Requirements for Second Normal Form –In 1NF –No non-key column is dependent on only a portion of the primary key
Southern Methodist University CSE Dependency Diagram Use arrows to indicate functional dependencies Partial Dependency – dependent on only a portion of the primary key OrderNumOrderDatePartNumDescriptionNumOrderedQuotePrice
Southern Methodist University CSE NF Another definition –In 1NF –No partial dependencies Resolution????? –Take each subset of the columns that make up the PK –Make new table with this subset as the primary key
Southern Methodist University CSE NF for Orders Table (OrderNum, (PartNum, (OrderNum, PartNum (OrderNum, OrderDate) (PartNum, Description) (OrderNum, PartNum, NumOrdered, QuotedPrice)
Southern Methodist University CSE Problems with 2NF Data redundancy
Southern Methodist University CSE Problems with 2NF Consider the table –Customer (customerNum, customerName, balance, creditLimit, repNum, lastName, firstName) Functional Dependencies: –CustomerNum → CustomerName, Balance,CreditLimit, RepNum, LastName, FirstName –RepNum → lastName, FirstName
Southern Methodist University CSE NF and Determinants Determinant – Any column (or collection thereof) that determines another column Third Normal Form (3NF) –2NF –Only determinants in the table are part of they PK
Southern Methodist University CSE NF for Customer Table To resolve redundancy –For each determinant that is not a candidate key, remove columns that are dependent on this column (but not the determinant column itself) –Put all columns (including determinant) in a new table –Make the determinant the primary key for the new table
Southern Methodist University CSE NF For Customer Table
Southern Methodist University CSE NF Technically, our 3NF is really Boyce- Codd Normal Form (BCNF). Codd was the father of RDBMS theory