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,
"AirportName" TEXT,
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", "ABZ", "Aberdeen International Airport");
INSERT INTO "airports" VALUES ("Abilene", "ABI", "Abilene Regional Airport");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport");
INSERT INTO "airports" VALUES ("Tokyo", "NRT", "Narita International Airport");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "OHare International Airport");
INSERT INTO "airports" VALUES ("Dallas", "DFW", "Dallas/Fort Worth International Airport");
INSERT INTO "airports" VALUES ("Houston", "IAH", "George Bush Intercontinental Airport");
INSERT INTO "flights" VALUES ("101", "1", "LHR", "ABZ");
INSERT INTO "flights" VALUES ("101", "2", "JFK", "ABI");
INSERT INTO "flights" VALUES ("102", "3", "CDG", "LHR");
INSERT INTO "flights" VALUES ("103", "4", "NRT", "JFK");
INSERT INTO "flights" VALUES ("104", "5", "LAX", "ABZ");
INSERT INTO "flights" VALUES ("105", "6", "ORD", "ABI");
INSERT INTO "flights" VALUES ("106", "7", "DFW", "LHR");
INSERT INTO "flights" VALUES ("107", "8", "IAH", "CDG");
INSERT INTO "flights" VALUES ("108", "9", "ABZ", "JFK");
INSERT INTO "flights" VALUES ("109", "10", "ABI", "NRT");
INSERT INTO "flights" VALUES ("110", "11", "LHR", "ABI");
INSERT INTO "flights" VALUES ("111", "12", "JFK", "ABZ");
INSERT INTO "flights" VALUES ("112", "13", "CDG", "ABZ");
INSERT INTO "flights" VALUES ("113", "14", "NRT", "ABI");
INSERT INTO "flights" VALUES ("114", "15", "LAX", "LHR");