Anda di halaman 1dari 5

STRUCTURE OF THE DENORMALISED TABLE:

ORDERS ORDER_ID ORDER_DATE CUST_ID CUST_ADDRESS CUST_CITY CUST_STATE ITEM_ID ITEM_DESCRIPTION ITEM_QTY ITEM_PRICE ITEM_TOTAL ORDER_TOTAL

1NF:

1. No repeating elements or groups of elements 2. There must be a primary key to uniquely identify each row of data STRUCTURE OF THE TABLE IN 1NF: ORDERS Primary Key = ORDER_ID, ITEM_ID ORDER_ID(PK) ORDER_DATE CUST_ID CUST_ADDRESS CUST_CITY CUST_STATE ITEM_ID(PK) ITEM_DESCRIPTION ITEM_QTY ITEM_PRICE ITEM_TOTAL ORDER_TOTAL

2NF:

No partial dependencies on a concatenated key. Following is the analysis of the attributes of ORDERS, on how they depend on the 2 parts of the primary key. ATTRIBUTE ORDER_DATE CUST_ID CUST_ADDRESS CUST_CITY CUST_STATE ITEM_DESCRIPT ION ITEM_QTY ITEM_PRICE ITEM_TOTAL ORDER_TOTAL Y N N N N N Y N Y (BUT DERIVED) Y (BUT DERIVED) ORDER_ID N N N N N Y Y Y Y (BUT DERIVED) Y (BUT DERIVED) ITEM_ID

The derived attributes will be discarded from the table as they can be calculated based on ITEM_QTY, ITEM_PRICE, ITEM_TOTAL.

Step 1. We take out the second half of the concatenated primary key (item_id) and put it in its own table. All the columns that depend on item_id - whether in whole or in part - follow it into the new table. We call this new table order_items. Step 2: We also bring a copy of ORDER_ID into the ORDER_ITEMS table, so that each order_item remembers which ORDER_ID it belongs to. ORDERS ORDER_ID(PK) ORDER_DATE CUST_ID 1 CUST_NAME CUST_ADDRESS CUST_CITY CUST_STATE ORDER_ITEMS ORDER_ID(PK) ITEM_ID (PK) ITEM_DESCRIPTION ITEM_QTY ITEM_PRICE

1:N

STEP 3: ORDERS is in 2NF, but ORDER_ITEMS, which has a concatenated key, is not. Following is an analysis of the dependency of the non-prime attributes on the primary key of the table ORDER_ITEMS ATTRIBUTE ITEM_DESCRIPT ION ITEM_QTY ITEM_PRICE N Y N ORDER_ID Y Y Y ITEM_ID

Step 4: We take the fields from ORDER_ITEMS that fail NF2, and create a new table ITEMS. ORDERS ORDER_ID(PK) ORDER_DATE CUST_ID CUST_NAME 1 CUST_ADDRESS CUST_CITY CUST_STATE

ORDER_ITEMS ORDER_ID(FK) ITEM_ID (FK) ITEM_QTY

0:N

ITEMS ITEM_ID (PK) ITEM_DESCRIPTION ITEM_PRICE

3NF: No dependencies on non-key attributes. Hence all customer details in a new table CUSTOMERS.
ORDERS ORDER_ID(PK) CUST_ID (FK) 1 ORDER_DATE 0:N 1 CUSTOMERS CUST_ID (PK) CUST_NAME CUST_ADDRESS CUST_CITY ORDER_ITEMS ORDER_ID(FK) PK ITEM_ID (FK) 0:N ITEM_QTY ITEMS ITEM_ID (PK) ITEM_DESCRIPTION ITEM_PRICE

1:N

DIMENSIONAL MODEL:
Which ones are the dimension tables? CUSTOMERS, ITEMS, TIME. The Time dimension table has been introduced in the dimensional model. Which ones are the fact tables? ORDERS, ORDER_ITEMS integrated into SALES_FACT

CUSTOMERS CUST_ID (PK) CUST_NAME CUST_ADDRESS CUST_CITY CUST_STATE

SALES_FACT ORDER_ID (FK) ITEM_ID (FK) CUST_ID (FK) TIME_ID (FK) ITEM_PRICE ITEM_QTY ITEM_TOTAL ORDER_TOTAL_PRICE

ITEMS ITEM_ID (PK) ITEM_DESCRIPTION ITEM_PRICE

TIME TIME_ID (PK) ORDER_DATE

Anda mungkin juga menyukai