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", "CA");
INSERT INTO "AREA_CODE_STATE" VALUES ("202", "NY");
INSERT INTO "AREA_CODE_STATE" VALUES ("203", "TX");
INSERT INTO "AREA_CODE_STATE" VALUES ("204", "FL");
INSERT INTO "AREA_CODE_STATE" VALUES ("205", "NV");
INSERT INTO "AREA_CODE_STATE" VALUES ("206", "WA");
INSERT INTO "AREA_CODE_STATE" VALUES ("207", "OR");
INSERT INTO "AREA_CODE_STATE" VALUES ("208", "NM");
INSERT INTO "AREA_CODE_STATE" VALUES ("209", "AZ");
INSERT INTO "AREA_CODE_STATE" VALUES ("210", "UT");
INSERT INTO "AREA_CODE_STATE" VALUES ("211", "MT");
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 "VOTES" VALUES ("1", "CA", "1", "2024-06-01 10:00:00");
INSERT INTO "VOTES" VALUES ("2", "CA", "2", "2024-06-01 10:00:00");
INSERT INTO "VOTES" VALUES ("3", "CA", "3", "2024-06-02 09:59:59");
INSERT INTO "VOTES" VALUES ("4", "CA", "1", "2024-06-02 10:00:00");
INSERT INTO "VOTES" VALUES ("5", "CA", "4", "2024-06-02 10:00:00");
INSERT INTO "VOTES" VALUES ("6", "NY", "2", "2024-05-30 15:00:00");
INSERT INTO "VOTES" VALUES ("7", "TX", "3", "2024-06-01 12:00:00");
INSERT INTO "VOTES" VALUES ("8", "FL", "4", "2024-06-01 12:00:01");
INSERT INTO "VOTES" VALUES ("9", "NV", "1", "2024-06-01 08:00:00");
INSERT INTO "VOTES" VALUES ("10", "WA", "2", "2024-06-01 09:00:00");
INSERT INTO "VOTES" VALUES ("11", "OR", "3", "2024-06-01 11:00:00");
INSERT INTO "VOTES" VALUES ("12", "NM", "4", "2024-06-01 13:00:00");
INSERT INTO "VOTES" VALUES ("13", "AZ", "1", "2024-06-01 14:00:00");
INSERT INTO "VOTES" VALUES ("14", "UT", "2", "2024-06-01 15:00:00");