A complete SQL capstone project that designs and manages a University Course Management System — featuring 5 related tables with Foreign Keys, 16 analytical queries covering JOINs, Subqueries, Window Functions, Date Functions, String Functions and CASE statements.
This project builds a fully normalized University Database from scratch — managing Students, Courses, Departments, Instructors and Enrollments — and answers 16 real-world business questions using advanced SQL techniques.
UCMS (University Course Management System)
│
├── department → DepartmentID, DepartmentName
├── students → StudentID, FirstName, LastName, Email, BirthDate, EnrollmentDate
├── courses → CourseID, CourseName, DepartmentID*, Credits
├── instructors → InstructorID, FirstName, LastName, Email, DepartmentID*, Salary
└── enrollment → EnrollmentID, StudentID*, CourseID*, EnrollmentDate
* = Foreign Key
| Q# | Question | Concept Used |
|---|---|---|
| Q1 | CRUD Operations on Students | INSERT, UPDATE, DELETE, SELECT |
| Q2 | Students enrolled after 2022 | YEAR() + WHERE |
| Q3 | Courses by department | JOIN + WHERE |
| Q4 | Student count per course (>1) | GROUP BY + HAVING |
| Q5 | Students in both SQL & Data Structure | Subquery + HAVING COUNT(DISTINCT) |
| Q6 | Students in SQL or Data Structure | JOIN + IN + DISTINCT |
| Q7 | Average credits of all courses | AVG() |
| Q8 | Max salary of instructor by department | ALTER TABLE + MAX() + JOIN |
| Q9 | Student count per department | 3-table JOIN + GROUP BY |
| Q10 | Students with their enrolled courses | INNER JOIN (3 tables) |
| Q11 | All students including unenrolled | LEFT JOIN (3 tables) |
| Q12 | Students in courses with >1 students | Nested Subquery |
| Q13 | Extract enrollment year | YEAR() |
| Q14 | Instructor full name | CONCAT() |
| Q15 | Running total of students per course | COUNT() OVER() Window Function |
| Q16 | Label Senior / Junior by enrollment | TIMESTAMPDIFF() + CASE WHEN |
- Database: MySQL
- Concepts: DDL, DML, Foreign Keys, JOINs, Subqueries, Window Functions, String Functions, Date Functions, CASE, ALTER TABLE
- Tool: MySQL Workbench
sql-capstone-project/
│
├── Final_Project.sql # Complete SQL script (16 queries)
└── README.md # Project documentation
- Clone the repository
git clone https://github.com/ravindra-data/sql-capstone-project.git
-
Open MySQL Workbench
-
Open
Final_Project.sqland run it -
Database
UCMSwill be created with all 5 tables and 16 queries!
-- Q15: Running Total of Students Per Course
SELECT CourseID,
COUNT(StudentID) OVER(ORDER BY CourseID) AS running_total
FROM enrollment;
-- Output: 1 → 2 → 3 → 4
-- Q16: Senior / Junior Label
SELECT StudentID, FirstName,
CASE
WHEN TIMESTAMPDIFF(MONTH, EnrollmentDate, CURDATE()) > 1
THEN 'Senior'
ELSE 'Junior'
END AS Status FROM students;
-- Q9: Student Count Per Department
-- Computer Science → 2 students
-- Math → 2 students
- Designing a normalized relational database with Foreign Key constraints
- Writing complex multi-table JOINs (3 tables at once)
- Using nested Subqueries to filter based on aggregated data
- Modifying live tables using
ALTER TABLEto add new columns - Applying Window Functions —
COUNT() OVER()for running totals - Labeling data dynamically using
CASE WHEN TIMESTAMPDIFF() - Answering 16 real-world business questions using SQL