This project contains a set of SQL queries written to explore and analyze the Chinook database.
Each task focuses on joining multiple tables, extracting meaningful relationships between entities, and presenting results in a clear and structured way.
-
Tracks with album and artist
- Track name
- Album title
- Artist name
-
Invoice lines with track, invoice date, and customer
- Invoice line ID
- Invoice date
- Track name
- Unit price (from invoice line)
- Quantity
- Customer’s full name (combined first and last names)
-
Customers with their support representative (employee) sorted by full name of support representative and full name of customer
- Customer ID
- Customer’s full name (combined first and last names)
- Support representative’s full name (combined first and last name s)
-
Playlist contents: playlist name with each track sorted by playlist name and track’s name
- Playlist's name
- Track’s name
-
Invoices with billing city sorted by invoice date in descending order and Invoice ID in ascending order
- Invoice ID
- Invoice date
- Billing city
- Total
- Customer’s full name
-
Employees with no manager
- Employee’s full name
- Title
- Birth Date (only date with no time)
- Hire Date (only date with no time)
The goal of this homework assignment is to strengthen my SQL skills through practical work with a real relational schema.
The Chinook database provides a clean and well-structured environment to practice JOINs, sorting, date formatting, and working with multi-entity relationships such as tracks, albums, artists, invoices, customers, employees, and playlists.
Through this assignment, I aimed to improve my ability to:
- Write SQL queries involving multiple JOINs
- Extract composite fields such as full names
- Format output for clarity (dates, sorted results, naming)
- Understand how normalized tables connect in a production-like schema
- Navigate real-world entity relationships between music catalog data and sales records
These are essential skills for backend engineering, analytics, and any data-driven development workflow.
This project includes six SQL queries, each addressing a specific task in the Chinook environment:
Retrieves the track name together with its album and the performing artist.
Shows individual invoice lines combined with the track name, invoice date, unit price, quantity,
and the customer's full name.
Lists customers along with their assigned employees, sorted by both employee and customer full names.
Displays playlists and the tracks they contain, sorted alphabetically.
Returns invoices including invoice date, billing city, total price,
and full customer name, sorted by newest invoices first.
Shows employees whose reports_to value is NULL, indicating they do not have a manager.
All queries use readable formatting and consistent naming conventions.
Below is an entity-relationship diagram describing the main tables used in this assignment.
Examples of results produced by these queries may include:
- Track: “Give Me Back My Bullets” — Album: “Give Me Back My Bullets” — Artist: “Lynyrd Skynyrd”
- Invoice #312 on 2010-03-11 billed to Jane Peacock
- Playlist “Rock” contains track “Back in Black”
- Employee “Andrew Adams” has no manager
Actual output varies depending on the dataset inside Chinook.
- Install PostgreSQL or use any PostgreSQL-compatible environment.
- Import the Chinook database:
psql -U your_user -f chinook.sql-
Run the SQL queries in:
- psql
- pgAdmin
- DBeaver
- DataGrip
- Any SQL editor of your choice
All queries in this repository are fully compatible with PostgreSQL.
- PostgreSQL
- Chinook PostgreSQL schema
- Any SQL client
- ✔️ Fully completed
- ✔️ Tested against official Chinook sample database
- ✔️ Clean and maintainable SQL code
MIT License
This homework strengthened my practical understanding of relational databases, multi-table JOINs, and structured data extraction using the Chinook schema. By implementing all six queries — from track and album relations to invoices, playlists, and employee hierarchy — I reinforced my ability to navigate normalized datasets and transform them into clean, meaningful results.
Working through this assignment helped me better understand entity relationships, sorting logic, date formatting, and the importance of readable, maintainable SQL. These are essential skills for backend engineering and data-driven application development.
Great work — my SQL foundation just became stronger and more production-ready. 🚀
Made with ❤️ and SQL by Sam-Shepsl Malikin 🎓
