TAL Data Warehouse - Weebly

Preview:

Citation preview

TAL Data Warehouse

BCISTUTOR.weebly.com

TAL Star Diagram Original

BCISTUTOR.weebly.com

TAL OrderDetail Modify Query

Datasheet View (12 Records) Table View

SQL View

BCISTUTOR.weebly.com

ALTER TABLE OrderDetail ADD COLUMN Time_key Number;

!!! CHANGE FIELD SIZE TO LONG INTEGER !!!

TAL OrderDetail Modify Query Index Pane View SQL View

BCISTUTOR.weebly.com

CREATE INDEX TimeNDX ON OrderDetail (Time_key);

TAL OrderDetail Update

• Need populate the Time_key field in the OrderDetail table with data.

• In the new time table the Time_key field is primary key.

• In the Query, relate the tables by the date fields.

BCISTUTOR.weebly.com

TAL OrderDetail Modify Query

Datasheet View (12 Records updated) QBE View

SQL View

BCISTUTOR.weebly.com

UPDATE [Time2008-2016] INNER JOIN OrderDetail ON [Time2008-2016].Date = OrderDetail.OrderDate SET OrderDetail.Time_key = [Time2008-2016]![Time_key] WHERE (([OrderDetail]![OrderDate]=[Time2008-2016]![Date]));

New TAL TIME Table

BCISTUTOR.weebly.com

TAL OrderDetail Indexes Index Pane View

BCISTUTOR.weebly.com

SQL View

CREATE INDEX PrimaryKey ON OrderDetail (OrderNum, ItemNum); CREATE INDEX ItemNDX ON OrderDetail (ItemNum); CREATE INDEX CustomerNDX ON OrderDetail (CustomerNum); CREATE INDEX RepNDX ON OrderDetail (RepNum); CREATE INDEX DateNDX ON OrderDetail (OrderDate); CREATE INDEX TimeNDX ON OrderDetail (Time_key);

TAL Time Table Indexes Index Pane View

BCISTUTOR.weebly.com

SQL View CREATE INDEX PrimaryKey ON Time2008-2016 (Time_key); CREATE INDEX DayofWeekNDX ON Time2008-2016 (Day_of_Week); CREATE INDEX MonthNDX ON Time2008-2016 (Month); CREATE INDEX Cal_YearNDX ON Time2008-2016 (Cal_Year); CREATE INDEX QuarterNDX ON Time2008-2016 (Quarter); CREATE INDEX Month_keyNDX ON Time2008-2016 (Month_Key); CREATE INDEX SerialNumNDX ON Time2008-2016 (Serial_Num); CREATE INDEX WeekNumNDX ON Time2008-2016 (Week_Num); CREATE INDEX DayNumNDX ON Time2008-2016 (Day_Number); CREATE INDEX DayofWeekNumNDX ON Time2008-2016 (Day_of_Week_Num);

TAL Customer Indexes Index Pane View

BCISTUTOR.weebly.com

SQL View

CREATE INDEX PrimaryKey ON Customer (CustomerNum); CREATE INDEX CustomerNameNDX ON Customer (CustomerName); CREATE INDEX StateNDX ON Customer (State);

TAL Item Indexes Index Pane View

BCISTUTOR.weebly.com

SQL View

CREATE INDEX PrimaryKey ON Item (ItemNum); CREATE INDEX CategoryNDX ON Item (Category); CREATE INDEX StorehouseNDX ON Item (Storehouse);

TAL Rep Indexes Index Pane View

BCISTUTOR.weebly.com

SQL View

CREATE INDEX PrimaryKey ON Rep (RepNum); CREATE INDEX LastNameNDX ON Rep (LastName); CREATE INDEX FirstNameNDX ON Rep (FirstName); CREATE INDEX CityNDX ON Rep (City); CREATE INDEX StateNDX ON Rep (State); CREATE INDEX PostalCodeNDX ON Rep (PostalCode);

TAL Rep Table Index Pane View

BCISTUTOR.weebly.com

Table View

Datasheet View (4 Records)

TAL Item Table Index Pane View

BCISTUTOR.weebly.com

Table View

Datasheet View (15 Records)

TAL Customer Table Index Pane View

BCISTUTOR.weebly.com

Table View

Datasheet View (13 Records)

TAL OrderDetail Table Index Pane View

BCISTUTOR.weebly.com

Table View

Datasheet View (13 Records)

TAL Time Table Index Pane View

BCISTUTOR.weebly.com

Table View

Datasheet View (3288 Records)

New TAL Star Diagram

BCISTUTOR.weebly.com

TAL Star Diagram ERDPlus version

BCISTUTOR.weebly.com

TAL Data Warehouse Relation List

Fact Table 1NF

BCISTUTOR.weebly.com

OrderDetail [OrderNum, ItemNum, OrderDate, CustomerNum, RepNum, NumOrdered, QuotedPrice, ExtendedPrice, Time_key]

Dimension Tables 3NF

• Customer [CustomerNum, CustomerName, Street, City, State, PostalCode, Balance, CreditLimit]

• Rep [RepNum, LastName, FirstName, Street, City, State, PostalCode, Commission, Rate]

• Item [ItemNum, Description, OnHand, Category, Storehouse, Price] • Time2008-2016 [Time_key, Date, Day_of_Week, Month, Cal_Year,

Fiscal_Year, Quarter, Month_Key, Month_Day, Serial_Num, Week_Num, Day_Number, Day_of_Week_Num]

Appending Florida Data

• Customer and Rep tables currently have CA data.

• Copy Customer and Rep tables as Customer CA and Rep CA.

• Import Customer and Rep tables into the data warehouse database using External data.

• Rename the imported tables as Customer FL and Rep FL.

BCISTUTOR.weebly.com

Appending Florida Data

