Download presentation
Presentation is loading. Please wait.
Published byKaylynn Dobbe Modified over 9 years ago
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 12489 12491 12494 12495 12498 12500 12504 9/02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ81 11 1 4 2 4 1 2
8
4/30/2015 Result of Normalization (1NF) Customer (Order Number, Part Number) Order Number Order Date Part Number Ordered 12489 12491 12494 12495 12498 12500 12504 9/02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ81 11 1 4 2 4 1 2
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 12489 12491 12494 12495 12498 12500 12504 9/02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ81 11 1 4 2 4 1 2 Part Description Iron Gas Grill Washer Bike Blender Dartboard Basketball Gas Grill Treadmill Quoted price $21.95 $149.99 $399.99 $279.99 $22.95 $12.95 $24.95 $149.99 $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 12489 12491 12494 12495 12498 12500 12504 9/02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 BT04 CZ81 11 1 4 2 4 1 2 Part Description Iron Gas Grill Washer Bike Blender Dartboard Basketball Gas Grill Treadmill Quoted price $21.95 $149.99 $399.99 $279.99 $22.95 $12.95 $24.95 $149.99 $325.99
17
4/30/2015 Conversion to 2NF 12489 12491 12494 12495 12498 12500 12504 9/02/98 9/04/98 9/05/98 AX12 BT04 BZ66 CB03 CX11 AZ52 BA74 CZ81 11 1 4 2 4 1 2 Iron Gas Grill Washer Bike Blender Dartboard Basketball Treadmill $21.95 $149.99 $399.99 $279.99 $22.95 $12.95 $24.95 $149.99 $325.99 Order Number Order Date Orders Part Number Part Description Part Order Number Part Number Ordered Quoted Price 12489 12491 12494 12495 12498 12500 12504 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 124 256 311 315 405 412 522 567 587 622 Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $818.75 $21.50 $825.75 $770.75 $402.75 $1817.50 $98.75 $402.40 $114.60 $1045.75 $1000 $1500 $1000 $750 $1500 $2000 $1500 $750 $1000 03 06 12 06 12 03 12 06 03 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 124 256 311 315 405 412 522 567 587 622 Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $818.75 $21.50 $825.75 $770.75 $402.75 $1817.50 $98.75 $402.40 $114.60 $1045.75 $1000 $1500 $1000 $750 $1500 $2000 $1500 $750 $1000 03 06 12 06 12 03 12 06 03 Mary William Miquel Customer Slsrep Number Slsrep Last Slsrep First 03 06 12 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 124 256 311 315 405 412 522 567 587 622 Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $818.75 $21.50 $825.75 $770.75 $402.75 $1817.50 $98.75 $402.40 $114.60 $1045.75 $1000 $1500 $1000 $750 $1500 $2000 $1500 $750 $1000 03 06 12 06 12 03 12 06 03 Customer Number Slsrep Last Slsrep First 124 256 311 315 405 412 522 567 587 622 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 124 256 311 315 405 412 522 567 587 622 Adams Samuels Charles Daniels Williams Adams Nelson Dinh Galvez Martin Sally Ann Don Tom Al Sally Mary Tran Mara Dan $818.75 $21.50 $825.75 $770.75 $402.75 $1817.50 $98.75 $402.40 $114.60 $1045.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 03 06 12 Jones Smith Diaz Sales Rep
28
4/30/2015 Questions and Comments
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.