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 "Student_Enrolment" (
"student_enrolment_id" INT,
"semester_id" INT,
PRIMARY KEY ("student_enrolment_id")
);

CREATE TABLE "Student_Enrolment_Courses" (
"student_course_id" INT UNIQUE,
"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")
);

CREATE TABLE "Transcript_Contents" (
"student_course_id" INT,
"transcript_id" INT,
FOREIGN KEY ("transcript_id") REFERENCES "Transcripts"("transcript_id"),
FOREIGN KEY ("student_course_id") REFERENCES "Student_Enrolment_Courses"("student_course_id")
);

CREATE TABLE "Transcripts" (
"transcript_id" INT UNIQUE,
PRIMARY KEY ("transcript_id")
);





INSERT INTO "Courses" VALUES ("1", "Mathematics I");
INSERT INTO "Courses" VALUES ("2", "Physics II");
INSERT INTO "Courses" VALUES ("3", "Chemistry III");
INSERT INTO "Courses" VALUES ("4", "Computer Science Fundamentals");
INSERT INTO "Courses" VALUES ("5", "History of Art");
INSERT INTO "Courses" VALUES ("6", "Advanced Calculus");
INSERT INTO "Courses" VALUES ("7", "Data Structures");
INSERT INTO "Student_Enrolment" VALUES ("101", "20231");
INSERT INTO "Student_Enrolment" VALUES ("102", "20231");
INSERT INTO "Student_Enrolment" VALUES ("103", "20232");
INSERT INTO "Student_Enrolment" VALUES ("104", "20232");
INSERT INTO "Student_Enrolment" VALUES ("105", "20241");
INSERT INTO "Student_Enrolment" VALUES ("106", "20241");
INSERT INTO "Student_Enrolment" VALUES ("107", "20231");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1001", "1", "101");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1002", "2", "101");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1003", "3", "102");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1004", "1", "102");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1005", "4", "103");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1006", "1", "103");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1007", "2", "104");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1008", "5", "104");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1009", "1", "105");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1010", "6", "105");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1011", "7", "106");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1012", "1", "107");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1013", "4", "107");
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");
INSERT INTO "Students" VALUES ("7");
INSERT INTO "Transcripts" VALUES ("201");
INSERT INTO "Transcripts" VALUES ("202");
INSERT INTO "Transcripts" VALUES ("203");
INSERT INTO "Transcripts" VALUES ("204");
INSERT INTO "Transcripts" VALUES ("205");
INSERT INTO "Transcripts" VALUES ("206");
INSERT INTO "Transcripts" VALUES ("207");
INSERT INTO "Transcripts" VALUES ("208");
INSERT INTO "Transcripts" VALUES ("209");
INSERT INTO "Transcripts" VALUES ("210");
INSERT INTO "Transcript_Contents" VALUES ("1001", "201");
INSERT INTO "Transcript_Contents" VALUES ("1002", "201");
INSERT INTO "Transcript_Contents" VALUES ("1003", "202");
INSERT INTO "Transcript_Contents" VALUES ("1004", "202");
INSERT INTO "Transcript_Contents" VALUES ("1005", "203");
INSERT INTO "Transcript_Contents" VALUES ("1006", "203");
INSERT INTO "Transcript_Contents" VALUES ("1007", "204");
INSERT INTO "Transcript_Contents" VALUES ("1008", "204");
INSERT INTO "Transcript_Contents" VALUES ("1009", "205");
INSERT INTO "Transcript_Contents" VALUES ("1010", "205");
INSERT INTO "Transcript_Contents" VALUES ("1011", "206");
INSERT INTO "Transcript_Contents" VALUES ("1001", "207");
INSERT INTO "Transcript_Contents" VALUES ("1004", "208");
INSERT INTO "Transcript_Contents" VALUES ("1006", "209");
INSERT INTO "Transcript_Contents" VALUES ("1009", "210");
INSERT INTO "Transcript_Contents" VALUES ("1012", "201");
INSERT INTO "Transcript_Contents" VALUES ("1013", "202");