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,
"Country" 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", "United Kingdom");
INSERT INTO "airports" VALUES ("Abilene", "ABI", "Abilene Regional Airport", "United States");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport", "United States");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "Los Angeles International Airport", "United States");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport", "United Kingdom");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "O'Hare International Airport", "United States");
INSERT INTO "airports" VALUES ("Dallas", "DFW", "Dallas/Fort Worth International Airport", "United States");
INSERT INTO "airports" VALUES ("Houston", "IAH", "George Bush Intercontinental Airport", "United States");
INSERT INTO "airports" VALUES ("Denver", "DEN", "Denver International Airport", "United States");
INSERT INTO "airports" VALUES ("Miami", "MIA", "Miami International Airport", "United States");
INSERT INTO "flights" VALUES ("1", "101", "JFK", "ABZ");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "ABI");
INSERT INTO "flights" VALUES ("2", "201", "LHR", "ABZ");
INSERT INTO "flights" VALUES ("2", "202", "ORD", "ABI");
INSERT INTO "flights" VALUES ("3", "301", "DFW", "MIA");
INSERT INTO "flights" VALUES ("3", "302", "IAH", "DEN");
INSERT INTO "flights" VALUES ("4", "401", "DEN", "ABZ");
INSERT INTO "flights" VALUES ("4", "402", "MIA", "ABI");
INSERT INTO "flights" VALUES ("5", "501", "ABZ", "LHR");
INSERT INTO "flights" VALUES ("5", "502", "ABI", "JFK");
INSERT INTO "flights" VALUES ("6", "601", "ORD", "LAX");
INSERT INTO "flights" VALUES ("6", "602", "LAX", "ORD");
INSERT INTO "flights" VALUES ("7", "701", "JFK", "LHR");
INSERT INTO "flights" VALUES ("7", "702", "LHR", "JFK");
INSERT INTO "flights" VALUES ("8", "801", "MIA", "DFW");
INSERT INTO "flights" VALUES ("8", "802", "DFW", "MIA");