__STYLES__
I wanted to practice my recently acquired skills in data analysis and chose the Maven Analytics Pizza Challenge to start off with. In this project, I acted as a data analyst for a pizza business and sought to understand how the business was doing in terms of pizza sales and identified insights that could help boost sales during low months and days.
I sought to address the following questions:
The data
This dataset consisted of 4 tables in CSV format:
CREATE TABLE orders(
order_id SERIAL PRIMARY KEY,
date DATE NOT NULL,
time TIME NOT NULL
)
`CREATE TABLE pizza_types(
pizza_types_id SERIAL PRIMARY KEY,
name VARCHAR(500) UNIQUE NOT NULL,
category VARCHAR(500) NOT NULL
)
`CREATE TABLE pizzas(
pizza_id VARCHAR(5000) UNIQUE NOT NULL,
pizza_type_id VARCHAR(8000) REFERENCES pizza_types(pizza_type_id),
size VARCHAR(5) NOT NULL,
price NUMERIC(5,2) NOT NULL
)
ALTER TABLE pizzas
ADD CONSTRAINT pizzas_pk PRIMARY KEY(pizza_id);
CREATE TABLE order_details(
order_details_id SERIAL PRIMARY KEY,
order_id INTEGER REFERENCES orders(order_id),
pizza_id VARCHAR(5000) REFERENCES pizzas(pizza_id),
quantity INTEGER NOT NULL
)
I then uploaded the relevant data from the CSV files provided into these tables.
SELECT
typ.category,
typ.pizza_type_id,
piz.pizza_id,
det.order_id,
ord.date,
TO_CHAR(ord.date, 'Day') AS "day",
ord.time,
SUM(det.quantity) AS total_units,
SUM(det.quantity * piz.price) AS revenue
FROM pizza_types AS typ
JOIN pizzas AS piz
ON typ.pizza_type_id = piz.pizza_type_id
JOIN order_details AS det
ON piz.pizza_id = det.pizza_id
JOIN orders AS ord
ON ord.order_id = det.order_id
GROUP BY
typ.category,
typ.pizza_type_id,
piz.pizza_id,
det.order_id,
ord.date,
ord.time
ORDER BY order_id
I then downloaded the table as a CSV file.
In MS Excel I used the filter tool to check for any null values or spelling errors in the columns.
Created a calculated field to extract hour from date time:
DATEPART(‘Hour’, [TIME])
I focused on creating visualizations for the following: