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 ("ORD", "OHare 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 ("DXB", "Dubai International Airport", "UAE");
INSERT INTO "airports" VALUES ("SYD", "Sydney Airport", "Australia");
INSERT INTO "flights" VALUES ("101", "1001", "DEN", "LAX");
INSERT INTO "flights" VALUES ("101", "1002", "LAX", "DEN");
INSERT INTO "flights" VALUES ("102", "2001", "ORD", "JFK");
INSERT INTO "flights" VALUES ("102", "2002", "JFK", "ORD");
INSERT INTO "flights" VALUES ("103", "3001", "DEN", "AKO");
INSERT INTO "flights" VALUES ("103", "3002", "AKO", "DEN");
INSERT INTO "flights" VALUES ("104", "4001", "LHR", "CDG");
INSERT INTO "flights" VALUES ("104", "4002", "CDG", "LHR");
INSERT INTO "flights" VALUES ("105", "5001", "NRT", "DXB");
INSERT INTO "flights" VALUES ("105", "5002", "DXB", "NRT");
INSERT INTO "flights" VALUES ("106", "6001", "SYD", "LAX");
INSERT INTO "flights" VALUES ("106", "6002", "LAX", "SYD");