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 UNIQUE,
"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 "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,
"transcript_date" DATETIME,
PRIMARY KEY ("transcript_id")
);





INSERT INTO "Courses" VALUES ("1", "Mathematics");
INSERT INTO "Courses" VALUES ("2", "Physics");
INSERT INTO "Courses" VALUES ("3", "Chemistry");
INSERT INTO "Courses" VALUES ("4", "Biology");
INSERT INTO "Courses" VALUES ("5", "History");
INSERT INTO "Student_Enrolment" VALUES ("10", "202101");
INSERT INTO "Student_Enrolment" VALUES ("11", "202102");
INSERT INTO "Student_Enrolment" VALUES ("12", "202103");
INSERT INTO "Student_Enrolment" VALUES ("13", "202104");
INSERT INTO "Student_Enrolment" VALUES ("14", "202105");
INSERT INTO "Student_Enrolment_Courses" VALUES ("100", "1", "10");
INSERT INTO "Student_Enrolment_Courses" VALUES ("101", "2", "10");
INSERT INTO "Student_Enrolment_Courses" VALUES ("102", "1", "11");
INSERT INTO "Student_Enrolment_Courses" VALUES ("103", "3", "11");
INSERT INTO "Student_Enrolment_Courses" VALUES ("104", "1", "12");
INSERT INTO "Student_Enrolment_Courses" VALUES ("105", "4", "12");
INSERT INTO "Student_Enrolment_Courses" VALUES ("106", "2", "13");
INSERT INTO "Student_Enrolment_Courses" VALUES ("107", "1", "13");
INSERT INTO "Student_Enrolment_Courses" VALUES ("108", "5", "14");
INSERT INTO "Student_Enrolment_Courses" VALUES ("109", "1", "14");
INSERT INTO "Transcripts" VALUES ("1000", "2021-06-01 10:00:00");
INSERT INTO "Transcripts" VALUES ("1001", "2021-06-02 10:00:00");
INSERT INTO "Transcripts" VALUES ("1002", "2021-06-03 10:00:00");
INSERT INTO "Transcripts" VALUES ("1003", "2021-06-04 10:00:00");
INSERT INTO "Transcripts" VALUES ("1004", "2021-06-05 10:00:00");
INSERT INTO "Transcript_Contents" VALUES ("100", "1000");
INSERT INTO "Transcript_Contents" VALUES ("101", "1000");
INSERT INTO "Transcript_Contents" VALUES ("102", "1001");
INSERT INTO "Transcript_Contents" VALUES ("103", "1001");
INSERT INTO "Transcript_Contents" VALUES ("104", "1002");
INSERT INTO "Transcript_Contents" VALUES ("105", "1002");
INSERT INTO "Transcript_Contents" VALUES ("106", "1003");
INSERT INTO "Transcript_Contents" VALUES ("107", "1003");
INSERT INTO "Transcript_Contents" VALUES ("108", "1004");
INSERT INTO "Transcript_Contents" VALUES ("109", "1004");