This project is a comprehensive SQL-based analysis of the Sakila Sample Database, covering key insights and behaviors of customers, films, rentals, and financials.
All logic is implemented in a single SQL script file:
sakila_analysis.sql
Running this file will create all the necessary views, stored procedures, and functions in your MySQL Sakila database.
Note: Since the Sakila dataset contains historical data from 2005-2006, procedures or views that depend on recent time ranges (e.g., last 3 months) may return no results when executed today. This behavior is expected.
sakila-analysis/
│
├── views/ # Reusable reports and insights
├── procedures/ # Stored procedures for business logic
├── functions/ # User-defined utility functions
├── sakila_analysis.sql #All logic
├── README.md
Generates a report of daily sales by summing up rental payments for each day.
Columns: date, total_sales
Useful for tracking rental revenue trends over time.
Returns customers list with overdue movie rentals who owe late fees. Columns: customer_id, full_name, email Helps identify customers with overdue returns.
Summarizes monthly revenue from all rentals.
Columns: month, total_sales
Useful for financial reports and comparing month-to-month performance.
Estimates the probability of each film being rented again in the upcoming month, based on its performance in recent months.
Columns: FID, title, description, category, price, length, rating, count_avg, last_month_count, probability
probability: High, Medium, Low, Very Low
Identifies the days with the highest number of rentals.
Columns: rental_day, rental_count
Used for understanding peak business days.
Shows the most frequently rented actors based on their film appearances.
Columns: actor_id, first_name, last_name
Useful for marketing and recommendations.
Lists genres that have received the most rentals.
Columns: genre, rental_count
Helps analyze customer preferences.
Customers who have been active in the last 3 months.
Columns: rental_id, customer_id, full_name, email, rental_date
Supports re-engagement strategies.
Customers who have rented the most films in total.
Columns: ID, full_name, phone, rental_count
Great for loyalty programs and VIP marketing.
Films that have generated the most revenue.
Columns: film_id, title, description, length, rating, rental_rate, total_sale
Insight into which films perform best commercially.
Summarized yearly sales.
Columns: year, total_sales
Helpful for long-term performance tracking.
Returns all films by a specific actor along with total sales per film.
Columns: film_id, title, genres, length, rating, reales_year, total_sales
Useful for analyzing individual actor performance.
Calculates total late fees and rental durations for a customer.
Columns: rental_id, film_id, title, rental_date, return_date, rental_duration, late, replacement_cost
Helps track customer behavior and payment discipline.
Estimates how likely a film is to be rented next month based on the last 3 months.
Columns: count_avg, last_month_count, probability
Same logic as monthly_sales_probability, but for one film.
Finds customers with more than a certain number of rentals or rental total.
Columns: customer_id, full_name, email, rental_count, total_amount
For targeting high-value customers.
Returns total revenue for a specific month.
Columns: total_sale
Input format: 'YYYY-MM'
Recommends top 5 best-selling films from the customer’s most-rented genre.
Columns: film_id, title, description, length, rating, rental_rate, genre, total_sale
Useful for building recommendation engines.
Returns the average number of days a film is rented.
Used for planning film availability and popularity.
Calculates total payments made by a customer.
Useful for evaluating customer lifetime value.
Calculates total revenue generated by a film.
Great for analyzing commercial performance.
-
Install the Sakila Database First, make sure you have the official Sakila database installed on your MySQL server. You can download it and follow the installation guide from the official MySQL documentation: Sakila Sample Database Installation Guide
-
Clone the repository
git clone https://github.com/Sinabehboodi/sakila-dataset-practicing.git
-
Run the Analysis Script The entire analysis (views, procedures and functions) is included in a single SQL file: sakila_analysis.sql. Runnig this file will set up everything automatically:
SOURCE sakila_analysis.sql;