-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent Management System (SMS)
More file actions
51 lines (43 loc) · 1.19 KB
/
Student Management System (SMS)
File metadata and controls
51 lines (43 loc) · 1.19 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
//first we need to create a database
CREATE DATABASE student_management;
USE student_management;
//Next we should create tables related
CREATE TABLE students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
age INT,
email VARCHAR(100)
);
CREATE TABLE courses (
course_id INT AUTO_INCREMENT PRIMARY KEY,
course_name VARCHAR(50),
credits INT
);
CREATE TABLE enrollments (
enroll_id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
course_id INT,
grade VARCHAR(5),
FOREIGN KEY (student_id) REFERENCES students(student_id),
FOREIGN KEY (course_id) REFERENCES courses(course_id)
);
//Insert Sample Data
INSERT INTO students (name, age, email) VALUES
('Poojitha', 22, 'pooji@gmail.com'),
('Ram', 23, 'ram@gmail.com');
INSERT INTO courses (course_name, credits) VALUES
('Java Basics', 3),
('SQL Foundations', 4);
INSERT INTO enrollments (student_id, course_id, grade) VALUES
(1, 1, 'A'),
(1, 2, 'B'),
(2, 1, 'A');
// Sample Queries
All students:
SELECT * FROM students;
Courses taken by Poojitha:
SELECT s.name, c.course_name, e.grade
FROM enrollments e
JOIN students s ON e.student_id = s.student_id
JOIN courses c ON e.course_id = c.course_id
WHERE s.name = 'Poojitha';