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 "museum" (
"Museum_ID" INT UNIQUE,
"Name" TEXT,
"Open_Year" TEXT,
PRIMARY KEY ("Museum_ID")
);

CREATE TABLE "visit" (
"Museum_ID" INT,
"visitor_ID" TEXT,
"Total_spent" FLOAT,
PRIMARY KEY ("Museum_ID", "visitor_ID"),
FOREIGN KEY ("visitor_ID") REFERENCES "visitor"("ID"),
FOREIGN KEY ("Museum_ID") REFERENCES "museum"("Museum_ID")
);

CREATE TABLE "visitor" (
"ID" INT UNIQUE,
"Name" TEXT,
PRIMARY KEY ("ID")
);





INSERT INTO "museum" VALUES ("1", "Art Gallery", "2005");
INSERT INTO "museum" VALUES ("2", "Science Museum", "2012");
INSERT INTO "museum" VALUES ("3", "History Museum", "1998");
INSERT INTO "museum" VALUES ("4", "Modern Art Museum", "2015");
INSERT INTO "museum" VALUES ("5", "Natural History Museum", "2009");
INSERT INTO "museum" VALUES ("6", "Childrens Museum", "2011");
INSERT INTO "museum" VALUES ("7", "Maritime Museum", "2000");
INSERT INTO "visitor" VALUES ("101", "Alice");
INSERT INTO "visitor" VALUES ("102", "Bob");
INSERT INTO "visitor" VALUES ("103", "Charlie");
INSERT INTO "visitor" VALUES ("104", "David");
INSERT INTO "visitor" VALUES ("105", "Eve");
INSERT INTO "visitor" VALUES ("106", "Frank");
INSERT INTO "visitor" VALUES ("107", "Grace");
INSERT INTO "visitor" VALUES ("108", "Heidi");
INSERT INTO "visit" VALUES ("1", "101", "25.50");
INSERT INTO "visit" VALUES ("3", "101", "15.00");
INSERT INTO "visit" VALUES ("1", "102", "30.00");
INSERT INTO "visit" VALUES ("2", "102", "20.00");
INSERT INTO "visit" VALUES ("3", "103", "10.00");
INSERT INTO "visit" VALUES ("5", "103", "18.75");
INSERT INTO "visit" VALUES ("2", "104", "22.00");
INSERT INTO "visit" VALUES ("4", "104", "35.00");
INSERT INTO "visit" VALUES ("6", "105", "12.50");
INSERT INTO "visit" VALUES ("1", "106", "28.00");
INSERT INTO "visit" VALUES ("3", "106", "16.00");
INSERT INTO "visit" VALUES ("5", "106", "19.00");
INSERT INTO "visit" VALUES ("7", "107", "14.00");
INSERT INTO "visit" VALUES ("2", "108", "21.00");
INSERT INTO "visit" VALUES ("4", "108", "33.00");
INSERT INTO "visit" VALUES ("6", "108", "11.00");