Outline Homework 6 Hints & Tips

advertisement
Class 09.02
Homework 6 Hints & Tips
PART 1: TAL Data Warehouse
SPRING 2016
Outline
•
•
•
•
Homework #6 Requirements
Part 1: TAL DW
Transforming TAL TPS to TAL DW
ETL  OrderDetail
– Extract, Transform, Load
• Expanded Time Dimension: Time2015
• Part 2: CAT DW [Relation Listing]
1
Homework #6 [TEAM PROJECT]
Due: Sec 1 & Sec 2 (Thurs; March 31)
Points: 20 points (plus Bonus 10 points)
Pratt & Last: TAL and CAT Databases
•
•
1.
2.
3.
4.
5.
Use 3-hole punch notebook (1/2” or smaller). Assignments must have cover
sheet, table of contents, index tabs. Put your name on the spine of the notebook.
Use tabs for each section of the PP and HB data warehouses. Use 4 Tabs.
You may use the Star Diagrams from Homework #5 as the basis for this
assignment; or you may start from the TPS databases. All tables MUST be
completely loaded with required data. You must use the TIME table on my
website (for 2008-2015). Print only the Last Page of the TIME table. MUST Use
the Time_Key as the Primary Key and replace the OrderDate as the Foreign
Key in the Fact Table with the appropriate value for the Time_Key.
Turn in copies of the SQL code used to load data into the Star Diagrams
(especially the Fact Table). Also, include a copy of the Index Pane with
appropriate indexes for each all Fact & Dimension Tables.
Turn in printouts of the data in each table (Table View/Datasheet View/Index
Views) in the Data Warehouse. Use portrait or landscape mode as appropriate.
Turn-in printouts of the ACCESS Relationship/Star diagrams (ERDs) for both
databases. BONUS (2 pts @): Turn in ERDPlus version TOO!
Turn in the relation lists for each database as in Homework #5. There may
be some changes. Specify the normality of each table.
(6 BONUS POINTS): ETL new data for the State of Florida (PROVIDED)
TIP: Make a backup copy of the TAL and CAT databases before starting this assignment.
Homework #6 (cont.)
6.
Reports (10 Bonus pts. each Report & Query):
1) TAL Subtotal Orders by Customer (3 Bonus pts).
•
2)
•
3)
8.
Include SQL for Query used for Report
CAT Subtotal Trip Reservations Total Fees by Month ----(4 Bonus pts).
•
7.
Include SQL for Query used for Report
TAL Subtotal Orders by Items (3 Bonus pts).
Include SQL for Query used for Report
Summary of Requirements (TAL & CAT)
– Star Diagram (ERDPlus Diagram 2 pts Bonus)
– ETL SQL code for appropriate NEW tables
– DataSheet Views all tables; and Index Pane Views
– Relation Lists; with appropriate Relation Notation
– Bonus: Append/Merge New FL Data to TAL
– Bonus: Reports with Queries
TURN in Team Evaluation Form for each member.
2
BCIS 4660 - Homework #6
BEGIN: TAL Transactional
Database (TPS)
3
5.A. TAL Star Diagram (Pre-Final)
New: Time
Table
New: Team/
State Table
5.B. TAL DW -- Relation List
Fact Table
• OrderDetail [OrderNum, ItemNum, TimeKey, CustNum,
RepNum, NumOrdered, QuotedPrice, ExtendedPrice]
Dimension Tables (Full)
• Customer [CustNum, CustName, Street, City, State,
PostalCode, Balance, CreditLimit, (RepNum)]
• Rep [RepNum, LastName, FirstName, Street, City, State,
PostalCode, Commission, Rate]
• Item [ItemNum, Desc, OnHand, Category, Storehouse,
Price, (Allocation)]
• Time [TimeKey, OrderDate, Month, Cal_Year, Fiscal_Year,
Quarter, Month_Key, Month_Day, Serial_Num, Week_Num,
Julian, Day_of_Week, Day_of_Week_Num]
• State[TeamID, StateCode, StateName, TerritoryCode]
4
Transformation Stages
(Steps for Homework #5)
1.
2.
3.
4.
5.
6.
7.
De-normalization Process
a. Start with Normalized Tables (TAL TPS)
b. Determine Dimensions and Fact Tables
c. Delete Relationships (optional here; may defer to step 3.
below)
Rebuild Tables (ETL)
Rebuild Relationship Diagram as Star Diagram, a.k.a., Dimension
Table
Build or add additional Dimension tables (Import Time2015, etc.)
a. Join Time2015 to Order_Detail with TimeKey
Final Star Diagram: The TAL Data Warehouse.
Create Views for Reports
Homework #5 provides background information needed to
complete Homework 6, too!
2.a. ETL Tables
• Using copied operations database
• Be sure all ops. data is saved and backed up …
multiple times!!
• Data staging & cleansing
– Denormalize extra relationships: Create Order_Detail
•
•
•
•
Order:OrderLine;
Customer:SalesRep;
Order:OrderNum, PartNum  OrderDetail
Customer:OrderNum CustNum  SalesRep
– Transform data for new tables in Access:
• Make Table Order_Detail
– Import Time2015 Table from website
– Import FL data from PPDW06_Team20.06 data
warehouse
5
2.b. OrderDetail Query
SQL View OrderDetail Query
SELECT Orders.OrderNum, OrderLine.ItemNum,
Orders.OrderDate, Orders.CustomerNum,
Customer.RepNum, OrderLine.NumOrdered,
OrderLine.QuotedPrice, [numordered]*[quotedprice] AS
ExtendedPrice
FROM Rep, Customer, Orders, Orderline, Rep
WHERE
Customer.CustomerNum = Orders.CustomerNum AND
Orders.OrderNum = OrderLine.OrderNum AND
Rep.RepNum = Customer.RepNum;
Datasheet View; Save OrderDetail
QBE Design View
Option: RepNum added in
Orders of Homework #4
2.c. Make Table OrderDetail Table
SELECT Orders.OrderNum, OrderLine.ItemNum, Orders.OrderDate, Orders.CustomerNum,
Customer.RepNum, OrderLine.NumOrdered, OrderLine.QuotedPrice,
[NumOrdered]*[QuotedPrice] AS ExtendedPrice INTO OrderDetail
FROM Rep INNER JOIN ((Customer INNER JOIN Orders ON Customer.CustomerNum =
Orders.CustomerNum) INNER JOIN OrderLine ON Orders.OrderNum =
OrderLine.OrderNum) ON Rep.RepNum = Customer.RepNum;
6
2.d. OrderDetail Table
Set Primary Keys
Create INDEXes
3. Build Star Diagram
Dimension Table
Dimension Table
Fact Table
Dimension Table
Missing Time2015 Table
7
4. Import Time2015 Table
Datasheet View
Time2015 Table
Time2015 Index Pane
View
TAL Datasheet Views (cont.)
Customer Table
Item Table
Rep Table
8
5. TAL Append BONUS
• Think outside the box!
• Append your data warehouse to the
BONUS data warehouse.
– Rationale:
• Guarantees that all data conforms to the
“corporate” standard
• Time, State (Team), and Region tables are
completely populated.
TAL Star Diagram
Optional
9
Extract (Import) Your TAL Data
Import Tables from Your TAL DW into
TALDW06_Team06 database;
OR visa-versa
Note: Tables Added (1)
Append (ELT) Your Customer1
to Standard Customer
Append Table
Note: Column Alignment after Append
10
Append Query: Customer
SQL View
Datasheet View
INSERT INTO Customer ( CustomerNum,
CustomerName, Street, City, State,
PostalCode, Balance, CreditLimit,
RepNum )
SELECT Customer1.CustomerNum,
Customer1.CustomerName,
Customer1.Street, Customer1.City,
Customer1.State, Customer1.PostalCode,
Customer1.Balance,
Customer1.CreditLimit,
Customer1.RepNum
FROM Customer1;
Repeat Append
Rep & Item Tables
Last: OrderDetail
INSERT INTO Rep ( RepNum, LastName,
FirstName, Street, City, State,
PostalCode, Commission, Rate )
SELECT Rep1.RepNum, Rep1.LastName,
Rep1.FirstName, Rep1.Street, Rep1.City,
Rep1.State, Rep1.PostalCode,
Rep1.Commission, Rep1.Rate
FROM Rep1;
INSERT INTO OrderDetail ( OrderNum,
ItemNum, TimeKey, OrderDate,
CustomerNum, RepNum, QuotedPrice,
NumOrdered, ExtendedPrice, TeamID )
SELECT OrderDetail1.OrderNum,
OrderDetail1.ItemNum,
OrderDetail1.TimeKey,
OrderDetail1.OrderDate,
OrderDetail1.CustomerNum,
OrderDetail1.RepNum,
OrderDetail1.QuotedPrice,
OrderDetail1.NumOrdered,
OrderDetail1.ExtendedPrice,
OrderDetail1.TeamID
FROM OrderDetail1;
INSERT INTO Item ( ItemNum,
Description, OnHand, Category,
Storehouse, Price )
SELECT Item1.ItemNum,
Item1.Description, Item1.OnHand,
Item1.Category, Item1.Storehouse,
Item1.Price
FROM Item1;
Add TimeKey and TeamID field
11
5.a. Final Touch: Replacing
OrderDate with Time_key
QBE View
SQL View
UPDATE [Time] INNER
JOIN OrderDetail ON
Time.Date =
OrderDetail.OrderDate
SET OrderDetail.TimeKey =
[Time].[Time_key];
5.B. TAL DW -- Relation List
Fact Table
• OrderDetail [OrderNum, ItemNum, TimeKey, CustNum,
RepNum, NumOrdered, QuotedPrice, ExtendedPrice]
Dimension Tables (Full)
• Customer [CustNum, CustName, Street, City, State,
PostalCode, Balance, CreditLimit, (RepNum)]
• Rep [RepNum, LastName, FirstName, Street, City, State,
PostalCode, Commission, Rate]
• Item [ItemNum, Desc, OnHand, Category, Storehouse,
Price, (Allocation)]
• Time [TimeKey, OrderDate, Month, Cal_Year, Fiscal_Year,
Quarter, Month_Key, Month_Day, Serial_Num, Week_Num,
Julian, Day_of_Week, Day_of_Week_Num]
• State[TeamID, StateCode, StateName, TerritoryCode]
12
TAL BONUS Reports
• Materialize the Object Views (MOV)
– Select Tables
– Create Views (Saved Queries)
– Create Reports
6. Customer SubTotal Query
SQL View
SELECT OrderDetail.CustomerNum,
Count(OrderDetail.RepNum) AS CountOfOrders,
Sum(OrderDetail.ExtendedPrice) AS CustomerSubTotal,
Count(OrderDetail.OrderNum) AS CountOfCustomers
FROM OrderDetail
GROUP BY OrderDetail.CustomerNum;
Datasheet View
CustomerSubtotals
13
Total Customer Sales
SQL View
SELECT
Sum(CustomerSubTotals.C
ustomerSubTotal) AS
CustomerTotal
FROM CustomerSubTotals;
Datasheet View
Creating an Annotated View
SQL View
SELECT CustomerSubTotals.CustomerNum, Customer.CustomerName,
CustomerSubTotals.CountOfOrders, CustomerSubTotals.CountOfCustomers,
CustomerSubTotals.CustomerSubTotal
FROM CustomerSubTotals INNER JOIN Customer ON
CustomerSubTotals.CustomerNum = Customer.CustomerNum
ORDER BY Customer.CustomerName;
Datasheet View
14
Calculating Percentage
SQL View
SELECT CustomerSubtotalAnnotatedQuery.CustomerNum,
CustomerSubtotalAnnotatedQuery.CustomerName,
CustomerSubtotalAnnotatedQuery.CustomerSubTotal,
CustomerTotalSales.CustomerTotal,
[CustomerSubtotalAnnotatedQuery].[CustomerSubTotal]/[CustomerTot
al] AS CustomerPercent
FROM CustomerSubtotalAnnotatedQuery, CustomerTotalSales; Cartesian Product
Datasheet View
MOV
Report Creation
Layout View
Design View
Control Boxes
1. Bound; Connected to a field
2. Unbound; Not connected to a field
3. Calculated; Expression; =Sum()
4. Other specific Types:
1) Text box; 2) Label; 3) Page break; 4) Line;
5) Combo box; 6) Rectangle; 7) Image
15
Report Design View w/Property Sheet
1) Text box; 2) Label; 3) Page break; 4) Line; 5) Combo box; 6) Rectangle; 7) Image
Control Boxes
1. Bound; Connected to a field
2. Unbound; Not connected to a field
3. Calculated; Expression; =Sum()
4. Other specific Types:
1) Text box; 2) Label; 3) Page break;
4) Line; 5) Combo box; 6) Rectangle;
7) Image
Report Sections:
1. Header
2. Page Header
3. Group Header
4. Detail
5. Group Footer
6. Page Footer
7. Footer
6. Sample Customer Report
FL Data ONLY (-.5)
FL & CA Data (Full Bonus Credit)
16
7. CAT DW -- Relation List
Fact Table
• ReservationFacts[ReservationID, TripID, GuideNum,
CustomerNum, TimeKey, NumPersons, TripPrice, OtherFees,
TotalTripPrice, SeasonCode]
Dimension Tables
• Customer[CustomerNum, LastName, FirstName, Address, City, State,
PostalCode, Phone]
• Trips[TripID, TripName, StartLocation, State, Distance, MaxGrpSize,
Type, Season]
• Guides[GuideNum, LastName, FirstName, Address, City, State,
PostalCode, PhoneNum, HireDate]
• Season [SeasonCode, SeasonName]
• Time [TimeKey, TripDate, Month, Cal_Year, Fiscal_Year, Quarter,
Month_Key, Month_Day, Serial_Num, Week_Num, Julian,
Day_of_Week, Day_of_Week_Num]
Summary
• Complete Transformations
• How normal are the resulting tables?
– 1NF, 2NF, 3NF?
• Document ETL procedures (a.k.a,
Transformation maps)
• Prepare for Appending Tables with new
data
• Extract, Transform, Load (ETL) Tables
• ToolCreate Data for Reports: M.O.V. !
17
Download