0% found this document useful (0 votes)
28 views38 pages

Session 5 - Data Warehousing and OLAP

X-Mart Supermarket is facing challenges with integrated data for decision-making across its various stores. The document outlines the development of a data warehouse to analyze sales data, including requirements for profit tracking, sales comparisons, and product demand analysis. It details the steps for creating a dimensional model, fact tables, and OLAP queries to facilitate data exploration and insights.

Uploaded by

edgardream
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views38 pages

Session 5 - Data Warehousing and OLAP

X-Mart Supermarket is facing challenges with integrated data for decision-making across its various stores. The document outlines the development of a data warehouse to analyze sales data, including requirements for profit tracking, sales comparisons, and product demand analysis. It details the steps for creating a dimensional model, fact tables, and OLAP queries to facilitate data exploration and insights.

Uploaded by

edgardream
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Activity 1:Developing a Data Warehouse for X-

Mart Supermarket
The Scenario: X-Mart Supermarket
Problem analysis: X-Mart has different malls in the city, where
daily sales take place for various products. Higher management is
facing an issue of non-availability of integrated data in decision-
making. They cannot do study on their data as per their
requirement. So they would like to design a system, which can
help them in decision-making and provide return on investment.
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket

• Identify and collect requirements


• What are the success factors in the business

• How to analyze data

• What are the most important business questions

Real world example requirements:


• Need to see daily, weekly, monthly, quarterly profit of each store.

• Comparison of sales and profit on various time periods.


• Comparison of sales in various time bands of the day.

• Need to know which product has more demand on which location?

• Need to study trend of sales by time period of the day over the week,
month, and year?
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
The Scenario: X-Mart Supermarket
Functional Requirements Analysis, e.g.:
• Need to see daily, monthly, quarterly profit of each store.
• Need to know which product has more demand on which
location?
• On what day sales is higher?
• What is the trend of sales on weekday and weekend?
• Need to compare daily, monthly and yearly sales to know
growth and KPI?
The Phases Of A Data Warehouse Project
• Design the dimensional model
• Dimension
• Provide filtering, grouping and labeling on data; contains textual
descriptions about the subjects of the business.
• e.g. Product, Customer, Store, etc.
• Measure
• Mapped to a column in a fact table
• e.g.Actual Cost, Total Sales, etc.
• Fact Table
• Provides statistics; usually contains historical transactional entries
of live system
• e.g. [Foreign Key Column] Sales Date key, Store ID, Customer ID,
etc.
[Measures] Total Sales, Quantity, etc.
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
The Schema Design
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 1: Create a new Model
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 2: Create the customer dimension table dim_customer
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 3: Add the customer_id Column to the dim_customer table
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 4: Add the rest of the columns to the dim_customer table
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 5: Create Store Dimension table dim_store according to the Schema
 Add the columns of dim_store as follows:

Name Type Comment


store_id DECIMAL(7) Primary UID (unique identifier). (Unique store ID
number)
store_name VARCHAR (100) M (mandatory, that is, must not be null). 100 characters
maximum.
store_location VARCHAR(100) Store’s stree address
city VARCHAR (25) (City or town of where the store is.)
state VARCHAR (25) (State of where the store ises.)
country VARCHAR (25) (Country of where the store is.)
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 5: Create Store Dimension table dim_store according to the Schema
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 6: Create Salesperson Dimension table dim_salesperson
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 7: Assign store_id as the foreign key reference to the dim_store table.
 Select Foreign Keys tab. Enter FK_dim_store as the foreign key name. Select
dim_store as the referenced table. Check the store_id.
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 8: Create Product Dimension table dim_product
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 9: Create fact table to hold all transactional entries fact_productsales
 Add the columns of fact_productsales as follows

Name Type Comment


transaction_id DECIMAL(7) (M) Primary UID (unique identifier). (Unique transaction ID
number)
invoice_number DECIMAL(7) (M) Invoice number that the transaction belongs to

transaction_time TIMESTAMP (M) Date when the transaction occurs


store_id DECIMAL(7) (M) Store when the transaction occurs
customer_id DECIMAL(7) (M) Customer who create the transaction
product_id DECIMAL(7) (M) Product that the transaction is about
salesperson_id DECIMAL(7) (M) Sales person who process the transaction
quantity DECIMAL(7) The number of product the transaction involved
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 9: Create fact table to hold all transactional entries fact_productsales
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 10: Create fact table to hold all transactional entries fact_productsales
 Select the transaction_id column, set transaction_id as auto increment field
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 11: Create foreign keys for fact_productsales
 Set the following foreign key of the fact_productsales table
 FK_dim_store: store_id reference store_id in the dim_store table
 FK_dim_customer: customer_id reference customer_id in the dim_customer table
 FK_dim_product: product_id reference product_id in the dim_product table
 FK_dim_salesperson: salesperson_id reference salesperson_id in the dim_salesperson
table
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 11: Create foreign keys for fact_productsales
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 11: Create foreign keys for fact_productsales
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 12: Generating the DDL File to update the database
 Click Database -> Forward Engineer
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 12: Generating the DDL File to update the database
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 12: Generating the DDL File to update the database
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 12: Generating the DDL File to update the database
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 12: Generating the DDL File to update the database
 Click the Continue to run the DDL to create the tables directly. (You can also copy
or save the DDL to run it later)
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 12: Generating the DDL File to update the database
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 12: Generating the DDL File to update the database
 You may need to right click on the Tables and click refresh if you cannot see the
tables
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
 Step 13 (optional): Generate the Diagram
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
• Step 14: Insert sample data into your datawarehouse
• Download the sampledata.sql file
• Open sampledata.sql in Oracle SQL Developer
• run the SQL Scripts
• explore the data in each table
Activity 1:Developing a Data Warehouse for X-
Mart Supermarket
• Step 14: Insert sample data into your datawarehouse
• Download the sampledata.sql file from the URL:
• <URL>
• Open sampledata.sql in Oracle SQL Developer
• run the SQL Scripts
• explore the data in each table
Activity 2:Performing OLAP Queries
• Step 1: Perform the following full star join and explore the data.
Activity 2:Performing OLAP Queries
• Step 2: [Roll-up] Perform the following query to show total number
of product sales grouping by product
Activity 2:Performing OLAP Queries
• Step 3: [Star join with selections and projections] Perform the
following query to show total sales volume to Male customers in
Ahmedabad city.
Activity 2:Performing OLAP Queries
• Step 4: [Grouping and aggregation over fact table] Perform the
following query to show total number of item sales by store and
customer
Activity 2:Performing OLAP Queries
• Step 5: [Drill-down] Perform the following query to show total
number of item sales by store, product, and customer
Activity 2:Performing OLAP Queries
• Step 6: [Slice] Perform the following query to show the number of item
sales by store, item, and customer for stores in Ahmedabad city only

Look for the store_id in the


dim_stores table to see which
stores are in Ahmedabad city!!!
Activity 2:Performing OLAP Queries
• Step 7: [Dice] Perform the following query to show the total sales by
store, item, and customer for stores in Ahmedabad city and to Male
customers only

Look for the customer_id in the


dim_customer table to see
whether the return customers
are Male!!!

You might also like