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,
"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 ("New York", "JFK", "USA");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "USA");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "USA");
INSERT INTO "airports" VALUES ("London", "LHR", "UK");
INSERT INTO "airports" VALUES ("Paris", "CDG", "France");
INSERT INTO "airports" VALUES ("Tokyo", "HND", "Japan");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Australia");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "UAE");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Canada");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Germany");
INSERT INTO "flights" VALUES ("1", "101", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "JFK", "ORD");
INSERT INTO "flights" VALUES ("2", "202", "ORD", "JFK");
INSERT INTO "flights" VALUES ("3", "301", "LHR", "CDG");
INSERT INTO "flights" VALUES ("3", "302", "CDG", "LHR");
INSERT INTO "flights" VALUES ("4", "401", "HND", "SYD");
INSERT INTO "flights" VALUES ("4", "402", "SYD", "HND");
INSERT INTO "flights" VALUES ("5", "501", "DXB", "JFK");
INSERT INTO "flights" VALUES ("5", "502", "JFK", "DXB");
INSERT INTO "flights" VALUES ("6", "601", "YYZ", "FRA");
INSERT INTO "flights" VALUES ("6", "602", "FRA", "YYZ");
INSERT INTO "flights" VALUES ("7", "701", "ORD", "LAX");
INSERT INTO "flights" VALUES ("7", "702", "LAX", "ORD");
INSERT INTO "flights" VALUES ("8", "801", "CDG", "DXB");
INSERT INTO "flights" VALUES ("8", "802", "DXB", "CDG");
INSERT INTO "flights" VALUES ("9", "901", "SYD", "YYZ");
INSERT INTO "flights" VALUES ("9", "902", "YYZ", "SYD");
INSERT INTO "flights" VALUES ("10", "1001", "FRA", "HND");
INSERT INTO "airports" VALUES ("Reykjavik", "KEF", "Iceland");