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

CREATE TABLE "visit" (
"Museum_ID" INT,
"visitor_ID" TEXT,
"Num_of_Ticket" INT,
"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 ("101", "2005");
INSERT INTO "museum" VALUES ("102", "2010");
INSERT INTO "museum" VALUES ("103", "2012");
INSERT INTO "museum" VALUES ("104", "2008");
INSERT INTO "museum" VALUES ("105", "2015");
INSERT INTO "museum" VALUES ("106", "2007");
INSERT INTO "museum" VALUES ("107", "2013");
INSERT INTO "museum" VALUES ("108", "2000");
INSERT INTO "museum" VALUES ("109", "2018");
INSERT INTO "museum" VALUES ("110", "2006");
INSERT INTO "visitor" VALUES ("1", "Alice", "1");
INSERT INTO "visitor" VALUES ("2", "Bob", "2");
INSERT INTO "visitor" VALUES ("3", "Charlie", "1");
INSERT INTO "visitor" VALUES ("4", "David", "3");
INSERT INTO "visitor" VALUES ("5", "Eve", "2");
INSERT INTO "visitor" VALUES ("6", "Frank", "1");
INSERT INTO "visitor" VALUES ("7", "Grace", "3");
INSERT INTO "visitor" VALUES ("8", "Heidi", "2");
INSERT INTO "visitor" VALUES ("9", "Ivan", "1");
INSERT INTO "visitor" VALUES ("10", "Judy", "3");
INSERT INTO "visit" VALUES ("101", "1", "2", "25.00");
INSERT INTO "visit" VALUES ("103", "1", "1", "15.00");
INSERT INTO "visit" VALUES ("104", "2", "3", "30.00");
INSERT INTO "visit" VALUES ("105", "2", "2", "20.00");
INSERT INTO "visit" VALUES ("101", "3", "1", "12.50");
INSERT INTO "visit" VALUES ("102", "3", "2", "22.00");
INSERT INTO "visit" VALUES ("106", "4", "4", "40.00");
INSERT INTO "visit" VALUES ("107", "4", "1", "18.00");
INSERT INTO "visit" VALUES ("108", "5", "2", "28.00");
INSERT INTO "visit" VALUES ("109", "5", "3", "35.00");
INSERT INTO "visit" VALUES ("101", "6", "1", "10.00");
INSERT INTO "visit" VALUES ("103", "6", "2", "20.00");
INSERT INTO "visit" VALUES ("104", "7", "1", "15.00");
INSERT INTO "visit" VALUES ("105", "7", "1", "15.00");
INSERT INTO "visit" VALUES ("106", "8", "2", "25.00");
INSERT INTO "visit" VALUES ("107", "8", "2", "25.00");
INSERT INTO "visit" VALUES ("108", "9", "3", "30.00");
INSERT INTO "visit" VALUES ("109", "9", "1", "10.00");
INSERT INTO "visit" VALUES ("101", "10", "2", "20.00");
INSERT INTO "visit" VALUES ("102", "10", "1", "10.00");
INSERT INTO "visit" VALUES ("103", "10", "1", "10.00");
INSERT INTO "visit" VALUES ("104", "1", "1", "10.00");
INSERT INTO "visit" VALUES ("105", "1", "1", "10.00");
INSERT INTO "visit" VALUES ("106", "2", "1", "10.00");
INSERT INTO "visit" VALUES ("107", "2", "1", "10.00");
INSERT INTO "visit" VALUES ("108", "3", "1", "10.00");
INSERT INTO "visit" VALUES ("109", "3", "1", "10.00");