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 "Has_Pet" (
"StuID" INT,
"PetID" INT,
FOREIGN KEY ("PetID") REFERENCES "Pets"("PetID"),
FOREIGN KEY ("StuID") REFERENCES "Student"("StuID")
);

CREATE TABLE "Pets" (
"PetID" INT UNIQUE,
"PetType" VARCHAR(20),
"pet_age" INT,
PRIMARY KEY ("PetID")
);

CREATE TABLE "Student" (
"StuID" INT UNIQUE,
"Fname" VARCHAR(12),
"Age" INT,
"Sex" VARCHAR(1),
"city_code" VARCHAR(3),
PRIMARY KEY ("StuID")
);





INSERT INTO "Pets" VALUES ("1", "dog", "3");
INSERT INTO "Pets" VALUES ("2", "cat", "2");
INSERT INTO "Pets" VALUES ("3", "dog", "5");
INSERT INTO "Pets" VALUES ("4", "cat", "4");
INSERT INTO "Pets" VALUES ("5", "parrot", "1");
INSERT INTO "Pets" VALUES ("6", "dog", "7");
INSERT INTO "Pets" VALUES ("7", "hamster", "1");
INSERT INTO "Pets" VALUES ("8", "cat", "3");
INSERT INTO "Pets" VALUES ("9", "dog", "2");
INSERT INTO "Pets" VALUES ("10", "rabbit", "4");
INSERT INTO "Student" VALUES ("101", "Alice", "20", "F", "NYC");
INSERT INTO "Student" VALUES ("102", "Bob", "22", "M", "LAX");
INSERT INTO "Student" VALUES ("103", "Charlie", "19", "M", "NYC");
INSERT INTO "Student" VALUES ("104", "Diana", "21", "F", "CHI");
INSERT INTO "Student" VALUES ("105", "Ethan", "23", "M", "LAX");
INSERT INTO "Student" VALUES ("106", "Fiona", "20", "F", "NYC");
INSERT INTO "Student" VALUES ("107", "George", "22", "M", "CHI");
INSERT INTO "Student" VALUES ("108", "Hannah", "19", "F", "LAX");
INSERT INTO "Student" VALUES ("109", "Ian", "21", "M", "NYC");
INSERT INTO "Student" VALUES ("110", "Jane", "23", "F", "CHI");
INSERT INTO "Has_Pet" VALUES ("101", "1");
INSERT INTO "Has_Pet" VALUES ("101", "5");
INSERT INTO "Has_Pet" VALUES ("102", "2");
INSERT INTO "Has_Pet" VALUES ("102", "3");
INSERT INTO "Has_Pet" VALUES ("103", "3");
INSERT INTO "Has_Pet" VALUES ("104", "4");
INSERT INTO "Has_Pet" VALUES ("105", "6");
INSERT INTO "Has_Pet" VALUES ("105", "2");
INSERT INTO "Has_Pet" VALUES ("106", "9");
INSERT INTO "Has_Pet" VALUES ("107", "7");
INSERT INTO "Has_Pet" VALUES ("108", "8");
INSERT INTO "Has_Pet" VALUES ("109", "1");
INSERT INTO "Has_Pet" VALUES ("110", "10");