Designing a Dimensional Model for Sales Analysis and SQL Queries for a car repair shop.
This report provides a comprehensive analysis on a sample invoice on which two tasks were performed.
A relational database was created based on the contents of the invoice received. Explanations and Entity Relationship Diagram (ERD) can be found in a pdf file on my drive here. The link to the invoice sample can be found here.
The task B is the analysis of a "vehicle repair and part sales" company contained in this google drive link downloaded for analysis in SQL. The datasets in the link had the following headers: customer, vehicle, invoice, job
and parts
.
Some data preparation and manipulation were done on the dataset before importing into SQL, these included the addition of key columns. Here is a breakdown of the data preparation steps:
customer: Needed a
CustomerID
column as the primary key.job: Already had
JobID
as the primary key.VehicleID
andInvoiceID
are present, which can be used as foreign keys.vehicle: Needed a
VehicleID
column as the primary key.OwnerName
needed to be linked to theCustomerID
from the customer table.parts: Needed a
PartID
column as the primary key.JobID
andInvoiceID
were present, which can be used as foreign keys.invoice: Already had
InvoiceID
as the primary key.CustomerID
andVehicleID
are present, which can be used as foreign keys.
A database named "DA-Miles" was created in SQL Server Management Studio (SSMS), furthermore, relational tables were created based on the prepared datasets in readiness for importing. The codes used for the creation of the relational database tables can be found in my github repository here. The datasets containing the same headers and datatypes with the created tables were then imported into the database. The codes used to import the datasets into the database can be found in my github repository here. The codes used for the data cleaning which included changing most of the entries for the invoice table can also be found in my github repository here. Also, the exported "DA-Miles" database can be found in my github repository here.
Some analyses were carried out across various dimensions, including customer, vehicle, job performance, parts usage, and financial analysis. Here is a breakdown of the analyses performed, the codes used for the analysis can be found in my github repository here.
Customer Analysis:
a. Top 5 Customers by Spending:
The top 5 customers who spent the most on vehicle repairs and parts were identified by summing the total amount spent by each customer and sorting the results in descending order.
It can be seen from the chart that Jennifer Robinson had the highest money spent $ 1802.20, the customer with the least money spent is Sarah Johnson, $ 395.50.
b. Average Spending:
The average spending of customers was calculated by determining the mean total amount spent by each customer. The result of the query is shown below.
c. Frequency of Visits:
The frequency of customer visits was analyzed by counting the number of invoices associated with each customer, identifying patterns in customer behavior.
From the analysis and chart, all the customers came once.
Vehicle Analysis:
a. Average Mileage:
The average mileage of vehicles serviced was calculated to understand the typical usage level of vehicles brought in for service. The average mileage as shown in the result snippet below is 33299.
b. Common Makes and Models:
The most common vehicle makes and models were identified by counting the occurrences of each make and model in the dataset.
From the analysis and chart, all vehicles were brought in once as at the time of the analysis and dataset downloaded. the legend shows the model of the vehicles.
c. Vehicle Age Distribution:
The distribution of vehicle ages was analyzed by calculating the age of each vehicle based on the current year and grouping the results to identify trends. The chart below shows vehicle ages of 4, 6, 8, 9, and 12 which all came in only once as at the time of this analysis.
Job Performance Analysis:
a. Common Job Types:
The most common types of jobs performed were identified by counting the occurrences of each job description. The chart below shows that all job types offered were only done once as at the time of this analysis.
b. Revenue by Job Type:
The total revenue generated from each type of job was calculated by summing the amount for each job type. From the chart below, replacement of the front CV axel had the highest revenue $437.50, and replacement of air filters had the lowest $25.00.
c. Jobs with the highest and lowest revenue:
Jobs with the highest and lowest average costs were identified by calculating the mean cost for each job type and sorting the results. A common table expression (CTE) was used to calculate the average costs, and then
UNION ALL
was used to combine the highest and lowest average costs in a single result set. The chart below shows both the job type and their respective revenues.Parts Usage Analysis:
a. Frequently Used Parts:
The top 5 most frequently used parts were identified by counting the usage of each part in repairs. The chart below shows that "wheel weights" and "spark plugs" were the most frequently used parts with a count of 4, others were used once, hence the numbers.
b. Average Part Cost:
The average cost of parts used in repairs was calculated to understand the typical expenditure on parts. From the query result gotten, the average part cost was $148.887.
c. Revenue from Parts Sales:
The total revenue generated from parts sales was calculated by summing the amount for each part. The chart below shows a parts sale of $1584.87.
Financial Analysis:
a. Monthly Revenue:
The total revenue generated from labor and parts for each month was calculated to identify trends and seasonal patterns in revenue. The dataset captured only a month; the sum of the total labor revenue $1915 and the total parts revenue $1584.87 gave the total revenue for the month at $3954.85.
b. Overall Profitability:
Research was done on the average salary of auto mechanics in the area where the company is located (Winnipeg, MB) which is $28.54 as at this analysis. Since the rate was not given in the dataset. The hours of work done was multiplied by this rate and then summed up to give 470.91 which was then added to the sum of the part sales $1584.87. This was added to the Cost of Labour and the result gave $2055.78 which was then subtracted from the Subtotal. The profit for the repair shop is $1444.09.
c. Impact of Sales Tax:
The impact of sales tax on total revenue was analyzed by calculating the total sales tax collected and comparing it to the total revenue.
Optimization Recommendations
Based on the analysis, some actionable recommendations were identified to optimize operations these are:
Improvement of Underperforming Services:
- Identifying services with low revenue or high costs and implementing measures to improve their performance or promote them more effectively. For example, anyone who pays for replacement of front CV Axel can get a free Balance Tyre check. Customers will pay for the service if they find out their Tyres are not properly balanced.
Inventory Management:
- Keeping higher stock of frequently used parts to ensure availability and reduce wait times for repairs. Example of these stocks are spark plugs and wheel weights.
Customer Loyalty Programs:
- Implementing loyalty programs for top-spending customers to encourage repeat business and enhance customer satisfaction. Example of these can be discounts for top spenders, dedicated workers to attend to top spenders in order to reduce their wait time, incentives that are relatively free can be given to them also.
Scheduling Adjustments:
- Adjusting scheduling practices to better manage the frequency and types of jobs, ensuring efficient allocation of resources and reducing downtime.
Thank you for reading this far, you can connect with me on LinkedIn for collaborations and insights.
Here are links to the necessary files used in this analysis:
Task A: ERD and Explanations, Codes for table creation.
Task B: Table creation codes, Dataset Import codes, Data cleaning codes, Data analysis codes, Database export file.