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,
"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 "airlines" VALUES ("1", "Air Global");
INSERT INTO "airlines" VALUES ("2", "Skyways");
INSERT INTO "airlines" VALUES ("3", "FlyHigh");
INSERT INTO "airlines" VALUES ("4", "CloudJet");
INSERT INTO "airlines" VALUES ("5", "Eagle Air");
INSERT INTO "airports" VALUES ("Aberdeen", "ABZ", "United Kingdom");
INSERT INTO "airports" VALUES ("London", "LHR", "United Kingdom");
INSERT INTO "airports" VALUES ("Edinburgh", "EDI", "United Kingdom");
INSERT INTO "airports" VALUES ("Glasgow", "GLA", "United Kingdom");
INSERT INTO "airports" VALUES ("New York", "JFK", "United States");
INSERT INTO "airports" VALUES ("Paris", "CDG", "France");
INSERT INTO "airports" VALUES ("Berlin", "TXL", "Germany");
INSERT INTO "airports" VALUES ("Dublin", "DUB", "Ireland");
INSERT INTO "airports" VALUES ("Manchester", "MAN", "United Kingdom");
INSERT INTO "airports" VALUES ("Amsterdam", "AMS", "Netherlands");
INSERT INTO "flights" VALUES ("1", "101", "LHR", "ABZ");
INSERT INTO "flights" VALUES ("1", "102", "EDI", "ABZ");
INSERT INTO "flights" VALUES ("2", "201", "GLA", "ABZ");
INSERT INTO "flights" VALUES ("2", "202", "MAN", "ABZ");
INSERT INTO "flights" VALUES ("3", "301", "JFK", "ABZ");
INSERT INTO "flights" VALUES ("3", "302", "CDG", "ABZ");
INSERT INTO "flights" VALUES ("4", "401", "TXL", "ABZ");
INSERT INTO "flights" VALUES ("4", "402", "DUB", "ABZ");
INSERT INTO "flights" VALUES ("5", "501", "ABZ", "LHR");
INSERT INTO "flights" VALUES ("5", "502", "ABZ", "EDI");
INSERT INTO "flights" VALUES ("1", "103", "LHR", "GLA");
INSERT INTO "flights" VALUES ("2", "203", "MAN", "EDI");
INSERT INTO "flights" VALUES ("3", "303", "JFK", "CDG");
INSERT INTO "flights" VALUES ("4", "403", "TXL", "DUB");
INSERT INTO "flights" VALUES ("5", "503", "AMS", "MAN");