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 ("Aberdeen", "APG");
INSERT INTO "airports" VALUES ("Baltimore", "BWI");
INSERT INTO "airports" VALUES ("Washington", "IAD");
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 ("Dallas", "DFW");
INSERT INTO "airports" VALUES ("Miami", "MIA");
INSERT INTO "airports" VALUES ("Denver", "DEN");
INSERT INTO "flights" VALUES ("101", "123", "BWI", "APG");
INSERT INTO "flights" VALUES ("101", "124", "IAD", "JFK");
INSERT INTO "flights" VALUES ("102", "200", "JFK", "APG");
INSERT INTO "flights" VALUES ("103", "301", "LAX", "BWI");
INSERT INTO "flights" VALUES ("104", "405", "ORD", "APG");
INSERT INTO "flights" VALUES ("105", "510", "IAH", "DFW");
INSERT INTO "flights" VALUES ("106", "620", "MIA", "APG");
INSERT INTO "flights" VALUES ("107", "730", "DEN", "IAD");
INSERT INTO "flights" VALUES ("108", "840", "APG", "JFK");
INSERT INTO "flights" VALUES ("109", "950", "BWI", "APG");
INSERT INTO "flights" VALUES ("110", "1000", "IAD", "APG");