Presentation is loading. Please wait.

Presentation is loading. Please wait.

4/30/2015 Database Design:Normalization. 4/30/2015 Functional Dependence An attribute (column) B, is functionally dependent on another attribute A if.

Similar presentations


Presentation on theme: "4/30/2015 Database Design:Normalization. 4/30/2015 Functional Dependence An attribute (column) B, is functionally dependent on another attribute A if."— Presentation transcript:

1 4/30/2015 Database Design:Normalization

2 4/30/2015 Functional Dependence An attribute (column) B, is functionally dependent on another attribute A if a value for A determines a single value for B at any one time. A -----> B

3 4/30/2015 Primary Key Attribute A (or a collection of attributes) is the primary key for a relation (table), R, if 1. All attributes in R are functionally dependent on A. 2. No subcollection of attributes in A also has a property 1.

4 4/30/2015 Primary Key Candidate key: Collection of attributes that has the same properties as in the definition of primary key. Alternate keys: Candidate keys that are not chosen to be the primary key.

5 4/30/2015 First Normal Form Unnormalized relation: A relation (table) that contains a repeating group 1NF: Relations without repeating groups

6 4/30/2015 Relations Unnormalized ORDERS(ORDER_NUMBER, ORDER_DATE, (PART_NUMBER, NUMBER_ORDERED)) 1NF ORDERS(ORDER_NUMBER, ORDER_DATE, PART_NUMBER, NUMBER_ORDERED)

7 4/30/2015 Unnormalized Table Customer (Order Number) Order Number Order Date Part Number Ordered /02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ

8 4/30/2015 Result of Normalization (1NF) Customer (Order Number, Part Number) Order Number Order Date Part Number Ordered /02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ

9 4/30/2015 Conversion to 1NF No repeating group Primary key will expand in converting a non-1NF table to 1NF

10 4/30/2015 Second Normal form ORDERS(ORDER_NUMBER, ORDER_DATE, PART_NUMBER, PART_DESRIPTION, NUMBER_ORDERED, Quoted_PRICE) Functional dependencies ORDER_NUMBER ORDER_DATE PART_NUMBER PART_DESRIPTION ORDER_NUMBER, PART_NUMBER NUMBER_ORDERED, Quoted_PRICE

11 4/30/2015 Sample Orders table Orders Order Number Order Date Part Number Ordered /02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ Part Description Iron Gas Grill Washer Bike Blender Dartboard Basketball Gas Grill Treadmill Quoted price $21.95 $ $ $ $22.95 $12.95 $24.95 $ $325.99

12 4/30/2015 Update Anomalies Update: A single change may need to be updated in several rows Inconsistent data: Values that are intended to be the same may appear differently in different rows

13 4/30/2015 Update Anomalies Additions: Values may be missing, forcing users to add dummy data as a placeholder until real data is available Deletions: Deleting one row may delete information in the row unintentionally

14 4/30/2015 Dependencies in Order table Order Number Order Date Part Number Part Description Number ordered Quoted Price Nonkey attributes depend on only a portion of the primary key

15 4/30/2015 2NF conversion Convert into 3 Tables (ORDER NUMBER, ORDER_DATE) (PART_NUMBER, PART_DESCRIPTION) (ORDER_NUMBER, PART_NUMBER, NUMBER_ORDERED, QUOTED_PRICE)

16 4/30/2015 Sample Orders table Orders (Order Number, Part Number) Order Number Order Date Part Number Ordered /02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ Part Description Iron Gas Grill Washer Bike Blender Dartboard Basketball Gas Grill Treadmill Quoted price $21.95 $ $ $ $22.95 $12.95 $24.95 $ $325.99

17 4/30/2015 Conversion to 2NF /02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 CZ Iron Gas Grill Washer Bike Blender Dartboard Basketball Treadmill $21.95 $ $ $ $22.95 $12.95 $24.95 $ $ Order Number Order Date Orders Part Number Part Description Part Order Number Part Number Ordered Quoted Price AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ81 Order line

18 4/30/2015 2NF is in 1NF No nonkey attribute is dependent on only a portion of the primary key. Elimination of Update anomalies Easy Update No inconsistent data Additions- No need for dummy data Deletions- No fact is lost

19 4/30/2015 Third Normal Form Any attribute or collection of attributes that determine another attribute is called a determinant. A relation (table) is in 3NF if it is second NF and if the only determinant it contains are candidate keys.

20 4/30/2015 Sample Customer table Customer Number Customer Last Customer First Balance Credit Limit Slsrep Number Slsrep Last Slsrep First Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $ $21.50 $ $ $ $ $98.75 $ $ $ $1000 $1500 $1000 $750 $1500 $2000 $1500 $750 $ Jones Smith Diaz Smith Diaz Jones Diaz Smith Jones Mary William Miquel William Miguel Mary Miguel William Mary Customer ( Customer Number )

21 4/30/2015 Dependencies in Customer table Customer Number CUST Name Cust First Balance SLSREP LAST SLSREP FIRST Credit Limit SLSREP Number

22 4/30/2015 Update Anomalies Update Inconsistent data Additions Deletions

23 4/30/2015 Conversion to 3NF Convet into 2 Tables CUSTOMER(CUSTOMER_NUMBER, CUST_LAST, CUST_FIRST, BALANCE, CREDIT_LIMIT, SLSREP_NUMBER) SALES_REP(SLSREP_NUMBER, SLSREP_LAST, SLSREP_FIRST)

24 4/30/2015 Conversion to 3NF Customer Number Customer Last Customer First Balance Credit Limit Slsrep Number Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $ $21.50 $ $ $ $ $98.75 $ $ $ $1000 $1500 $1000 $750 $1500 $2000 $1500 $750 $ Mary William Miquel Customer Slsrep Number Slsrep Last Slsrep First Jones Smith Diaz Sales Rep

25 4/30/2015 Normal Forms 1 NF: No repeating groups 2 NF: 1 NF and no nonkey attribute depedent on only a portion of the primary key. Automatically 2NF if the primary key contains only a single attribute 3NF: 2NF and the only determinants are candidate keys. Boyce-Codd normal form (BCNF)

26 4/30/2015 Incorrect decomposition Customer Number Customer Last Customer First Balance Credit Limit Slsrep Number Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $ $21.50 $ $ $ $ $98.75 $ $ $ $1000 $1500 $1000 $750 $1500 $2000 $1500 $750 $ Customer Number Slsrep Last Slsrep First Sales Rep Jones Smith Diaz Smith Diaz Jones Diaz Smith Jones Mary William Miquel William Miguel Mary Miguel William Mary

27 4/30/2015 Another Decomposition Customer Number Customer Last Customer First Balance Credit Limit Slsrep Last Slsrep First Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $ $21.50 $ $ $ $ $98.75 $ $ $ $1000 $1500 $1000 $750 $1500 $2000 $1500 $750 $1000 Jones Smith Diaz Smith Diaz Jones Diaz Smith Jones Mary William Miquel William Miguel Mary Miguel William Mary Customer Mary William Miquel Slsrep Number Slsrep Last Slsrep First Jones Smith Diaz Sales Rep

28 4/30/2015 Questions and Comments


Download ppt "4/30/2015 Database Design:Normalization. 4/30/2015 Functional Dependence An attribute (column) B, is functionally dependent on another attribute A if."

Similar presentations


Ads by Google