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" (
"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 ("AKO", "Colorado Plains Regional Airport", "USA");
INSERT INTO "airports" VALUES ("DEN", "Denver International Airport", "USA");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport", "USA");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport", "USA");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport", "UK");
INSERT INTO "airports" VALUES ("CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "airports" VALUES ("NRT", "Narita International Airport", "Japan");
INSERT INTO "airports" VALUES ("SYD", "Sydney Airport", "Australia");
INSERT INTO "airports" VALUES ("DXB", "Dubai International Airport", "UAE");
INSERT INTO "airports" VALUES ("PEK", "Beijing Capital International Airport", "China");
INSERT INTO "flights" VALUES ("101", "123", "DEN", "AKO");
INSERT INTO "flights" VALUES ("101", "124", "AKO", "DEN");
INSERT INTO "flights" VALUES ("202", "456", "LAX", "JFK");
INSERT INTO "flights" VALUES ("303", "789", "LHR", "CDG");
INSERT INTO "flights" VALUES ("404", "111", "NRT", "SYD");
INSERT INTO "flights" VALUES ("505", "222", "DXB", "PEK");
INSERT INTO "flights" VALUES ("101", "125", "DEN", "LAX");
INSERT INTO "flights" VALUES ("202", "457", "JFK", "LHR");
INSERT INTO "flights" VALUES ("303", "790", "CDG", "NRT");
INSERT INTO "flights" VALUES ("404", "112", "SYD", "DXB");