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,
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 "airlines" VALUES ("1", "British Airways");
INSERT INTO "airlines" VALUES ("2", "EasyJet");
INSERT INTO "airlines" VALUES ("3", "Ryanair");
INSERT INTO "airlines" VALUES ("4", "Lufthansa");
INSERT INTO "airlines" VALUES ("5", "Air France");
INSERT INTO "airlines" VALUES ("6", "KLM");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport");
INSERT INTO "airports" VALUES ("Aberdeen", "ABZ", "Aberdeen International Airport");
INSERT INTO "airports" VALUES ("Manchester", "MAN", "Manchester Airport");
INSERT INTO "airports" VALUES ("Edinburgh", "EDI", "Edinburgh Airport");
INSERT INTO "airports" VALUES ("Glasgow", "GLA", "Glasgow Airport");
INSERT INTO "airports" VALUES ("Dublin", "DUB", "Dublin Airport");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Frankfurt Airport");
INSERT INTO "airports" VALUES ("Amsterdam", "AMS", "Amsterdam Airport Schiphol");
INSERT INTO "airports" VALUES ("Aberdeen", "ABZ2", "Aberdeen Regional Airport");
INSERT INTO "flights" VALUES ("1", "101", "ABZ", "LHR");
INSERT INTO "flights" VALUES ("1", "102", "LHR", "ABZ");
INSERT INTO "flights" VALUES ("2", "201", "ABZ", "MAN");
INSERT INTO "flights" VALUES ("2", "202", "MAN", "ABZ");
INSERT INTO "flights" VALUES ("3", "301", "EDI", "DUB");
INSERT INTO "flights" VALUES ("3", "302", "DUB", "EDI");
INSERT INTO "flights" VALUES ("1", "103", "ABZ", "CDG");
INSERT INTO "flights" VALUES ("4", "401", "FRA", "LHR");
INSERT INTO "flights" VALUES ("5", "501", "CDG", "AMS");
INSERT INTO "flights" VALUES ("6", "601", "AMS", "GLA");
INSERT INTO "flights" VALUES ("1", "104", "ABZ", "EDI");
INSERT INTO "flights" VALUES ("2", "203", "ABZ", "GLA");
INSERT INTO "flights" VALUES ("3", "303", "ABZ", "DUB");
INSERT INTO "flights" VALUES ("4", "402", "ABZ", "FRA");
INSERT INTO "flights" VALUES ("5", "502", "ABZ", "CDG");
INSERT INTO "flights" VALUES ("6", "602", "ABZ", "AMS");
INSERT INTO "flights" VALUES ("1", "105", "LHR", "MAN");
INSERT INTO "flights" VALUES ("2", "204", "MAN", "EDI");
INSERT INTO "flights" VALUES ("3", "304", "DUB", "GLA");
INSERT INTO "flights" VALUES ("1", "106", "ABZ2", "LHR");
INSERT INTO "flights" VALUES ("2", "205", "ABZ2", "MAN");