0% found this document useful (0 votes)
7 views

Student_Management_System_Project

Mysql

Uploaded by

dadu27973
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Student_Management_System_Project

Mysql

Uploaded by

dadu27973
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Student Management System - MySQL Project

1. Objective
To design a relational database system to manage student information, courses,
enrollments, and grades in a structured and efficient way.

2. Database Design
The system consists of the following tables:

1. Students: Stores student details.


2. Courses: Stores course details.
3. Enrollment: Tracks student enrollment in courses.
4. Grades: Stores grades for completed courses.

3. SQL Implementation

3.1 Create Database


```sql
CREATE DATABASE StudentManagement;
USE StudentManagement;
```

3.2 Create Tables


a) Students Table

```sql
CREATE TABLE Students (
StudentID INT PRIMARY KEY AUTO_INCREMENT,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
DOB DATE,
Email VARCHAR(100) UNIQUE NOT NULL,
Phone VARCHAR(15),
Address VARCHAR(200)
);
```

b) Courses Table

```sql
CREATE TABLE Courses (
CourseID INT PRIMARY KEY AUTO_INCREMENT,
CourseName VARCHAR(100) NOT NULL,
Description TEXT,
Credits INT NOT NULL
);
```

c) Enrollment Table

```sql
CREATE TABLE Enrollment (
EnrollmentID INT PRIMARY KEY AUTO_INCREMENT,
StudentID INT NOT NULL,
CourseID INT NOT NULL,
EnrollmentDate DATE,
FOREIGN KEY (StudentID) REFERENCES Students(StudentID),
FOREIGN KEY (CourseID) REFERENCES Courses(CourseID)
);
```

d) Grades Table

```sql
CREATE TABLE Grades (
GradeID INT PRIMARY KEY AUTO_INCREMENT,
EnrollmentID INT NOT NULL,
Grade CHAR(2),
FOREIGN KEY (EnrollmentID) REFERENCES Enrollment(EnrollmentID)
);
```

4. Sample Data Insertion


a) Insert Students

```sql
INSERT INTO Students (FirstName, LastName, DOB, Email, Phone, Address)
VALUES
('Alice', 'Johnson', '2000-03-25', '[email protected]', '1234567890', '123 Main St'),
('Bob', 'Smith', '1999-07-15', '[email protected]', '9876543210', '456 Elm St');
```

b) Insert Courses

```sql
INSERT INTO Courses (CourseName, Description, Credits)
VALUES
('Mathematics', 'Study of numbers and equations', 4),
('Physics', 'Study of matter and energy', 3),
('Chemistry', 'Study of chemicals and reactions', 4);
```

c) Insert Enrollment

```sql
INSERT INTO Enrollment (StudentID, CourseID, EnrollmentDate)
VALUES
(1, 1, '2025-01-01'),
(1, 2, '2025-01-02'),
(2, 3, '2025-01-03');
```

d) Insert Grades

```sql
INSERT INTO Grades (EnrollmentID, Grade)
VALUES
(1, 'A'),
(2, 'B'),
(3, 'A');
```

5. Queries
a) View All Students

```sql
SELECT * FROM Students;
```

b) List of Courses and Enrolled Students

```sql
SELECT
Students.FirstName, Students.LastName, Courses.CourseName
FROM
Enrollment
JOIN
Students ON Enrollment.StudentID = Students.StudentID
JOIN
Courses ON Enrollment.CourseID = Courses.CourseID;
```

c) Update Student Email


```sql
UPDATE Students
SET Email = '[email protected]'
WHERE StudentID = 1;
```

d) Delete a Course

```sql
DELETE FROM Courses
WHERE CourseID = 2;
```

e) Aggregate Query: Total Students Enrolled in Each Course

```sql
SELECT
Courses.CourseName, COUNT(Enrollment.StudentID) AS TotalStudents
FROM
Enrollment
JOIN
Courses ON Enrollment.CourseID = Courses.CourseID
GROUP BY
Courses.CourseName;
```

6. Conclusion
This project demonstrates the implementation of a Student Management System using
MySQL. It includes table creation, data insertion, and executing various queries for effective
data management. The project can be further enhanced by adding features like attendance
tracking and teacher management.

You might also like