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





INSERT INTO "museum" VALUES ("1", "History Museum", "2005");
INSERT INTO "museum" VALUES ("2", "Modern Art Gallery", "2012");
INSERT INTO "museum" VALUES ("3", "Science Center", "2010");
INSERT INTO "museum" VALUES ("4", "Ancient Artifacts", "1998");
INSERT INTO "museum" VALUES ("5", "Contemporary Exhibits", "2015");
INSERT INTO "museum" VALUES ("6", "Local Heritage", "2008");
INSERT INTO "visitor" VALUES ("101", "Alice Johnson", "2");
INSERT INTO "visitor" VALUES ("102", "Bob Smith", "1");
INSERT INTO "visitor" VALUES ("103", "Carol White", "3");
INSERT INTO "visitor" VALUES ("104", "David Brown", "2");
INSERT INTO "visitor" VALUES ("105", "Eve Davis", "1");
INSERT INTO "visit" VALUES ("1", "101", "25.50");
INSERT INTO "visit" VALUES ("2", "101", "30.00");
INSERT INTO "visit" VALUES ("4", "102", "15.00");
INSERT INTO "visit" VALUES ("5", "102", "40.00");
INSERT INTO "visit" VALUES ("3", "103", "20.00");
INSERT INTO "visit" VALUES ("6", "103", "10.00");
INSERT INTO "visit" VALUES ("1", "104", "18.00");
INSERT INTO "visit" VALUES ("3", "104", "22.00");
INSERT INTO "visit" VALUES ("4", "105", "12.00");
INSERT INTO "visit" VALUES ("5", "105", "35.00");