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 ("Singapore", "SIN", "Changi Airport", "Singapore");
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 "flights" VALUES ("101", "1001", "LHR", "CDG");
INSERT INTO "flights" VALUES ("101", "1002", "CDG", "LHR");
INSERT INTO "flights" VALUES ("102", "2001", "JFK", "LHR");
INSERT INTO "flights" VALUES ("102", "2002", "LHR", "JFK");
INSERT INTO "flights" VALUES ("103", "3001", "NRT", "DXB");
INSERT INTO "flights" VALUES ("103", "3002", "DXB", "NRT");
INSERT INTO "flights" VALUES ("104", "4001", "FRA", "SIN");
INSERT INTO "flights" VALUES ("104", "4002", "SIN", "FRA");
INSERT INTO "flights" VALUES ("105", "5001", "SYD", "PEK");
INSERT INTO "flights" VALUES ("105", "5002", "PEK", "SYD");
INSERT INTO "flights" VALUES ("106", "6001", "LHR", "DXB");
INSERT INTO "flights" VALUES ("106", "6002", "DXB", "LHR");
INSERT INTO "flights" VALUES ("107", "7001", "JFK", "CDG");
INSERT INTO "flights" VALUES ("107", "7002", "CDG", "JFK");
INSERT INTO "flights" VALUES ("108", "8001", "NRT", "SIN");
INSERT INTO "flights" VALUES ("108", "8002", "SIN", "NRT");
INSERT INTO "flights" VALUES ("109", "9001", "FRA", "PEK");
INSERT INTO "flights" VALUES ("109", "9002", "PEK", "FRA");
INSERT INTO "flights" VALUES ("110", "10001", "SYD", "DXB");
INSERT INTO "flights" VALUES ("110", "10002", "DXB", "SYD");
INSERT INTO "flights" VALUES ("111", "11001", "FCO", "LHR");
INSERT INTO "flights" VALUES ("111", "11002", "LHR", "FCO");
INSERT INTO "flights" VALUES ("112", "12001", "FCO", "CDG");
INSERT INTO "flights" VALUES ("112", "12002", "CDG", "FCO");
INSERT INTO "flights" VALUES ("113", "13001", "FCO", "JFK");
INSERT INTO "flights" VALUES ("114", "14001", "FCO", "NRT");
INSERT INTO "flights" VALUES ("115", "15001", "FCO", "DXB");
INSERT INTO "flights" VALUES ("116", "16001", "FCO", "FRA");
INSERT INTO "flights" VALUES ("117", "17001", "FCO", "SIN");
INSERT INTO "flights" VALUES ("118", "18001", "FCO", "SYD");
INSERT INTO "flights" VALUES ("119", "19001", "FCO", "PEK");