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 ("213", "CA");
INSERT INTO "AREA_CODE_STATE" VALUES ("212", "NY");
INSERT INTO "AREA_CODE_STATE" VALUES ("305", "FL");
INSERT INTO "AREA_CODE_STATE" VALUES ("312", "IL");
INSERT INTO "AREA_CODE_STATE" VALUES ("415", "CA");
INSERT INTO "AREA_CODE_STATE" VALUES ("617", "MA");
INSERT INTO "AREA_CODE_STATE" VALUES ("702", "NV");
INSERT INTO "AREA_CODE_STATE" VALUES ("206", "WA");
INSERT INTO "AREA_CODE_STATE" VALUES ("503", "OR");
INSERT INTO "AREA_CODE_STATE" VALUES ("404", "GA");
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", "Evan Davis");
INSERT INTO "VOTES" VALUES ("101", "CA", "1", "2024-05-01 08:30:00");
INSERT INTO "VOTES" VALUES ("102", "CA", "2", "2024-05-02 09:45:00");
INSERT INTO "VOTES" VALUES ("103", "NY", "3", "2024-05-01 10:00:00");
INSERT INTO "VOTES" VALUES ("104", "CA", "1", "2024-05-03 11:15:00");
INSERT INTO "VOTES" VALUES ("105", "FL", "4", "2024-05-02 12:00:00");
INSERT INTO "VOTES" VALUES ("106", "CA", "5", "2024-05-03 11:15:00");
INSERT INTO "VOTES" VALUES ("107", "IL", "2", "2024-05-01 13:30:00");
INSERT INTO "VOTES" VALUES ("108", "CA", "3", "2024-05-04 14:45:00");
INSERT INTO "VOTES" VALUES ("109", "CA", "4", "2024-05-04 14:45:00");
INSERT INTO "VOTES" VALUES ("110", "MA", "1", "2024-05-05 15:00:00");
INSERT INTO "VOTES" VALUES ("111", "CA", "2", "2024-05-05 16:00:00");
INSERT INTO "VOTES" VALUES ("112", "CA", "3", "2024-05-05 16:00:00");
INSERT INTO "VOTES" VALUES ("113", "NV", "5", "2024-05-06 17:30:00");
INSERT INTO "VOTES" VALUES ("114", "CA", "1", "2024-05-06 18:00:00");
INSERT INTO "VOTES" VALUES ("115", "CA", "4", "2024-05-06 18:00:00");
INSERT INTO "VOTES" VALUES ("116", "WA", "2", "2024-05-07 19:00:00");
INSERT INTO "VOTES" VALUES ("117", "OR", "3", "2024-05-07 20:00:00");
INSERT INTO "VOTES" VALUES ("118", "CA", "5", "2024-05-07 21:00:00");
INSERT INTO "VOTES" VALUES ("119", "CA", "1", "2024-05-07 21:00:00");
INSERT INTO "VOTES" VALUES ("120", "GA", "4", "2024-05-08 22:00:00");