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 ("New York", "JFK", "John F. Kennedy International Airport", "USA");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "airports" VALUES ("Tokyo", "NRT", "Narita International Airport", "Japan");
INSERT INTO "airports" VALUES ("Berlin", "BER", "Berlin Brandenburg Airport", "Germany");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Sydney Airport", "Australia");
INSERT INTO "airports" VALUES ("Cairo", "CAI", "Cairo International Airport", "Egypt");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "Dubai International Airport", "UAE");
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 ("Oslo", "OSL", "Oslo Airport, Gardermoen", "Norway");
INSERT INTO "airports" VALUES ("Helsinki", "HEL", "Helsinki Airport", "Finland");
INSERT INTO "airports" VALUES ("Reykjavik", "KEF", "Keflavík International Airport", "Iceland");
INSERT INTO "airports" VALUES ("Wellington", "WLG", "Wellington International Airport", "New Zealand");
INSERT INTO "airports" VALUES ("Santiago", "SCL", "Comodoro Arturo Merino Benítez International Airport", "Chile");
INSERT INTO "flights" VALUES ("101", "1", "LHR", "JFK");
INSERT INTO "flights" VALUES ("101", "2", "JFK", "LHR");
INSERT INTO "flights" VALUES ("102", "3", "CDG", "NRT");
INSERT INTO "flights" VALUES ("103", "4", "NRT", "CDG");
INSERT INTO "flights" VALUES ("104", "5", "LHR", "CDG");
INSERT INTO "flights" VALUES ("105", "6", "JFK", "NRT");
INSERT INTO "flights" VALUES ("106", "7", "DXB", "LHR");
INSERT INTO "flights" VALUES ("107", "8", "LHR", "DXB");
INSERT INTO "flights" VALUES ("108", "9", "CAI", "FCO");
INSERT INTO "flights" VALUES ("109", "10", "FCO", "CAI");
INSERT INTO "flights" VALUES ("110", "11", "MAD", "DXB");
INSERT INTO "flights" VALUES ("111", "12", "DXB", "MAD");
INSERT INTO "flights" VALUES ("112", "13", "SYD", "NRT");
INSERT INTO "flights" VALUES ("113", "14", "NRT", "SYD");
INSERT INTO "flights" VALUES ("114", "15", "BER", "LHR");
INSERT INTO "flights" VALUES ("115", "16", "LHR", "BER");
INSERT INTO "flights" VALUES ("116", "17", "OSL", "JFK");
INSERT INTO "flights" VALUES ("117", "18", "JFK", "OSL");
INSERT INTO "flights" VALUES ("118", "19", "HEL", "CDG");
INSERT INTO "flights" VALUES ("119", "20", "CDG", "HEL");