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,
"line_1" VARCHAR(255),
"line_2" VARCHAR(255),
"line_3" VARCHAR(255),
"city" VARCHAR(255),
"zip_postcode" VARCHAR(20),
"state_province_county" VARCHAR(255),
"country" VARCHAR(255),
"other_address_details" VARCHAR(255),
PRIMARY KEY ("address_id")
);

CREATE TABLE "Degree_Programs" (
"degree_program_id" INT,
"degree_summary_name" VARCHAR(255),
PRIMARY KEY ("degree_program_id")
);

CREATE TABLE "Student_Enrolment" (
"student_enrolment_id" INT,
"degree_program_id" INT,
"semester_id" INT,
PRIMARY KEY ("student_enrolment_id"),
FOREIGN KEY ("degree_program_id") REFERENCES "Degree_Programs"("degree_program_id")
);

CREATE TABLE "Students" (
"student_id" INT UNIQUE,
"current_address_id" INT,
"permanent_address_id" INT,
"first_name" VARCHAR(80),
"middle_name" VARCHAR(40),
"last_name" VARCHAR(40),
"cell_mobile_number" VARCHAR(40),
"email_address" VARCHAR(40),
"ssn" VARCHAR(40),
"date_first_registered" DATETIME,
"date_left" DATETIME,
"other_student_details" VARCHAR(255),
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", "123 Maple St", "", "", "Springfield", "01101", "MA", "USA", "Near the old library");
INSERT INTO "Addresses" VALUES ("2", "456 Oak Ave", "Apt 5B", "", "Shelbyville", "02202", "MA", "USA", "Opposite the park");
INSERT INTO "Addresses" VALUES ("3", "789 Pine Rd", "", "Suite 12", "Capital City", "03303", "MA", "USA", "Next to the museum");
INSERT INTO "Addresses" VALUES ("4", "321 Birch Blvd", "", "", "Ogdenville", "04404", "MA", "USA", "Close to the river");
INSERT INTO "Addresses" VALUES ("5", "654 Cedar Ln", "Floor 3", "", "North Haverbrook", "05505", "MA", "USA", "Beside the post office");
INSERT INTO "Degree_Programs" VALUES ("1", "Computer Science");
INSERT INTO "Degree_Programs" VALUES ("2", "Mechanical Engineering");
INSERT INTO "Degree_Programs" VALUES ("3", "Business Administration");
INSERT INTO "Student_Enrolment" VALUES ("1", "1", "202101");
INSERT INTO "Student_Enrolment" VALUES ("2", "2", "202102");
INSERT INTO "Student_Enrolment" VALUES ("3", "3", "202103");
INSERT INTO "Student_Enrolment" VALUES ("4", "1", "202104");
INSERT INTO "Student_Enrolment" VALUES ("5", "2", "202105");
INSERT INTO "Students" VALUES ("101", "1", "2", "Alice", "M", "Zimmerman", "555-1234", "alice.z@example.com", "123-45-6789", "2020-08-15 09:00:00", "NULL", "Prefers evening classes");
INSERT INTO "Students" VALUES ("102", "2", "3", "Bob", "J", "Young", "555-2345", "bob.y@example.com", "987-65-4321", "2019-01-10 10:30:00", "2023-05-20 15:00:00", "Transferred to another university");
INSERT INTO "Students" VALUES ("103", "3", "1", "Charlie", "K", "Xavier", "555-3456", "charlie.x@example.com", "111-22-3333", "2021-09-01 08:45:00", "NULL", "Part-time student");
INSERT INTO "Students" VALUES ("104", "4", "4", "Diana", "L", "Williams", "555-4567", "diana.w@example.com", "444-55-6666", "2018-06-20 11:15:00", "NULL", "On scholarship");
INSERT INTO "Students" VALUES ("105", "5", "5", "Ethan", "N", "Vasquez", "555-5678", "ethan.v@example.com", "777-88-9999", "2022-02-28 14:00:00", "NULL", "International student from Spain");