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 "airports" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
PRIMARY KEY ("AirportCode")
);

CREATE TABLE "flights" (
"Airline" INT,
"FlightNo" INT,
"SourceAirport" TEXT,
"DestAirport" TEXT,
PRIMARY KEY ("Airline", "FlightNo"),
FOREIGN KEY ("SourceAirport") REFERENCES "airports"("AirportCode"),
FOREIGN KEY ("DestAirport") REFERENCES "airports"("AirportCode")
);





INSERT INTO "airports" VALUES ("New York", "JFK");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX");
INSERT INTO "airports" VALUES ("Chicago", "ORD");
INSERT INTO "airports" VALUES ("Houston", "IAH");
INSERT INTO "airports" VALUES ("Atlanta", "ATL");
INSERT INTO "airports" VALUES ("Baltimore", "APG");
INSERT INTO "airports" VALUES ("Dallas", "DFW");
INSERT INTO "airports" VALUES ("Denver", "DEN");
INSERT INTO "airports" VALUES ("Miami", "MIA");
INSERT INTO "airports" VALUES ("Seattle", "SEA");
INSERT INTO "flights" VALUES ("101", "1001", "JFK", "LAX");
INSERT INTO "flights" VALUES ("101", "1002", "LAX", "JFK");
INSERT INTO "flights" VALUES ("102", "2001", "ORD", "APG");
INSERT INTO "flights" VALUES ("103", "3001", "IAH", "ATL");
INSERT INTO "flights" VALUES ("102", "2002", "APG", "ORD");
INSERT INTO "flights" VALUES ("104", "4001", "DFW", "APG");
INSERT INTO "flights" VALUES ("105", "5001", "DEN", "MIA");
INSERT INTO "flights" VALUES ("104", "4002", "APG", "DFW");
INSERT INTO "flights" VALUES ("106", "6001", "SEA", "JFK");
INSERT INTO "flights" VALUES ("102", "2003", "ATL", "APG");
INSERT INTO "flights" VALUES ("107", "7001", "JFK", "APG");
INSERT INTO "flights" VALUES ("108", "8001", "LAX", "APG");
INSERT INTO "flights" VALUES ("109", "9001", "ORD", "LAX");