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,
"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 ("212", "NY");
INSERT INTO "AREA_CODE_STATE" VALUES ("213", "CA");
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 "AREA_CODE_STATE" VALUES ("404", "GA");
INSERT INTO "AREA_CODE_STATE" VALUES ("206", "WA");
INSERT INTO "AREA_CODE_STATE" VALUES ("702", "NV");
INSERT INTO "AREA_CODE_STATE" VALUES ("503", "OR");
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", "2125551234", "NY", "1");
INSERT INTO "VOTES" VALUES ("102", "2135555678", "CA", "2");
INSERT INTO "VOTES" VALUES ("103", "3125559012", "IL", "3");
INSERT INTO "VOTES" VALUES ("104", "4155553456", "CA", "1");
INSERT INTO "VOTES" VALUES ("105", "6175557890", "MA", "4");
INSERT INTO "VOTES" VALUES ("106", "3055552345", "FL", "5");
INSERT INTO "VOTES" VALUES ("107", "4045556789", "GA", "2");
INSERT INTO "VOTES" VALUES ("108", "2065550123", "WA", "3");
INSERT INTO "VOTES" VALUES ("109", "7025554567", "NV", "4");
INSERT INTO "VOTES" VALUES ("110", "5035558901", "OR", "5");
INSERT INTO "VOTES" VALUES ("111", "2125554321", "NY", "2");
INSERT INTO "VOTES" VALUES ("112", "2135558765", "CA", "3");
INSERT INTO "VOTES" VALUES ("113", "3125552109", "IL", "1");
INSERT INTO "VOTES" VALUES ("114", "4155556543", "CA", "5");
INSERT INTO "VOTES" VALUES ("115", "6175550987", "MA", "2");
INSERT INTO "VOTES" VALUES ("116", "3055553456", "FL", "3");
INSERT INTO "VOTES" VALUES ("117", "4045557890", "GA", "1");
INSERT INTO "VOTES" VALUES ("118", "2065551234", "WA", "5");
INSERT INTO "VOTES" VALUES ("119", "7025555678", "NV", "3");
INSERT INTO "VOTES" VALUES ("120", "5035559012", "OR", "4");