This project analyzes the PostgreSQL Pagila sample database, a DVD rental database containing information about customers, films, rentals, payments, stores, actors, and categories.
The goal of this project is to demonstrate SQL analytical skills by answering business questions related to revenue performance, customer behavior, film popularity, and rental activity.
The analysis was performed using PostgreSQL and focuses on transforming raw relational data into meaningful business insights.
This project answers questions across five main analytical areas:
- What is the total revenue generated by each store?
- How has monthly revenue changed over time?
- Which film categories generate the most revenue?
- Who are the top customers by total spending?
- Which customers have been inactive for the longest time?
- Who are the highest-spending customers within each store?
- How are customers distributed into spending quartiles?
- Which films are rented the most?
- Which film generates the highest rental revenue within each category?
- Which actors appear in the most rented films?
- Which days of the week and hours of the day experience the highest rental activity?
- How has monthly revenue changed compared to the previous month?
More details about each business question can be found in
business_questions.md.
- PostgreSQL
- SQL
- DBeaver
- Git & GitHub
- Visual Studio Code
- SQLTools
SQL techniques used:
- Joins
- Aggregations
- Common Table Expressions (CTEs)
- Window functions
- Ranking functions
- Date/time functions
The project uses the Pagila relational database.
The main analytical tables include:
- customer
- payment
- rental
- inventory
- film
- category
- film_category
- actor
- film_actor
- store
- staff
The complete schema documentation and entity relationship diagram are available in:
This project uses the Pagila sample database (PostgreSQL).
-
Get Pagila — clone or download the schema and data files from xzilla/pagila:
pagila-schema.sqlpagila-data.sql
-
Create a database and load the files, in order:
createdb pagila
psql -d pagila -f pagila-schema.sql
psql -d pagila -f pagila-data.sql- Verify the load:
SELECT COUNT(*) FROM store; -- expect 2
SELECT COUNT(*) FROM customer; -- expect ~599
SELECT COUNT(*) FROM film; -- expect 1000- Run any query in the
queries/folder against thepagiladatabase using your client of choice (psql, DBeaver, etc.). Each file is self-contained and includes its business question, context, and findings in the header comment.
Screenshots of each query's output are available in:
The analysis workflow consisted of:
- Understanding the database structure
- Identifying relevant business questions
- Writing SQL queries to answer each question
- Validating query outputs
- Documenting analytical methods and results
Detailed methodology:
This project demonstrates experience with:
- Relational database analysis
- Writing analytical SQL queries
- Data aggregation and transformation
- Business-oriented problem solving
- Working with normalized database schemas
- Communicating analytical results through documentation
