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

CREATE TABLE "airports" (
"City" TEXT,
"AirportCode" TEXT,
"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", "United States");
INSERT INTO "airlines" VALUES ("2", "United Kingdom");
INSERT INTO "airlines" VALUES ("3", "Germany");
INSERT INTO "airlines" VALUES ("4", "France");
INSERT INTO "airlines" VALUES ("5", "Canada");
INSERT INTO "airports" VALUES ("Aberdeen", "ABZ", "Aberdeen International Airport");
INSERT INTO "airports" VALUES ("Aberdeen", "ABD", "Aberdeen Regional 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 ("Berlin", "TXL", "Tegel Airport");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Toronto Pearson International Airport");
INSERT INTO "airports" VALUES ("Edinburgh", "EDI", "Edinburgh Airport");
INSERT INTO "airports" VALUES ("Glasgow", "GLA", "Glasgow International Airport");
INSERT INTO "flights" VALUES ("2", "101", "ABZ", "LHR");
INSERT INTO "flights" VALUES ("2", "102", "LHR", "ABZ");
INSERT INTO "flights" VALUES ("1", "201", "JFK", "ABZ");
INSERT INTO "flights" VALUES ("3", "301", "TXL", "EDI");
INSERT INTO "flights" VALUES ("4", "401", "CDG", "GLA");
INSERT INTO "flights" VALUES ("5", "501", "YYZ", "ABD");
INSERT INTO "flights" VALUES ("2", "103", "ABZ", "EDI");
INSERT INTO "flights" VALUES ("2", "104", "EDI", "ABZ");
INSERT INTO "flights" VALUES ("2", "105", "ABZ", "GLA");
INSERT INTO "flights" VALUES ("2", "106", "GLA", "ABZ");