-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradingSystem_Simplified.sql
64 lines (53 loc) · 1.67 KB
/
GradingSystem_Simplified.sql
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
53
54
55
56
57
58
59
60
61
62
63
64
CREATE DATABASE IF NOT EXISTS GradingSystem;
USE GradingSystem;
drop table if exists StudentGrade;
drop table if exists CourseAssignment;
drop table if exists StudentSection;
drop table if exists CourseSection;
drop table if exists Course;
drop table if exists Faculty;
drop table if exists Student;
CREATE TABLE Student(
student_id varchar(10) PRIMARY KEY,
student_fname text,
student_lname text,
gpa decimal
);
CREATE TABLE Faculty (
faculty_id varchar(10) PRIMARY KEY,
faculty_fname text,
faculty_lname text
);
CREATE TABLE Course (
course_code varchar(10) PRIMARY KEY,
course_name text
);
CREATE TABLE CourseSection (
section_id integer PRIMARY KEY,
course_code varchar(10),
instructor varchar(10),
semester text,
foreign key (course_code) references Course (course_code),
foreign key (instructor) references Faculty (faculty_id)
);
create table StudentSection (
student_section_id integer primary key not null,
student_id varchar(10),
section_id integer,
foreign key (student_id) references Student (student_id),
foreign key (section_id) references CourseSection (section_id)
);
CREATE TABLE CourseAssignment(
assignment_id integer PRIMARY KEY NOT NULL,
section_id integer,
assignment_name text,
assignment_weight decimal,
foreign key (section_id) references CourseSection (section_id)
);
create table StudentGrade(
student_grade_id integer primary key not null,
assignment_id integer,
student_id varchar(10),
foreign key (student_id) references Student (student_id),
foreign key (assignment_id) references CourseAssignment (assignment_id)
);