Student Management System
1. Project Title: Student Management System
The objective is to design a system that helps manage student details, courses, and their
enrollments.
The system should allow the user to:
- Add and update student information.
- Manage course offerings.
- Track which students are enrolled in which courses.
2. Database Design
Entities:
1. Students: Contains information about students.
2. Courses: Contains details about courses offered.
3. Enrollments: Tracks which students are enrolled in which courses.
Tables:
1. Students
- student_id (Primary Key)
- first_name
- last_name
- email
- phone
- enrollment_year
2. Courses
- course_id (Primary Key)
- course_name
- course_code
- credits
3. Enrollments
- enrollment_id (Primary Key)
- student_id (Foreign Key)
- course_id (Foreign Key)
- enrollment_date
3. SQL Queries
Table Creation Queries:
-- Table for Students
CREATE TABLE Students (
student_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(50),
last_name VARCHAR(50),
email VARCHAR(100),
phone VARCHAR(15),
enrollment_year YEAR
);
-- Table for Courses
CREATE TABLE Courses (
course_id INT PRIMARY KEY AUTO_INCREMENT,
course_name VARCHAR(100),
course_code VARCHAR(10),
credits INT
);
-- Table for Enrollments
CREATE TABLE Enrollments (
enrollment_id INT PRIMARY KEY AUTO_INCREMENT,
student_id INT,
course_id INT,
enrollment_date DATE,
FOREIGN KEY (student_id) REFERENCES Students(student_id),
FOREIGN KEY (course_id) REFERENCES Courses(course_id)
);
Sample Data Insertion
-- Insert into Students
INSERT INTO Students (first_name, last_name, email, phone, enrollment_year) VALUES
('Alice', 'Johnson', '[email protected]', '123-456-7890', 2021),
('Bob', 'Smith', '[email protected]', '987-654-3210', 2022);
-- Insert into Courses
INSERT INTO Courses (course_name, course_code, credits) VALUES
('Database Systems', 'DB101', 4),
('Operating Systems', 'OS102', 3),
('Data Structures', 'DS103', 4);
-- Insert into Enrollments
INSERT INTO Enrollments (student_id, course_id, enrollment_date) VALUES
(1, 1, '2024-01-15'),
(1, 2, '2024-01-18'),
(2, 3, '2024-02-05');
Sample Queries
1. List all students and their enrollment years:
SELECT first_name, last_name, enrollment_year FROM Students;
2. List all courses available:
SELECT course_name, course_code, credits FROM Courses;
3. List all students enrolled in a specific course:
SELECT S.first_name, S.last_name, C.course_name, E.enrollment_date
FROM Students S
JOIN Enrollments E ON S.student_id = E.student_id
JOIN Courses C ON E.course_id = C.course_id
WHERE C.course_name = 'Database Systems';
4. Check which courses a specific student is enrolled in:
SELECT C.course_name, C.course_code, E.enrollment_date
FROM Courses C
JOIN Enrollments E ON C.course_id = E.course_id
JOIN Students S ON S.student_id = E.student_id
WHERE S.first_name = 'Alice' AND S.last_name = 'Johnson';
5. Count the number of students enrolled in each course:
SELECT C.course_name, COUNT(E.student_id) AS num_students
FROM Courses C
LEFT JOIN Enrollments E ON C.course_id = E.course_id
GROUP BY C.course_name;