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", "Chapel Hill", "NC");
INSERT INTO "Addresses" VALUES ("5", "Atlanta", "GA");
INSERT INTO "Addresses" VALUES ("6", "New York", "NY");
INSERT INTO "Addresses" VALUES ("7", "Los Angeles", "CA");
INSERT INTO "Addresses" VALUES ("8", "Greensboro", "NC");
INSERT INTO "Addresses" VALUES ("9", "Wilmington", "NC");
INSERT INTO "Addresses" VALUES ("10", "Asheville", "NC");
INSERT INTO "Students" VALUES ("101", "1", "Alice", "Smith");
INSERT INTO "Students" VALUES ("102", "2", "Bob", "Johnson");
INSERT INTO "Students" VALUES ("103", "5", "Charlie", "Brown");
INSERT INTO "Students" VALUES ("104", "3", "Diana", "Miller");
INSERT INTO "Students" VALUES ("105", "6", "Eve", "Davis");
INSERT INTO "Students" VALUES ("106", "4", "Frank", "Garcia");
INSERT INTO "Students" VALUES ("107", "8", "Grace", "Rodriguez");
INSERT INTO "Students" VALUES ("108", "9", "Henry", "Martinez");
INSERT INTO "Students" VALUES ("109", "10", "Ivy", "Hernandez");
INSERT INTO "Students" VALUES ("110", "1", "Jack", "Lopez");
INSERT INTO "Students" VALUES ("111", "2", "Karen", "Gonzalez");
INSERT INTO "Student_Enrolment" VALUES ("1", "1001", "101");
INSERT INTO "Student_Enrolment" VALUES ("2", "1002", "103");
INSERT INTO "Student_Enrolment" VALUES ("3", "1001", "105");
INSERT INTO "Student_Enrolment" VALUES ("4", "1003", "106");
INSERT INTO "Student_Enrolment" VALUES ("5", "1002", "110");
INSERT INTO "Student_Enrolment_Courses" VALUES ("1", "201");
INSERT INTO "Student_Enrolment_Courses" VALUES ("2", "202");
INSERT INTO "Student_Enrolment_Courses" VALUES ("3", "203");
INSERT INTO "Student_Enrolment_Courses" VALUES ("4", "201");
INSERT INTO "Student_Enrolment_Courses" VALUES ("5", "204");
INSERT INTO "Student_Enrolment_Courses" VALUES ("6", "205");
INSERT INTO "Student_Enrolment_Courses" VALUES ("7", "206");
INSERT INTO "Student_Enrolment_Courses" VALUES ("8", "207");
INSERT INTO "Student_Enrolment_Courses" VALUES ("9", "208");
INSERT INTO "Student_Enrolment_Courses" VALUES ("10", "209");