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 ("Amsterdam", "AMS", "Amsterdam Airport Schiphol", "Netherlands");
INSERT INTO "airports" VALUES ("Zurich", "ZRH", "Zurich Airport", "Switzerland");
INSERT INTO "airports" VALUES ("Oslo", "OSL", "Oslo Airport, Gardermoen", "Norway");
INSERT INTO "airports" VALUES ("Helsinki", "HEL", "Helsinki Airport", "Finland");
INSERT INTO "airports" VALUES ("Stockholm", "ARN", "Stockholm Arlanda Airport", "Sweden");
INSERT INTO "flights" VALUES ("101", "1001", "LHR", "CDG");
INSERT INTO "flights" VALUES ("101", "1002", "CDG", "LHR");
INSERT INTO "flights" VALUES ("102", "2001", "JFK", "NRT");
INSERT INTO "flights" VALUES ("102", "2002", "NRT", "JFK");
INSERT INTO "flights" VALUES ("103", "3001", "DXB", "FRA");
INSERT INTO "flights" VALUES ("103", "3002", "FRA", "DXB");
INSERT INTO "flights" VALUES ("104", "4001", "SYD", "PEK");
INSERT INTO "flights" VALUES ("104", "4002", "PEK", "SYD");
INSERT INTO "flights" VALUES ("105", "5001", "LHR", "JFK");
INSERT INTO "flights" VALUES ("105", "5002", "JFK", "LHR");
INSERT INTO "flights" VALUES ("106", "6001", "CDG", "DXB");
INSERT INTO "flights" VALUES ("106", "6002", "DXB", "CDG");
INSERT INTO "flights" VALUES ("107", "7001", "NRT", "SYD");
INSERT INTO "flights" VALUES ("107", "7002", "SYD", "NRT");
INSERT INTO "flights" VALUES ("108", "8001", "FRA", "PEK");
INSERT INTO "flights" VALUES ("108", "8002", "PEK", "FRA");
INSERT INTO "flights" VALUES ("109", "9001", "FCO", "MAD");
INSERT INTO "flights" VALUES ("109", "9002", "MAD", "FCO");
INSERT INTO "flights" VALUES ("110", "10001", "AMS", "ZRH");
INSERT INTO "flights" VALUES ("110", "10002", "ZRH", "AMS");