Presentation is loading. Please wait.

Presentation is loading. Please wait.

DBS201: Merging 3NF Tables Lecture 7.

Similar presentations


Presentation on theme: "DBS201: Merging 3NF Tables Lecture 7."— Presentation transcript:

1 DBS201: Merging 3NF Tables Lecture 7

2 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

3 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 AX12 Iron BT04 GasGrill BZ66 Washer CB03 Bike ,119.96 CX11 Blender AZ52 Dartboard BA74 Basketball BT04 GasGrill CZ81 Treadmill

4 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 AX12 Iron BT04 GasGrill BZ66 Washer CB03 Bike ,119.96 CX11 Blender AZ52 Dartboard BA74 Basketball BT04 GasGrill CZ81 Treadmill 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)

5 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 Adams AX12 Iron Charles BT04 GasGrill BZ66 Washer Daniels CB03 Bike Samuels CX11 Blender Nelson AZ52 Dartboard BA74 Basketbal Adams BT04 GasGrill Nelson CZ81 Treadmill

6 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 Adams AX12 Iron Charles BT04 GasGrill BZ66 Washer Daniels CB03 Bike Samuels CX11 Blender Nelson AZ52 Dartboard BA74 Basketbal Adams BT04 GasGrill Nelson CZ81 Treadmill 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)

7 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

8 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

9 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)

10 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)

11 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


Download ppt "DBS201: Merging 3NF Tables Lecture 7."

Similar presentations


Ads by Google