Docsity

Dimensional Queries in Data Warehousing and Data Mining, Lecture notes of Data Warehousing

Partial preview of the text

Download Dimensional Queries in Data Warehousing and Data Mining and more Lecture notes Data Warehousing in PDF only on Docsity!

Lab Outlines

 Introduction to Dimensional Queries  Query Types  Applying Dimensional Queries to different QueryTypes DB 430 – Data Warehousing and Data Mining

Dimensional Queries

 It joins the fact table and the dimension tables onone or more surrogate keys. DB 430 – Data Warehousing and Data Mining

Aggregate Query

 It aggregates/summaries Individual Facts  Example^  The aggregation of the order amounts and number oforders by date DB 430 – Data Warehousing and Data Mining

Specific Query

 It selects and aggregates the Facts on a specificDimension Value.  Example^  Taking aggregates of sales amounts and the number oforders every month. DB 430 – Data Warehousing and Data Mining

Preliminaries for dimensional Queries

 In step one we will prepare our data warehouse fordimensional queries, for this purpose we will insertdata in empty tables.  In step two we will apply dimensional queries to allquery types. DB 430 – Data Warehousing and Data Mining

Data insertion  USE dw;  INSERT INTO order_dimVALUES(NULL, 1, CURRENT_DATE, '9999-12-31') , (NULL, 2,CURRENT_DATE, '9999-12-31') , (NULL, 3, CURRENT_DATE, '9999-12-31') , (NULL, 4, CURRENT_DATE, '9999-12-31') , (NULL, 5,CURRENT_DATE, '9999-12-31') , (NULL, 6, CURRENT_DATE, '9999-12-31') , (NULL, 7, CURRENT_DATE, '9999-12-31') , (NULL, 8,CURRENT_DATE, '9999-12-31') , (NULL, 9, CURRENT_DATE, '9999-12-31') , (NULL, 10, CURRENT_DATE, '9999-12-31') ,(NULL, 11,CURRENT_DATE, '9999-12-31') , (NULL, 12,CURRENT_DATE, '9999-12-31') , (NULL, 13, CURRENT_DATE, '9999-12-31') , (NULL, 14,CURRENT_DATE, '9999-12-31') , (NULL, 15 , CURRENT_DATE,'9999-12-31') , (NULL, 16, CURRENT_DATE, '9999-12-31') ; DB 430 – Data Warehousing and Data Mining

Data insertion (2)

INSERT INTO sales_order_factVALUES

DB 430 – Data Warehousing and Data Mining

Daily Sales Aggregation

SELECT date , SUM (order_amount) , COUNT(*)FROM sales_order_fact a , date_dim b WHERE a.order_date_sk = b.date_sk GROUP BY date ORDER BY date ;  The query result shows the daily total order amounts (sum) and thenumber of orders (count) of all orders. DB 430 – Data Warehousing and Data Mining

Inside-Out Queries

SELECT month_name , year , product_name , SUM (order_amount) , COUNT(*)FROM sales_order_fact a ,product_dim b , date_dim c WHERE a.product_sk = b.product_sk ANDa.order_date_sk = c.date_sk GROUP BY month_name , year , product_name HAVING SUM (order_amount) >= 75000 ORDER BY month , year ,product_name ;  The query output shows the total order amounts (sum) and the number of orders(count) for LCD Panel, the only product that has a total order amount that is equal toor greater than 75000. DB 430 – Data Warehousing and Data Mining

Assignment

DB 430 – Data Warehousing and Data Mining  Determine the order amounts and the number of ordersaggregated by date, product and by customer city?  Determine the quarterly aggregation of the orderamounts in Mechanicsburg?  which customer’s placed more than five orders annuallyin the past eighteen months?