University Management System (Students, Courses, Professors)
Design and build a relational database in PostgreSQL to manage the data of a university system. Your system should handle information about students, professors, courses, and their relationships.
Create a new database named:
university_systemYou must decide on the database structure yourself.
Your design must include:
-
At least 4–5 tables that represent main entities of a university system. Examples of possible entities:
- Students
- Professors
- Courses
- Departments
- Enrollments (or Registrations)
- Classrooms or Semesters
You may include additional tables if they make logical sense.
For each table:
- Choose appropriate column names and data types
- Define primary keys
- Use foreign keys to link related tables
- Add constraints where needed (
NOT NULL,UNIQUE,CHECK, etc.)
Tip: Think about how you would track which student is taking which course, who teaches each course, and in which department professors belong.
Insert at least:
- 5 professors
- 6 courses
- 10 students
- Several relationships (e.g., students enrolled in different courses)
The data must make logical sense. For example, each course should have a professor; each student can enroll in multiple courses.
Write SQL queries that demonstrate your understanding of:
- JOINs (inner, left, etc.)
- Filtering (
WHERE) - Aggregation (
COUNT,AVG, etc.) - Grouping (
GROUP BY) - Sorting (
ORDER BY) - Subqueries or views
Your queries must produce meaningful information, such as:
- List of students enrolled in a specific course
- Courses taught by a certain professor
- Number of students per course
- Average grade per course or per student (if you add grades)
- Departments with the most professors
- Students not enrolled in any course
Add one of the following:
- A VIEW showing full student-course-professor relationships
- A TRIGGER to automatically update a student’s total enrolled credits
- A STORED FUNCTION returning a professor’s teaching load (number of courses taught)
Submit:
-
.sqlfile that includes:CREATE DATABASE- All table creation statements
- Insert data statements
- All queries
-
A short README (or comment block) explaining:
- What each table represents
- The relationships between them
- What each query shows