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,
"Age" INT,
"Sex" VARCHAR(1),
"Major" INT,
"city_code" VARCHAR(3),
PRIMARY KEY ("StuID")
);





INSERT INTO "Student" VALUES ("1", "20", "M", "101", "NYC");
INSERT INTO "Student" VALUES ("2", "22", "F", "102", "LAX");
INSERT INTO "Student" VALUES ("3", "19", "M", "103", "CHI");
INSERT INTO "Student" VALUES ("4", "21", "F", "101", "NYC");
INSERT INTO "Student" VALUES ("5", "23", "M", "104", "HOU");
INSERT INTO "Student" VALUES ("6", "20", "F", "102", "LAX");
INSERT INTO "Student" VALUES ("7", "22", "M", "105", "PHX");
INSERT INTO "Student" VALUES ("8", "24", "F", "103", "CHI");
INSERT INTO "Student" VALUES ("9", "21", "M", "101", "NYC");
INSERT INTO "Student" VALUES ("10", "20", "F", "104", "HOU");
INSERT INTO "Pets" VALUES ("1", "dog", "3");
INSERT INTO "Pets" VALUES ("2", "cat", "2");
INSERT INTO "Pets" VALUES ("3", "parrot", "1");
INSERT INTO "Pets" VALUES ("4", "rabbit", "4");
INSERT INTO "Pets" VALUES ("5", "cat", "5");
INSERT INTO "Pets" VALUES ("6", "dog", "2");
INSERT INTO "Pets" VALUES ("7", "hamster", "1");
INSERT INTO "Pets" VALUES ("8", "cat", "3");
INSERT INTO "Pets" VALUES ("9", "fish", "1");
INSERT INTO "Pets" VALUES ("10", "dog", "4");
INSERT INTO "Has_Pet" VALUES ("1", "1");
INSERT INTO "Has_Pet" VALUES ("2", "2");
INSERT INTO "Has_Pet" VALUES ("3", "3");
INSERT INTO "Has_Pet" VALUES ("4", "4");
INSERT INTO "Has_Pet" VALUES ("5", "5");
INSERT INTO "Has_Pet" VALUES ("6", "6");
INSERT INTO "Has_Pet" VALUES ("7", "7");
INSERT INTO "Has_Pet" VALUES ("8", "8");
INSERT INTO "Has_Pet" VALUES ("9", "9");
INSERT INTO "Has_Pet" VALUES ("10", "10");
INSERT INTO "Has_Pet" VALUES ("1", "9");
INSERT INTO "Has_Pet" VALUES ("3", "2");
INSERT INTO "Has_Pet" VALUES ("7", "1");