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,
"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 ("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 "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 "CONTESTANTS" VALUES ("6", "Fiona Green");
INSERT INTO "CONTESTANTS" VALUES ("7", "George Hall");
INSERT INTO "VOTES" VALUES ("1", "NY", "1");
INSERT INTO "VOTES" VALUES ("2", "NY", "2");
INSERT INTO "VOTES" VALUES ("3", "DC", "1");
INSERT INTO "VOTES" VALUES ("4", "CT", "2");
INSERT INTO "VOTES" VALUES ("5", "WI", "1");
INSERT INTO "VOTES" VALUES ("6", "AL", "4");
INSERT INTO "VOTES" VALUES ("7", "AL", "4");
INSERT INTO "VOTES" VALUES ("8", "DC", "2");
INSERT INTO "VOTES" VALUES ("9", "CT", "1");
INSERT INTO "VOTES" VALUES ("10", "WI", "2");