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,
"Level_of_membership" INT,
PRIMARY KEY ("ID")
);





INSERT INTO "museum" VALUES ("1", "History Museum", "2005");
INSERT INTO "museum" VALUES ("2", "Modern Art Museum", "2012");
INSERT INTO "museum" VALUES ("3", "Science Center", "2010");
INSERT INTO "museum" VALUES ("4", "Children's Museum", "2015");
INSERT INTO "museum" VALUES ("5", "Natural History Museum", "2000");
INSERT INTO "visitor" VALUES ("101", "1");
INSERT INTO "visitor" VALUES ("102", "2");
INSERT INTO "visitor" VALUES ("103", "3");
INSERT INTO "visitor" VALUES ("104", "1");
INSERT INTO "visitor" VALUES ("105", "2");
INSERT INTO "visitor" VALUES ("106", "3");
INSERT INTO "visitor" VALUES ("107", "1");
INSERT INTO "visitor" VALUES ("108", "2");
INSERT INTO "visit" VALUES ("1", "101", "15.0");
INSERT INTO "visit" VALUES ("3", "101", "20.0");
INSERT INTO "visit" VALUES ("5", "102", "10.0");
INSERT INTO "visit" VALUES ("1", "103", "5.0");
INSERT INTO "visit" VALUES ("5", "103", "7.5");
INSERT INTO "visit" VALUES ("2", "104", "12.0");
INSERT INTO "visit" VALUES ("4", "104", "18.0");
INSERT INTO "visit" VALUES ("2", "105", "25.0");
INSERT INTO "visit" VALUES ("4", "106", "30.0");
INSERT INTO "visit" VALUES ("3", "107", "8.0");
INSERT INTO "visit" VALUES ("5", "108", "9.0");