Presentation is loading. Please wait.

Presentation is loading. Please wait.

Information Resources Management March 13, 2001. Agenda n Administrivia n Normalization n Homework #7 n Mid-Term #2.

Similar presentations


Presentation on theme: "Information Resources Management March 13, 2001. Agenda n Administrivia n Normalization n Homework #7 n Mid-Term #2."— Presentation transcript:

1 Information Resources Management March 13, 2001

2 Agenda n Administrivia n Normalization n Homework #7 n Mid-Term #2

3 Administrivia n Homework #4 n Homework #5 n Homework #6 n Quiz 2 n Mid-Term #1 Keys n Mid-Term Grades

4 Regrade Requests HW 5 & 6 n Create Database n Enter query(s) as submitted n Submit to me n Database (electronic) n Graded homework (paper) n Reserve the right to change test data and reexecute query

5 Normalization n Why & What n 1st Normal Form n 2nd Normal Form n 3rd Normal Form n Boyce-Codd Normal Form n 4th Normal Form

6 Normalization - Why n Eliminate anomalies n Avoid duplication n Increase flexibility and stability n Reduce maintenance

7 Normalization - What?!? n Analysis of functional dependencies between attributes n Building several smaller tables from larger ones n Decomposing relations with anomalies to produce smaller, well-structured relations n Reducing complexity & increasing stability

8 Normalization - What (2) n Series of Steps n Recipe for constructing a “good” physical model of a database from a logical model n Applied to all existing tables, including ones produced by earlier normalization steps

