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 ("London", "LHR", "Heathrow Airport", "UK");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport", "USA");
INSERT INTO "airports" VALUES ("Tokyo", "NRT", "Narita International Airport", "Japan");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "Dubai International Airport", "UAE");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Frankfurt Airport", "Germany");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Sydney Airport", "Australia");
INSERT INTO "airports" VALUES ("Beijing", "PEK", "Beijing Capital International Airport", "China");
INSERT INTO "airports" VALUES ("Rome", "FCO", "Leonardo da Vinci–Fiumicino Airport", "Italy");
INSERT INTO "airports" VALUES ("Madrid", "MAD", "Adolfo Suárez Madrid–Barajas Airport", "Spain");
INSERT INTO "airports" VALUES ("Cairo", "CAI", "Cairo International Airport", "Egypt");
INSERT INTO "airports" VALUES ("Oslo", "OSL", "Oslo Airport, Gardermoen", "Norway");
INSERT INTO "airports" VALUES ("Zurich", "ZRH", "Zurich Airport", "Switzerland");
INSERT INTO "airports" VALUES ("Dublin", "DUB", "Dublin Airport", "Ireland");
INSERT INTO "airports" VALUES ("Lisbon", "LIS", "Lisbon Airport", "Portugal");
INSERT INTO "flights" VALUES ("101", "1", "LHR", "CDG");
INSERT INTO "flights" VALUES ("101", "2", "CDG", "LHR");
INSERT INTO "flights" VALUES ("202", "3", "JFK", "NRT");
INSERT INTO "flights" VALUES ("202", "4", "NRT", "JFK");
INSERT INTO "flights" VALUES ("303", "5", "DXB", "FRA");
INSERT INTO "flights" VALUES ("303", "6", "FRA", "DXB");
INSERT INTO "flights" VALUES ("404", "7", "SYD", "PEK");
INSERT INTO "flights" VALUES ("404", "8", "PEK", "SYD");
INSERT INTO "flights" VALUES ("505", "9", "LHR", "JFK");
INSERT INTO "flights" VALUES ("505", "10", "JFK", "LHR");
INSERT INTO "flights" VALUES ("606", "11", "CDG", "DXB");
INSERT INTO "flights" VALUES ("606", "12", "DXB", "CDG");
INSERT INTO "flights" VALUES ("707", "13", "NRT", "FRA");
INSERT INTO "flights" VALUES ("707", "14", "FRA", "NRT");
INSERT INTO "flights" VALUES ("808", "15", "SYD", "LHR");
INSERT INTO "flights" VALUES ("808", "16", "LHR", "SYD");
INSERT INTO "flights" VALUES ("909", "17", "PEK", "JFK");
INSERT INTO "flights" VALUES ("909", "18", "JFK", "PEK");
INSERT INTO "flights" VALUES ("111", "19", "FCO", "MAD");
INSERT INTO "flights" VALUES ("111", "20", "MAD", "FCO");