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,
"semester_id" INT,
"student_id" INT,
PRIMARY KEY ("student_enrolment_id"),
FOREIGN KEY ("student_id") REFERENCES "Students"("student_id")
);

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





INSERT INTO "Addresses" VALUES ("1", "Raleigh", "North Carolina");
INSERT INTO "Addresses" VALUES ("2", "Charlotte", "North Carolina");
INSERT INTO "Addresses" VALUES ("3", "Durham", "North Carolina");
INSERT INTO "Addresses" VALUES ("4", "Atlanta", "Georgia");
INSERT INTO "Addresses" VALUES ("5", "Austin", "Texas");
INSERT INTO "Addresses" VALUES ("6", "Greensboro", "North Carolina");
INSERT INTO "Addresses" VALUES ("7", "Wilmington", "North Carolina");
INSERT INTO "Students" VALUES ("101", "1", "4", "Alice", "Johnson");
INSERT INTO "Students" VALUES ("102", "2", "2", "Bob", "Smith");
INSERT INTO "Students" VALUES ("103", "5", "3", "Charlie", "Williams");
INSERT INTO "Students" VALUES ("104", "6", "6", "Diana", "Brown");
INSERT INTO "Students" VALUES ("105", "7", "7", "Ethan", "Jones");
INSERT INTO "Students" VALUES ("106", "4", "5", "Fiona", "Garcia");
INSERT INTO "Students" VALUES ("107", "3", "1", "George", "Miller");
INSERT INTO "Student_Enrolment" VALUES ("201", "1", "101");
INSERT INTO "Student_Enrolment" VALUES ("202", "2", "103");
INSERT INTO "Student_Enrolment" VALUES ("203", "1", "106");
INSERT INTO "Student_Enrolment" VALUES ("204", "3", "107");