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,
"PetType" VARCHAR(20),
"pet_age" INT,
PRIMARY KEY ("PetID")
);

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





INSERT INTO "Student" VALUES ("1", "Alice", "20", "F");
INSERT INTO "Student" VALUES ("2", "Bob", "22", "M");
INSERT INTO "Student" VALUES ("3", "Charlie", "19", "M");
INSERT INTO "Student" VALUES ("4", "Diana", "21", "F");
INSERT INTO "Student" VALUES ("5", "Eve", "23", "F");
INSERT INTO "Student" VALUES ("6", "Frank", "20", "M");
INSERT INTO "Pets" VALUES ("101", "Dog", "3");
INSERT INTO "Pets" VALUES ("102", "Cat", "2");
INSERT INTO "Pets" VALUES ("103", "Parrot", "1");
INSERT INTO "Pets" VALUES ("104", "Hamster", "1");
INSERT INTO "Pets" VALUES ("105", "Fish", "1");
INSERT INTO "Pets" VALUES ("106", "Rabbit", "4");
INSERT INTO "Pets" VALUES ("107", "Dog", "5");
INSERT INTO "Pets" VALUES ("108", "Cat", "3");
INSERT INTO "Has_Pet" VALUES ("1", "101");
INSERT INTO "Has_Pet" VALUES ("1", "102");
INSERT INTO "Has_Pet" VALUES ("2", "103");
INSERT INTO "Has_Pet" VALUES ("3", "104");
INSERT INTO "Has_Pet" VALUES ("3", "105");
INSERT INTO "Has_Pet" VALUES ("3", "106");
INSERT INTO "Has_Pet" VALUES ("4", "107");
INSERT INTO "Has_Pet" VALUES ("5", "108");
INSERT INTO "Has_Pet" VALUES ("6", "101");
INSERT INTO "Has_Pet" VALUES ("6", "103");