-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_management.sql
More file actions
52 lines (47 loc) · 1.37 KB
/
student_management.sql
File metadata and controls
52 lines (47 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- Create the database
CREATE DATABASE StudentManagement;
USE StudentManagement;
-- Create Students table
CREATE TABLE Students (
student_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
age INT NOT NULL,
class VARCHAR(20),
contact VARCHAR(15)
);
-- Create Courses table
CREATE TABLE Courses (
course_id INT PRIMARY KEY AUTO_INCREMENT,
course_name VARCHAR(100) NOT NULL,
instructor VARCHAR(100) NOT NULL
);
-- Create Enrollment table
CREATE TABLE Enrollment (
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)
);
-- Create Attendance table
CREATE TABLE Attendance (
attendance_id INT PRIMARY KEY AUTO_INCREMENT,
student_id INT,
course_id INT,
date DATE,
status ENUM('Present', 'Absent'),
FOREIGN KEY (student_id) REFERENCES Students(student_id),
FOREIGN KEY (course_id) REFERENCES Courses(course_id)
);
-- Create Marks table
CREATE TABLE Marks (
marks_id INT PRIMARY KEY AUTO_INCREMENT,
student_id INT,
course_id INT,
marks_obtained INT,
grade CHAR(2),
FOREIGN KEY (student_id) REFERENCES Students(student_id),
FOREIGN KEY (course_id) REFERENCES Courses(course_id)
);