__STYLES__
Designing a Dimensional Model for Sales Analysis and SQL
Queries
To design the dimensional model, we must define a Fact Table and multiple Dimension Tables
that together represent the data in a way that’s optimized for analysis
• The Fact Table is where the measurable, quantitative data (facts) will be stored. For
myscenario:
o Fact Table Name: Fact_Sales
o Purpose: To store sales data, including sales amounts for both services and parts.
• Dimension Tables contain descriptive attributes that relate to the facts in the Fact Table.
Here are the dimensions based on mydata:
▪ Other useful time attributes (e.g., Quarter, DayOfWeek)
• Each fact in the Fact_Sales table will be linked to its related dimensions via foreign keys.
• Create Dimension Tables First:
• Create the Fact Table:
• Run some sample queries to ensure that the relationships between the fact and dimension
tables are correctly set up and returning the expected results.
Create a new EER (Enhanced Entity-Relationship) Diagram in MySQL Workbench.
To analyze sales performance by customer, vehicle brand/model/year, and shop location
across Western Canada.
This query will give the total sales (both services and parts) for each customer.
Total Sales by Vehicle Brand/Model/Year
Total Sales by Shop Location
This query will show the total sales for each shop location.
This query provides a more detailed breakdown of sales by customer, further categorized by
vehicle brand, model, and year.
This query allows to analyze sales performance by location, broken down by date (e.g., month,
quarter, or year).
This query separates the sales of services and parts by shop location.
This query identifies the top customers based on their total sales volume
This query shows the sales performance of different vehicle types (brand/model/year) across
various locations.
Logical Decisions
• Fact_Sales table captures the core transactional data (sales) and is linked to
dimension tables that provide additional context (customer, vehicle, job, part,
date).
• The fact table’s granularity is at the level of individual sales transactions. Each
row corresponds to a single sale, which can be a service or a part.
• Dimension tables are designed to be normalized to avoid data redundancy. For
example, customer and vehicle information is stored once in their respective
tables and linked through foreign keys.
• The model supports flexible queries for analysis. By linking facts to dimensions,
we can easily analyze sales by different attributes such as customer, vehicle
make/model/year, job type, and date.
• Using a star schema (fact table in the center surrounded by dimension tables)
ensures efficient querying and reporting. Joins between the fact table and
dimension tables are straightforward and fast.
• The model can be easily extended to include additional dimensions or facts if
needed. New attributes can be added to dimension tables without affecting the
overall structure.
Part B
Using an extended data of the Sales receipt that can be accessed here, answer the following
business questions using SQL.Objectives
• Import the provided CSV files into a relational database.
• Ensure that the data is clean, properly formatted, and indexed for efficient querying.
Create indexes on columns that are frequently used in WHERE clauses or JOIN conditions to
improve query performance.
Customer Analysis
Step 3: Answer Business Questions Using SQL
Determine Average Spending of Customers
Step 4: Analyze Frequency of Customer Visits
Analyze Patterns by Time Period (e.g., Monthly Visits)
• Calculate the average mileage of vehicles serviced.
•
• Identify the most common vehicle makes and models brought in for service.
• Analyze the distribution of vehicle ages and identify any trends in service requirements
based on vehicle age.
• Determine the most common types of jobs performed and their frequency.
• Calculate the total revenue generated from each type of job.
• Identify the jobs with the highest and lowest average costs.
• List the top 5 most frequently used parts and their total usage.
• Calculate the average cost of parts used in repairs.
• Determine the total revenue generated from parts sales.
Optimization Recommendations
• Based on my analysis, provide actionable recommendations to optimize operations, such
as:
Identifying underperforming services that may need improvement or marketing efforts.:
which is balance tires
• Suggesting parts that should be kept in higher stock due to frequent usage.: Cv-Axel is
the most demanded part
• Proposing customer loyalty programs for top-spending customers: Jennifer Robinson .