9 Example Sales (Order#, Date, CustID, Name, Address, City, State, Zip, {Product#, ProductDesc, Price, QuantityOrdered}, Subtotal, Tax, S&H, Total) n What are the problems with using a single table for all order information?

10 Problems n Implementing Repeating Groups n Duplication of Data (customer name & address) n Unnecessary Data (subtotal, total, tax) n Others Normalization is a process to eliminate these problems.

11 1st Normal Form n Eliminate Repeating Groups n 1st Normal Form has no repeating groups n Create definition with all other attributes, remove the repeat {}, and change the primary key to include the “key” for the repeating group.

12 Example Sales (Order#, Date, CustID, Name, Address, City, State, Zip, Product#, ProductDesc, Price, QuantityOrdered, Subtotal, Tax, S&H, Total) n Why is this better?

13 1st NF Improvements n Implementation is possible n Querying is possible

14 2nd Normal Form n Remove all partial functional dependencies n 2nd Normal Form has no partial functional dependencies and is in 1st Normal Form n Partial dependencies get their own tables -- original table gets a foreign key

15 Partial Functional Dependencies n An attribute is only dependent on part of the primary key n must be composite key n single attribute key is 2nd NF n Functional dependencies can be specified explicitly but usually come from the E-R model, user specifications, and common sense key  non-key attributes

16 Example - Functional Dependencies Order#  Date, CustID, Name, Address, City, State, Zip, Subtotal, Tax, S&H, Total Order#, Product#  ProductDesc, Price, QuantityOrdered CustID  Name, Address, City, State, Zip Product#  ProductDesc, Price Which are partial functional dependencies?

17 Example Sales (Order#, Date, CustID, Name, Address, City, State, Zip, Subtotal, Tax, S&H, Total) OrderLine (Order#, Product#, ProductDesc, Price, QuantityOrdered) n Is this 2nd NF?

18 Example Sales (Order#, Date, CustID, Name, Address, City, State, Zip, Subtotal, Tax, S&H, Total) OrderLine (Order#, Product#, QuantityOrdered) Product (Product#, ProductDesc, Price) n Is this 2nd NF? Why is this better than 1st NF?

19 2nd NF Improvements n Elimination of Duplicate Data n No Loss

20 3rd Normal Form n Eliminate transitive functional dependencies n 3rd Normal Form has no transitive depencencies and is in 2nd Normal Form n Transitive dependencies get their own tables -- original table gets a foreign key

21 Transitive Functional Dependencies n Attribute is dependent on another, non- key attribute or attributes n Attribute is the result of a calculation CustID  Name, Address, City, State, Zip

22 Example Sales (Order#, Date, CustID, Subtotal, Tax, S&H, Total) OrderLine (Order#, Product#, QuantityOrdered) Product (Product#, ProductDesc, Price) Customer (CustID, Name, Address, City, State, Zip) n Is this 3rd NF? Why is this better than 2nd NF?

23 Example Sales (Order#, Date, CustID) OrderLine (Order#, Product#, QuantityOrdered) Product (Product#, ProductDesc, Price) Customer (CustID, Name, Address, City, State, Zip) n Is this 3rd NF? Why is this better than 2nd NF?

24 3rd NF Improvements n Elimination of Duplicate Data n No Loss n Data is Well-grouped

25 Beyond 3rd Normal Form n Assume we also want to track information about products, builders, and finishes n The following are the functional dependencies: Product, Finish  Builder Product, Finish  Builder Builder  Finish Builder  Finish

26 Beyond 3rd Normal Form ProdFinish (Product#, {Finish, Builder}) becomes ProdFinish (Product#, Finish, Builder) Is this 3rd NF?

27 What’s wrong with 3rd NF? Product, Finish  Builder Builder  Finish

28 What’s Wrong with 3rd NF? What happens when: 1. Vera is replaced by Vern? 2. Vera is rehired to work with Oak? 3. Product #3 in pine is discontinued?

29 What’s Wrong with 3rd NF? n Problems 1. Multiple changes need to be made 2. Can’t assign a builder without a product 3. Lose information that Marv works in Pine

30 Problem & Solution Problem: Builder  Finish Builder  Finish n Builder is not a key Solution: n Boyce-Codd Normal Form

31 Boyce-Codd Normal Form (BCNF) n Every determinant in a relation (LHS of the FD’s) is a candidate key and 3rd NF n Make determinant part of the key and that which is dependent on it an attribute and renormalize

32 Example ProductFinish (Product#, Builder, Finish) Is this BCNF? Hint: Is it 3rd NF?

33 Example ProductFinish (Product#, Builder) Builder (Builder, Finish) Is there anything wrong with this?

34 Example ProductBuilder (Product#, Builder) Builder (Builder, Finish) Normalization often results in the need to rename tables so the table name matches the actual contents.

35 Beyond BCNF n Normalization with separate repeating groups can result in other anomalies CustService (State, {SalesPerson}, {Delivery})

36 Beyond BCNF CustService (State, SalesPerson, Delivery) Is this BCNF?

37 Beyond BCNF n Everything is in the key -- must be BCNF n Still problems with duplication n Multivalued Dependencies

38 Multivalued Dependency n At least three attributes (A, B, C) A  B and A  C A  B and A  C n B and C are independent of each other (they really shouldn’t be in the same table)

39 4th Normal Form n No multivalued dependencies and BCNF n Create separate tables for each separate functional dependency

40 Example SalesForce (State, SalesPerson) Delivery (State, Delivery)

41 Beyond 4th Normal Form n 5th Normal Form n Project-Join Normal Form n Domain Key Normal Form (DKNF)

42 User View1st NF2nd NF3rd NFBCNF4th NF Remove repeating groups Remove partial functional dependencies Remove transitive functional dependencies Remove remaining functional dependency anomalies Remove multivalued dependencies

43 In-Class Exercises n Identify the current normal form n If not 4th NF, transform to 4th NF

44 Homework #7 n Normalization n Database schema from HW #3 n Earlier due date - post key?

45 Mid-Term #2 n Next week, 3/20 n Topics n Converting an E-R Diagram to a physical database schema n Normalizing that schema (3NF) n SQL n Identification of BCNF, 4NF problems


Download ppt "Information Resources Management March 13, 2001. Agenda n Administrivia n Normalization n Homework #7 n Mid-Term #2."

Similar presentations


Ads by Google