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 UNIQUE,
"contestant_name" VARCHAR(50),
PRIMARY KEY ("contestant_number")
);

CREATE TABLE "VOTES" (
"vote_id" INT,
"phone_number" INT,
"state" VARCHAR(2),
"contestant_number" INT,
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 ("312", "IL");
INSERT INTO "AREA_CODE_STATE" VALUES ("415", "CA");
INSERT INTO "AREA_CODE_STATE" VALUES ("617", "MA");
INSERT INTO "AREA_CODE_STATE" VALUES ("305", "FL");
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 ("1", "2015551234", "NY", "1");
INSERT INTO "VOTES" VALUES ("2", "2015555678", "NY", "1");
INSERT INTO "VOTES" VALUES ("3", "3125554321", "IL", "2");
INSERT INTO "VOTES" VALUES ("4", "4155558765", "CA", "3");
INSERT INTO "VOTES" VALUES ("5", "4155554321", "CA", "3");
INSERT INTO "VOTES" VALUES ("6", "6175551111", "MA", "4");
INSERT INTO "VOTES" VALUES ("7", "3055552222", "FL", "5");
INSERT INTO "VOTES" VALUES ("8", "3055553333", "FL", "5");
INSERT INTO "VOTES" VALUES ("9", "3055554444", "FL", "5");
INSERT INTO "VOTES" VALUES ("10", "3125559999", "IL", "2");
INSERT INTO "VOTES" VALUES ("11", "6175552222", "MA", "4");
INSERT INTO "VOTES" VALUES ("12", "2015559999", "NY", "1");