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 "airlines" (
"uid" INT,
"Airline" TEXT,
PRIMARY KEY ("uid")
);

CREATE TABLE "airports" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
"AirportName" TEXT,
"Country" TEXT,
PRIMARY KEY ("AirportCode")
);

CREATE TABLE "flights" (
"Airline" INT,
"FlightNo" INT,
"DestAirport" TEXT,
PRIMARY KEY ("Airline", "FlightNo"),
FOREIGN KEY ("DestAirport") REFERENCES "airports"("AirportCode")
);





INSERT INTO "airlines" VALUES ("1", "Delta Air Lines");
INSERT INTO "airlines" VALUES ("2", "British Airways");
INSERT INTO "airlines" VALUES ("3", "Lufthansa");
INSERT INTO "airlines" VALUES ("4", "Emirates");
INSERT INTO "airlines" VALUES ("5", "EasyJet");
INSERT INTO "airports" VALUES ("Aberdeen", "ABZ", "Aberdeen International Airport", "United Kingdom");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport", "United Kingdom");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport", "United States");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Frankfurt Airport", "Germany");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "Dubai International Airport", "United Arab Emirates");
INSERT INTO "airports" VALUES ("Glasgow", "GLA", "Glasgow Airport", "United Kingdom");
INSERT INTO "airports" VALUES ("Edinburgh", "EDI", "Edinburgh Airport", "United Kingdom");
INSERT INTO "flights" VALUES ("1", "100", "ABZ");
INSERT INTO "flights" VALUES ("2", "200", "ABZ");
INSERT INTO "flights" VALUES ("3", "300", "FRA");
INSERT INTO "flights" VALUES ("4", "400", "DXB");
INSERT INTO "flights" VALUES ("5", "500", "ABZ");
INSERT INTO "flights" VALUES ("1", "101", "LHR");
INSERT INTO "flights" VALUES ("2", "201", "GLA");
INSERT INTO "flights" VALUES ("3", "301", "ABZ");
INSERT INTO "flights" VALUES ("4", "401", "EDI");
INSERT INTO "flights" VALUES ("5", "501", "JFK");