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 "Addresses" (
"address_id" INT UNIQUE,
"city" VARCHAR(255),
"state_province_county" VARCHAR(255),
PRIMARY KEY ("address_id")
);

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

CREATE TABLE "Students" (
"student_id" INT UNIQUE,
"current_address_id" INT,
"first_name" VARCHAR(80),
"last_name" VARCHAR(40),
PRIMARY KEY ("student_id"),
FOREIGN KEY ("current_address_id") REFERENCES "Addresses"("address_id")
);





INSERT INTO "Addresses" VALUES ("1", "Raleigh", "NC");
INSERT INTO "Addresses" VALUES ("2", "Charlotte", "NC");
INSERT INTO "Addresses" VALUES ("3", "Durham", "NC");
INSERT INTO "Addresses" VALUES ("4", "Atlanta", "GA");
INSERT INTO "Addresses" VALUES ("5", "Richmond", "VA");
INSERT INTO "Addresses" VALUES ("6", "Chapel Hill", "NC");
INSERT INTO "Addresses" VALUES ("7", "Greensboro", "NC");
INSERT INTO "Student_Enrolment" VALUES ("101", "1", "1");
INSERT INTO "Student_Enrolment" VALUES ("102", "2", "2");
INSERT INTO "Student_Enrolment" VALUES ("103", "1", "4");
INSERT INTO "Student_Enrolment" VALUES ("104", "3", "5");
INSERT INTO "Student_Enrolment" VALUES ("105", "2", "7");
INSERT INTO "Student_Enrolment_Courses" VALUES ("201", "1001");
INSERT INTO "Student_Enrolment_Courses" VALUES ("202", "1002");
INSERT INTO "Student_Enrolment_Courses" VALUES ("203", "1003");
INSERT INTO "Student_Enrolment_Courses" VALUES ("204", "1004");
INSERT INTO "Student_Enrolment_Courses" VALUES ("205", "1005");
INSERT INTO "Students" VALUES ("1", "1", "Alice", "Smith");
INSERT INTO "Students" VALUES ("2", "2", "Bob", "Johnson");
INSERT INTO "Students" VALUES ("3", "3", "Charlie", "Brown");
INSERT INTO "Students" VALUES ("4", "4", "Diana", "Prince");
INSERT INTO "Students" VALUES ("5", "5", "Eve", "Adams");
INSERT INTO "Students" VALUES ("6", "6", "Frank", "White");
INSERT INTO "Students" VALUES ("7", "7", "Grace", "Taylor");
INSERT INTO "Students" VALUES ("8", "1", "Henry", "Miller");
INSERT INTO "Students" VALUES ("9", "2", "Ivy", "Davis");
INSERT INTO "Students" VALUES ("10", "3", "Jack", "Wilson");