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 "Sections" (
"section_id" INT,
"section_name" VARCHAR(255),
PRIMARY KEY ("section_id")
);

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

CREATE TABLE "Student_Enrolment" (
"student_enrolment_id" INT UNIQUE,
PRIMARY KEY ("student_enrolment_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 UNIQUE,
PRIMARY KEY ("student_id")
);





INSERT INTO "Courses" VALUES ("1", "Introduction to Programming");
INSERT INTO "Courses" VALUES ("2", "Database Management");
INSERT INTO "Courses" VALUES ("3", "Web Development Basics");
INSERT INTO "Courses" VALUES ("4", "Data Structures and Algorithms");
INSERT INTO "Courses" VALUES ("5", "Operating Systems");
INSERT INTO "Courses" VALUES ("6", "Calculus I");
INSERT INTO "Courses" VALUES ("7", "Linear Algebra");
INSERT INTO "Courses" VALUES ("8", "Discrete Mathematics");
INSERT INTO "Sections" VALUES ("101", "Morning Session");
INSERT INTO "Sections" VALUES ("102", "Afternoon Session");
INSERT INTO "Sections" VALUES ("103", "Evening Session");
INSERT INTO "Sections" VALUES ("104", "Online Self-Paced");
INSERT INTO "Semesters" VALUES ("20231", "Fall 2023");
INSERT INTO "Semesters" VALUES ("20241", "Spring 2024");
INSERT INTO "Semesters" VALUES ("20242", "Summer 2024");
INSERT INTO "Student_Enrolment" VALUES ("1001");
INSERT INTO "Student_Enrolment" VALUES ("1002");
INSERT INTO "Student_Enrolment" VALUES ("1003");
INSERT INTO "Student_Enrolment" VALUES ("1004");
INSERT INTO "Student_Enrolment" VALUES ("1005");
INSERT INTO "Student_Enrolment" VALUES ("1006");
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", "1", "1002");
INSERT INTO "Student_Enrolment_Courses" VALUES ("4", "3", "1002");
INSERT INTO "Student_Enrolment_Courses" VALUES ("5", "4", "1003");
INSERT INTO "Student_Enrolment_Courses" VALUES ("6", "2", "1004");
INSERT INTO "Student_Enrolment_Courses" VALUES ("7", "5", "1005");
INSERT INTO "Student_Enrolment_Courses" VALUES ("8", "1", "1006");
INSERT INTO "Student_Enrolment_Courses" VALUES ("9", "3", "1006");
INSERT INTO "Students" VALUES ("1");
INSERT INTO "Students" VALUES ("2");
INSERT INTO "Students" VALUES ("3");
INSERT INTO "Students" VALUES ("4");
INSERT INTO "Students" VALUES ("5");
INSERT INTO "Students" VALUES ("6");