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,
"Country" 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", "AirGlobal", "USA");
INSERT INTO "airlines" VALUES ("2", "SkyHigh", "UK");
INSERT INTO "airlines" VALUES ("3", "FlyFast", "Canada");
INSERT INTO "airlines" VALUES ("4", "JetStream", "Australia");
INSERT INTO "airlines" VALUES ("5", "CloudNine", "Germany");
INSERT INTO "airports" VALUES ("Aberdeen", "ABZ", "UK");
INSERT INTO "airports" VALUES ("Ashley", "ASH", "USA");
INSERT INTO "airports" VALUES ("London", "LON", "UK");
INSERT INTO "airports" VALUES ("New York", "NYC", "USA");
INSERT INTO "airports" VALUES ("Toronto", "TOR", "Canada");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Australia");
INSERT INTO "airports" VALUES ("Berlin", "BER", "Germany");
INSERT INTO "airports" VALUES ("Aberdeen", "ABD", "USA");
INSERT INTO "airports" VALUES ("Ashley", "ASL", "UK");
INSERT INTO "flights" VALUES ("1", "101", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("1", "102", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("2", "201", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("3", "301", "ABZ", "NYC");
INSERT INTO "flights" VALUES ("4", "401", "LON", "ASH");
INSERT INTO "flights" VALUES ("5", "501", "ABZ", "BER");
INSERT INTO "flights" VALUES ("2", "202", "ABD", "ASL");
INSERT INTO "flights" VALUES ("3", "302", "ABD", "ASH");
INSERT INTO "flights" VALUES ("1", "103", "ABZ", "ASL");
INSERT INTO "flights" VALUES ("4", "402", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("5", "502", "ABZ", "ASH");