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 ("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 ("Los Angeles", "LAX", "Los Angeles International Airport", "USA");
INSERT INTO "flights" VALUES ("101", "1001", "LHR", "JFK");
INSERT INTO "flights" VALUES ("101", "1002", "JFK", "LHR");
INSERT INTO "flights" VALUES ("102", "2001", "CDG", "DXB");
INSERT INTO "flights" VALUES ("102", "2002", "DXB", "CDG");
INSERT INTO "flights" VALUES ("103", "3001", "NRT", "SIN");
INSERT INTO "flights" VALUES ("103", "3002", "SIN", "NRT");
INSERT INTO "flights" VALUES ("104", "4001", "LHR", "DXB");
INSERT INTO "flights" VALUES ("104", "4002", "DXB", "LHR");
INSERT INTO "flights" VALUES ("105", "5001", "JFK", "LAX");
INSERT INTO "flights" VALUES ("105", "5002", "LAX", "JFK");
INSERT INTO "flights" VALUES ("106", "6001", "FRA", "LHR");
INSERT INTO "flights" VALUES ("106", "6002", "LHR", "FRA");
INSERT INTO "flights" VALUES ("107", "7001", "PEK", "NRT");
INSERT INTO "flights" VALUES ("107", "7002", "NRT", "PEK");
INSERT INTO "flights" VALUES ("108", "8001", "SYD", "SIN");
INSERT INTO "flights" VALUES ("108", "8002", "SIN", "SYD");
INSERT INTO "flights" VALUES ("109", "9001", "JFK", "CDG");
INSERT INTO "flights" VALUES ("109", "9002", "CDG", "JFK");
INSERT INTO "flights" VALUES ("110", "1101", "LHR", "LAX");
INSERT INTO "flights" VALUES ("110", "1102", "LAX", "LHR");
INSERT INTO "flights" VALUES ("111", "1111", "DXB", "JFK");
INSERT INTO "flights" VALUES ("111", "1112", "JFK", "DXB");
INSERT INTO "flights" VALUES ("112", "1121", "LHR", "NRT");
INSERT INTO "flights" VALUES ("112", "1122", "NRT", "LHR");
INSERT INTO "flights" VALUES ("113", "1131", "CDG", "LHR");
INSERT INTO "flights" VALUES ("113", "1132", "LHR", "CDG");
INSERT INTO "flights" VALUES ("114", "1141", "JFK", "FRA");
INSERT INTO "flights" VALUES ("114", "1142", "FRA", "JFK");
INSERT INTO "flights" VALUES ("115", "1151", "SIN", "LHR");
INSERT INTO "flights" VALUES ("115", "1152", "LHR", "SIN");