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 "AREA_CODE_STATE" (
"area_code" INT,
"state" VARCHAR(2) UNIQUE,
PRIMARY KEY ("area_code")
);

CREATE TABLE "CONTESTANTS" (
"contestant_number" INT,
"contestant_name" VARCHAR(50),
PRIMARY KEY ("contestant_number")
);

CREATE TABLE "VOTES" (
"vote_id" INT,
"state" VARCHAR(2),
"contestant_number" INT,
"created" TIMESTAMP,
PRIMARY KEY ("vote_id"),
FOREIGN KEY ("contestant_number") REFERENCES "CONTESTANTS"("contestant_number"),
FOREIGN KEY ("state") REFERENCES "AREA_CODE_STATE"("state")
);





INSERT INTO "AREA_CODE_STATE" VALUES ("201", "NY");
INSERT INTO "AREA_CODE_STATE" VALUES ("202", "DC");
INSERT INTO "AREA_CODE_STATE" VALUES ("203", "CT");
INSERT INTO "AREA_CODE_STATE" VALUES ("204", "WI");
INSERT INTO "AREA_CODE_STATE" VALUES ("205", "AL");
INSERT INTO "AREA_CODE_STATE" VALUES ("206", "WA");
INSERT INTO "AREA_CODE_STATE" VALUES ("207", "ME");
INSERT INTO "AREA_CODE_STATE" VALUES ("208", "ID");
INSERT INTO "AREA_CODE_STATE" VALUES ("209", "CA");
INSERT INTO "AREA_CODE_STATE" VALUES ("210", "TX");
INSERT INTO "CONTESTANTS" VALUES ("1", "Alice Johnson");
INSERT INTO "CONTESTANTS" VALUES ("2", "Bob Smith");
INSERT INTO "CONTESTANTS" VALUES ("3", "Charlie Lee");
INSERT INTO "CONTESTANTS" VALUES ("4", "Diana Prince");
INSERT INTO "CONTESTANTS" VALUES ("5", "Ethan Hunt");
INSERT INTO "VOTES" VALUES ("101", "NY", "1", "2024-06-01 08:15:00");
INSERT INTO "VOTES" VALUES ("102", "NY", "2", "2024-06-01 08:20:00");
INSERT INTO "VOTES" VALUES ("103", "DC", "3", "2024-06-01 09:00:00");
INSERT INTO "VOTES" VALUES ("104", "CT", "1", "2024-06-01 09:30:00");
INSERT INTO "VOTES" VALUES ("105", "WI", "4", "2024-06-01 10:00:00");
INSERT INTO "VOTES" VALUES ("106", "AL", "5", "2024-06-01 10:15:00");
INSERT INTO "VOTES" VALUES ("107", "WA", "2", "2024-06-01 11:00:00");
INSERT INTO "VOTES" VALUES ("108", "ME", "3", "2024-06-01 11:30:00");
INSERT INTO "VOTES" VALUES ("109", "ID", "1", "2024-06-01 12:00:00");
INSERT INTO "VOTES" VALUES ("110", "CA", "4", "2024-06-01 12:15:00");
INSERT INTO "VOTES" VALUES ("111", "TX", "5", "2024-06-01 12:30:00");
INSERT INTO "VOTES" VALUES ("112", "NY", "3", "2024-06-01 13:00:00");
INSERT INTO "VOTES" VALUES ("113", "DC", "2", "2024-06-01 13:15:00");
INSERT INTO "VOTES" VALUES ("114", "CT", "5", "2024-06-01 13:30:00");
INSERT INTO "VOTES" VALUES ("115", "WI", "1", "2024-06-01 14:00:00");
INSERT INTO "VOTES" VALUES ("116", "AL", "4", "2024-06-01 14:15:00");
INSERT INTO "VOTES" VALUES ("117", "WA", "3", "2024-06-01 14:30:00");
INSERT INTO "VOTES" VALUES ("118", "ME", "2", "2024-06-01 15:00:00");
INSERT INTO "VOTES" VALUES ("119", "ID", "5", "2024-06-01 15:15:00");
INSERT INTO "VOTES" VALUES ("120", "CA", "1", "2024-06-01 15:30:00");