PRAGMA foreign_keys = ON;

PRAGMA writable_schema = 1;
DELETE FROM sqlite_master WHERE type IN ("table", "index", "trigger");
PRAGMA writable_schema = 0;
VACUUM;

CREATE TABLE "Courses" (
"course_id" INT UNIQUE,
"course_name" VARCHAR(255),
PRIMARY KEY ("course_id")
);

CREATE TABLE "Degree_Programs" (
"degree_program_id" INT,
"degree_summary_name" VARCHAR(255),
PRIMARY KEY ("degree_program_id")
);

CREATE TABLE "Semesters" (
"semester_id" INT,
"semester_name" VARCHAR(255),
PRIMARY KEY ("semester_id")
);

CREATE TABLE "Student_Enrolment" (
"student_enrolment_id" INT UNIQUE,
"student_id" INT,
PRIMARY KEY ("student_enrolment_id"),
FOREIGN KEY ("student_id") REFERENCES "Students"("student_id")
);

CREATE TABLE "Student_Enrolment_Courses" (
"student_course_id" INT,
"course_id" INT,
"student_enrolment_id" INT,
PRIMARY KEY ("student_course_id"),
FOREIGN KEY ("student_enrolment_id") REFERENCES "Student_Enrolment"("student_enrolment_id"),
FOREIGN KEY ("course_id") REFERENCES "Courses"("course_id")
);

CREATE TABLE "Students" (
"student_id" INT,
"first_name" VARCHAR(80),
PRIMARY KEY ("student_id")
);





INSERT INTO "Courses" VALUES ("1", "Introduction to Programming");
INSERT INTO "Courses" VALUES ("2", "Calculus I");
INSERT INTO "Courses" VALUES ("3", "Linear Algebra");
INSERT INTO "Courses" VALUES ("4", "Database Systems");
INSERT INTO "Courses" VALUES ("5", "Operating Systems");
INSERT INTO "Courses" VALUES ("6", "Data Structures");
INSERT INTO "Courses" VALUES ("7", "Web Development");
INSERT INTO "Courses" VALUES ("8", "Art History");
INSERT INTO "Courses" VALUES ("9", "Introduction to Psychology");
INSERT INTO "Courses" VALUES ("10", "Advanced Algorithms");
INSERT INTO "Degree_Programs" VALUES ("1", "Computer Science");
INSERT INTO "Degree_Programs" VALUES ("2", "Mathematics");
INSERT INTO "Degree_Programs" VALUES ("3", "Information Technology");
INSERT INTO "Degree_Programs" VALUES ("4", "Arts and Humanities");
INSERT INTO "Semesters" VALUES ("1", "Fall 2023");
INSERT INTO "Semesters" VALUES ("2", "Spring 2024");
INSERT INTO "Semesters" VALUES ("3", "Summer 2024");
INSERT INTO "Students" VALUES ("101", "Alice");
INSERT INTO "Students" VALUES ("102", "Bob");
INSERT INTO "Students" VALUES ("103", "Charlie");
INSERT INTO "Students" VALUES ("104", "David");
INSERT INTO "Students" VALUES ("105", "Eve");
INSERT INTO "Students" VALUES ("106", "Frank");
INSERT INTO "Students" VALUES ("107", "Grace");
INSERT INTO "Student_Enrolment" VALUES ("1001", "101");
INSERT INTO "Student_Enrolment" VALUES ("1002", "102");
INSERT INTO "Student_Enrolment" VALUES ("1003", "103");
INSERT INTO "Student_Enrolment" VALUES ("1004", "104");
INSERT INTO "Student_Enrolment" VALUES ("1005", "105");
INSERT INTO "Student_Enrolment" VALUES ("1006", "106");
INSERT INTO "Student_Enrolment" VALUES ("1007", "107");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1", "1", "1001");
INSERT INTO "Student_Enrolment_Courses" VALUES ("2", "2", "1001");
INSERT INTO "Student_Enrolment_Courses" VALUES ("3", "4", "1002");
INSERT INTO "Student_Enrolment_Courses" VALUES ("4", "5", "1002");
INSERT INTO "Student_Enrolment_Courses" VALUES ("5", "1", "1003");
INSERT INTO "Student_Enrolment_Courses" VALUES ("6", "3", "1003");
INSERT INTO "Student_Enrolment_Courses" VALUES ("7", "6", "1004");
INSERT INTO "Student_Enrolment_Courses" VALUES ("8", "7", "1004");
INSERT INTO "Student_Enrolment_Courses" VALUES ("9", "1", "1005");
INSERT INTO "Student_Enrolment_Courses" VALUES ("10", "2", "1005");
INSERT INTO "Student_Enrolment_Courses" VALUES ("11", "4", "1006");
INSERT INTO "Student_Enrolment_Courses" VALUES ("12", "6", "1006");
INSERT INTO "Student_Enrolment_Courses" VALUES ("13", "8", "1007");
INSERT INTO "Student_Enrolment_Courses" VALUES ("14", "9", "1007");