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 "Degree_Programs" (
"degree_program_id" INT UNIQUE,
PRIMARY KEY ("degree_program_id")
);

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

CREATE TABLE "Student_Enrolment" (
"student_enrolment_id" INT,
"degree_program_id" INT,
"semester_id" INT,
"student_id" INT,
"other_details" VARCHAR(255),
PRIMARY KEY ("student_enrolment_id"),
FOREIGN KEY ("student_id") REFERENCES "Students"("student_id"),
FOREIGN KEY ("semester_id") REFERENCES "Semesters"("semester_id"),
FOREIGN KEY ("degree_program_id") REFERENCES "Degree_Programs"("degree_program_id")
);

CREATE TABLE "Students" (
"student_id" INT UNIQUE,
"first_name" VARCHAR(80),
"middle_name" VARCHAR(40),
"last_name" VARCHAR(40),
"email_address" VARCHAR(40),
PRIMARY KEY ("student_id")
);





INSERT INTO "Degree_Programs" VALUES ("1");
INSERT INTO "Degree_Programs" VALUES ("2");
INSERT INTO "Degree_Programs" VALUES ("3");
INSERT INTO "Degree_Programs" VALUES ("4");
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", "M.", "Johnson", "alice.johnson@example.com");
INSERT INTO "Students" VALUES ("102", "Bob", "K.", "Smith", "bob.smith@example.com");
INSERT INTO "Students" VALUES ("103", "Charlie", "L.", "Brown", "charlie.brown@example.com");
INSERT INTO "Students" VALUES ("104", "Diana", "N.", "Evans", "diana.evans@example.com");
INSERT INTO "Students" VALUES ("105", "Ethan", "O.", "Williams", "ethan.williams@example.com");
INSERT INTO "Student_Enrolment" VALUES ("1001", "1", "1", "101", "Enrolled in CS and Math");
INSERT INTO "Student_Enrolment" VALUES ("1002", "2", "1", "101", "Enrolled in CS and Math");
INSERT INTO "Student_Enrolment" VALUES ("1003", "1", "2", "102", "Single program enrollment");
INSERT INTO "Student_Enrolment" VALUES ("1004", "3", "2", "102", "Single program enrollment");
INSERT INTO "Student_Enrolment" VALUES ("1005", "2", "1", "103", "Only one program this semester");
INSERT INTO "Student_Enrolment" VALUES ("1006", "3", "1", "103", "Only one program this semester");
INSERT INTO "Student_Enrolment" VALUES ("1007", "1", "3", "104", "Enrolled in two programs same semester");
INSERT INTO "Student_Enrolment" VALUES ("1008", "4", "3", "104", "Enrolled in two programs same semester");
INSERT INTO "Student_Enrolment" VALUES ("1009", "2", "3", "105", "Single program enrollment");
INSERT INTO "Student_Enrolment" VALUES ("1010", "3", "3", "105", "Single program enrollment");