• Compare the two Customer tables and the two Rep tables side by side to view any data that may need to be changed i.e. duplicate CustomerNum and RepNum.

• What would you do if there were duplicates?

– Hint: Change one of the numbers.

BCISTUTOR.weebly.com

Appending Florida Data

• Take note of how many records are in the Customer FL table (43 Records).

BCISTUTOR.weebly.com

TAL Append Customer Table

Datasheet View (55 Records) QBE View

SQL View

BCISTUTOR.weebly.com

INSERT INTO [Customer] ( CustomerNum, CustomerName, Street, City, State, PostalCode, Balance, CreditLimit, RepNum ) SELECT [Customer FL].CustomerNum, [Customer FL].CustomerName, [Customer FL].Street, [Customer FL].City, [Customer FL].State, [Customer FL].PostalCode, [Customer FL].Balance, [Customer FL].CreditLimit, [Customer FL].RepNum FROM [Customer FL];

TAL Append Rep Table

Datasheet View (13 Records) QBE View

SQL View

BCISTUTOR.weebly.com

INSERT INTO Rep ( RepNum, LastName, FirstName, Street, City, State, PostalCode, Commission, Rate ) SELECT [Rep FL].RepNum, [Rep FL].LastName, [Rep FL].FirstName, [Rep FL].Street, [Rep FL].City, [Rep FL].State, [Rep FL].PostalCode, [Rep FL].Commission, [Rep FL].Rate FROM [Rep FL];

TAL Append Item Table

Datasheet View (40 Records) QBE View

SQL View

BCISTUTOR.weebly.com

INSERT INTO Item ( ItemNum, Description, OnHand, Category, Storehouse, Price ) SELECT [Item FL].ItemNum, [Item FL].Description, [Item FL].OnHand, [Item FL].Category, [Item FL].Storehouse, [Item FL].Price FROM [Item FL];

TAL Append OrderDetail Table

Datasheet View (43 Records) QBE View

SQL View

BCISTUTOR.weebly.com

INSERT INTO OrderDetail ( OrderNum, ItemNum, Time_key, OrderDate, CustomerNum, RepNum, NumOrdered, QuotedPrice, ExtendedPrice, TeamID ) SELECT [OrderDetail FL].OrderNum, [OrderDetail FL].ItemNum, [OrderDetail FL].TimeKey, [OrderDetail FL].OrderDate, [OrderDetail FL].CustomerNum, [OrderDetail FL].RepNum, [OrderDetail FL].NumOrdered, [OrderDetail FL].QuotedPrice, [OrderDetail FL].ExtendedPrice, [OrderDetail FL].TeamID FROM [OrderDetail FL];

Create Report

• Customer

• Item

BCISTUTOR.weebly.com

TAL Customer SubTotal Query

Datasheet View QBE View

SQL View

BCISTUTOR.weebly.com

SELECT OrderDetail.CustomerNum, Customer.CustomerName, Count(OrderDetail.RepNum) AS CountofOrders, Sum(OrderDetail.ExtendedPrice) AS CustomerSubTotal, Count(OrderDetail.OrderNum) AS CountofCustomers FROM Customer INNER JOIN OrderDetail ON Customer.CustomerNum = OrderDetail.CustomerNum GROUP BY OrderDetail.CustomerNum, Customer.CustomerName ORDER BY Customer.CustomerName;

TAL Customer Total Sales Query

Datasheet View QBE View

SQL View

BCISTUTOR.weebly.com

SELECT Sum(OrderDetail.ExtendedPrice) AS SumOfExtendedPrice FROM OrderDetail;

TAL Customer Percentage Query

Datasheet View (25 Records) QBE View

SQL View

BCISTUTOR.weebly.com

SELECT CustomerSubTotal.CustomerNum, CustomerSubTotal.CustomerName, CustomerSubTotal.CustomerSubTotal, CustomerTotalSales.SumOfExtendedPrice, [CustomerSubTotal]/[SumOfExtendedPrice] AS CustomerPercent FROM CustomerSubTotal, CustomerTotalSales;

TAL Customer Report with FL data

BCISTUTOR.weebly.com

TAL Item SubTotal Query Datasheet View QBE View

SQL View

BCISTUTOR.weebly.com

SELECT OrderDetail.ItemNum, Item.Description, Count(OrderDetail.RepNum) AS CountofOrders, Sum(OrderDetail.ExtendedPrice) AS ItemSubtotal, Count(OrderDetail.OrderNum) AS CountofItems FROM Item INNER JOIN OrderDetail ON Item.ItemNum = OrderDetail.ItemNum GROUP BY OrderDetail.ItemNum, Item.Description ORDER BY Item.Description;

TAL Item Total Sales Query

Datasheet View QBE View

SQL View

BCISTUTOR.weebly.com

SELECT Sum(OrderDetail.ExtendedPrice) AS SumOfExtendedPrice FROM OrderDetail;

TAL Item Percentage Query

Datasheet View (30 Records) QBE View

SQL View

BCISTUTOR.weebly.com

SELECT ItemSubTotal.ItemNum, ItemSubTotal.Description, ItemSubTotal.ItemSubtotal, ItemTotalSales.SumOfExtendedPrice, [ItemSubTotal]![ItemSubtotal]/[ItemTotalSales]![SumOfExtendedPrice] AS ItemPercentage FROM ItemSubTotal, ItemTotalSales GROUP BY ItemSubTotal.ItemNum, ItemSubTotal.Description, ItemSubTotal.ItemSubtotal, ItemTotalSales.SumOfExtendedPrice, [ItemSubTotal]![ItemSubtotal]/[ItemTotalSales]![SumOfExtendedPrice] ORDER BY ItemSubTotal.Description;

TAL Item Report with FL data

BCISTUTOR.weebly.com