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,
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 ("Aberdeen", "ABZ", "Aberdeen International Airport");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport");
INSERT INTO "airports" VALUES ("Aberdeen", "ABR", "Aberdeen Regional Airport");
INSERT INTO "airports" VALUES ("Tokyo", "HND", "Haneda Airport");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Sydney Kingsford Smith Airport");
INSERT INTO "airports" VALUES ("Aberdeen", "ABD", "Aberdeen City Airport");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "Dubai International Airport");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Frankfurt Airport");
INSERT INTO "flights" VALUES ("101", "1001", "ABZ", "LHR");
INSERT INTO "flights" VALUES ("101", "1002", "ABZ", "JFK");
INSERT INTO "flights" VALUES ("102", "2001", "LHR", "CDG");
INSERT INTO "flights" VALUES ("103", "3001", "ABR", "HND");
INSERT INTO "flights" VALUES ("104", "4001", "ABD", "SYD");
INSERT INTO "flights" VALUES ("101", "1003", "ABZ", "DXB");
INSERT INTO "flights" VALUES ("105", "5001", "JFK", "FRA");
INSERT INTO "flights" VALUES ("106", "6001", "ABD", "LHR");
INSERT INTO "flights" VALUES ("107", "7001", "ABR", "CDG");
INSERT INTO "flights" VALUES ("108", "8001", "LHR", "ABZ");
INSERT INTO "flights" VALUES ("109", "9001", "DXB", "ABZ");
INSERT INTO "flights" VALUES ("110", "10001", "ABZ", "FRA");