DBS201: Merging 3NF Tables Lecture 7
Merging 3NF Tables Bottom up design on a number of similar views (reports/screens) generates a series of tables in 3NF Resulting tables are similar
Premiere Corporation Order Detail Report Merging 3NF Relations View 1 Premiere Corporation Order Detail Report Order Order Cust Part Part Number Quoted Total Number Date Number Number Desc Ordered Price 12489 2001-09-02 124 AX12 Iron 11 14.95 164.45 12491 2001-09-02 311 BT04 GasGrill 1 149.99 149.99 BZ66 Washer 1 399.99 399.99 12494 2001-09-04 315 CB03 Bike 4 279.99 1,119.96 12495 2001-09-04 256 CX11 Blender 2 22.95 45.90 12498 2001-09-05 522 AZ52 Dartboard 2 12.95 25.90 BA74 Basketball 4 24.95 99.80 12500 2001-09-05 124 BT04 GasGrill 1 149.99 149.99 12504 2001-09-05 522 CZ81 Treadmill 2 325.99 651.98
Premiere Corporation Order Detail Report Merging 3NF Relations Given this view sample, working through normalization could give the following 3NF tables Premiere Corporation Order Detail Report Order Order Cust Part Part Number Quoted Total Number Date Number Number Desc Ordered Price 12489 2001-09-02 124 AX12 Iron 11 14.95 164.45 12491 2001-09-02 311 BT04 GasGrill 1 149.99 149.99 BZ66 Washer 1 399.99 399.99 12494 2001-09-04 315 CB03 Bike 4 279.99 1,119.96 12495 2001-09-04 256 CX11 Blender 2 22.95 45.90 12498 2001-09-05 522 AZ52 Dartboard 2 12.95 25.90 BA74 Basketball 4 24.95 99.80 12500 2001-09-05 124 BT04 GasGrill 1 149.99 149.99 12504 2001-09-05 522 CZ81 Treadmill 2 325.99 651.98 ORDER (ORDER_NUM(PK), ORDER_DATE, CUSTOMER_NUM) PART (PART_NUM(PK), PART_DESC, QUOTED_PRICE) ORDER_PART(ORDER_NUM(PK,FK), PART_NUM(PK,FK), NUM_ORDERED)
Merging 3NF Relations View 2 Premiere Corporation Order Detail Report Order Order Cust Last Part Part Qty List Number Date Number Name Number Desc Ordered Price 12489 2001-09-02 124 Adams AX12 Iron 11 14.95 12491 2001-09-02 311 Charles BT04 GasGrill 3 149.99 BZ66 Washer 1 399.99 12494 2001-09-04 315 Daniels CB03 Bike 4 279.99 12495 2001-09-04 256 Samuels CX11 Blender 2 22.95 12498 2001-09-05 522 Nelson AZ52 Dartboard 2 12.95 BA74 Basketbal 4 24.95 12500 2001-09-05 124 Adams BT04 GasGrill 1 149.99 12504 2001-09-05 522 Nelson CZ81 Treadmill 2 325.99
Merging 3NF Relations Given this view sample, working through normalization could give the following 3NF tables Premiere Corporation Order Detail Report Order Order Cust Last Part Part Qty List Number Date Number Name Number Desc Ordered Price 12489 2001-09-02 124 Adams AX12 Iron 11 14.95 12491 2001-09-02 311 Charles BT04 GasGrill 3 149.99 BZ66 Washer 1 399.99 12494 2001-09-04 315 Daniels CB03 Bike 4 279.99 12495 2001-09-04 256 Samuels CX11 Blender 2 22.95 12498 2001-09-05 522 Nelson AZ52 Dartboard 2 12.95 BA74 Basketbal 4 24.95 12500 2001-09-05 124 Adams BT04 GasGrill 1 149.99 12504 2001-09-05 522 Nelson CZ81 Treadmill 2 325.99 ORDER (ORDER_NUM(PK), ORDER_DATE, CUSTOMER_NUM(FK)) CUSTOMER (CUST_NUM(PK, LAST_NAME) PART (PART_NUM(PK), PART_DESC, LIST_PRICE) ORDER_PART(ORDER_NUM(PK,FK), PART_NUM(PK,FK), QTY_ORDERED)
Merging 3NF Relations Resulting 3NF tables from both examples: View 1: ORDER (ORDER_NUM(PK), ORDER_DATE, CUST_NUM) PART (PART_NUM(PK), PART_DESC, QUOTED_PRICE) ORDER_PART(ORDER_NUM(PK,FK), PART_NUM(PK,FK), NUM_ORDERED) Notice most attributes are similarly named Two table ‘PART’, each with a different attribute QUOTED_PRICE and LIST_PRICE. Assuming they represent the same attribute, need to give them a consistent name ORDER (ORDER_NUM(PK), ORDER_DATE, CUST_NUM(FK)) CUSTOMER (CUST_NUM(PK, LAST_NAME) PART (PART_NUM(PK), PART_DESC, LIST_PRICE) ORDER_PART(ORDER_NUM(PK,FK), PART_NUM(PK,FK), QTY_ORDERED) Notice same with QTY_ORDERED and NUM_ORDERED in the ORDER_PART tables
Merging 3NF Relations Resulting Merged set of 3NF tables from both examples: ORDER (ORDER_NUM(PK), ORDER_DATE, CUST_NUM(FK)) PART (PART_NUM(PK), PART_DESC, LIST_PRICE) ORDER_PART(ORDER_NUM(PK,FK), PART_NUM(PK,FK), QTY_ORDERED) CUSTOMER (CUST_NUM(PK, LAST_NAME) Note new name in PART table: LIST_PRICE and new name in ORDER_PART table; QTY_ORDERED
Merging 3NF Relations Another Example - Two tables: Step 1: Merge tables: (Note this table is no longer in 3NF) CUSTOMER (CUST_NUM(PK), CUST_NAME, REP_NUM) CUSTOMER (CUST_NUM(PK), CUST_NAME, REP_LAST_NAME, REP_FIRST_NAME) CUSTOMER (CUST_NUM(PK), CUST_NAME, REP_LAST_NAME, REP_FIRST_NAME, REP_NUM)
Merging 3NF Relations Normalized tables: Normalize the tables: CUSTOMER (CUST_NUM(PK), CUST_NAME, REP_NUM, REP_FIRST_NAME, REP_LAST_NAME) CUSTOMER (CUST_NUM(PK), CUST_NAME, REP_NUM (FK)) REP (REP_NUM(PK), REP_FIRST_NAME, REP_LAST_NAME)
Steps to Merge 3NF Relations Review attribute names of 3NF relations from each user view and make them consistent across all relations Use consistent name for relations with same attributes in primary key (i.e. CUSTOMER table and CLIENT table; both with a primary key of CUST_NUM should have the same relation name) Examine the primary key of each relation with a composite primary key to determine if all parts should be part of the primary key (partial dependencies) Resolve any transitive dependencies if they were created in the previous step Revise ERD as required with one entity for each relation and a relationship for each foreign key Revisit ERD relationships to determine what is option vs mandatory