Welcome to the Football Ticket Booking System database project! This repository contains the complete schema design, Entity-Relationship Diagram (ERD), and complex SQL queries required to manage real-world ticketing scenarios for a football platform.
This project is built to seamlessly handle football fans purchasing tickets, manage upcoming tournament matches, and generate individual ticket booking receipts. It demonstrates a strong understanding of database relationships, referential integrity, and advanced data retrieval techniques.
The system is built on a robust, normalized relational database architecture consisting of three core tables:
Manages the platform's user base, including both administrative staff and football fans.
- Key Fields:
user_id(PK),full_name,email,role,phone_number.
Catalogs all tournament events, team fixtures, base pricing, and ticket availability statuses.
- Key Fields:
match_id(PK),fixture,tournament_category,base_ticket_price,match_status.
A transactional table recording every individual ticket purchase, establishing the vital link between a fan and a specific match.
- Key Fields:
booking_id(PK),user_id(FK),match_id(FK),seat_number,payment_status,total_cost.
The database utilizes One-to-Many, Many-to-One, and One-to-One (logical) relationships to enforce data integrity.
All queries can be found within the QUERY.sql file. The project utilizes various intermediate to advanced SQL features, including:
- Filtering & Pattern Matching: Finding specific tournament matches or searching user names using
ILIKEandLIKE. - Handling Missing Data: Utilizing
COALESCEto elegantly manageNULLpayment statuses. - Complex Joins: Employing
INNER JOINto fetch booking receipts with full user and match details, andLEFT JOINto identify users with zero bookings. - Aggregations & Subqueries: Calculating the system's average booking cost and dynamically filtering transactions that exceed it.
- Sorting & Pagination: Retrieving the most expensive matches using
ORDER BY,LIMIT, andOFFSETstrategies.
- Referential Integrity: Robust use of Primary Keys (PK) and Foreign Keys (FK).
- Constraints: Data validation through
UNIQUE,CHECK, andNOT NULLconstraints. - Relational Logic: Precise mapping of real-world scenarios into relational tables.
- Data Cleansing: Graceful handling of empty records and null values.
- Make sure you have PostgreSQL installed.
- Create a new database in your SQL client (e.g., pgAdmin, DBeaver).
- Execute the table creation schemas.
- Insert the provided sample data.
- Run the queries from the
QUERY.sqlfile to see the output!
Crafted with ❤️ for modern database engineering.