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,
"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", "SkyHigh Airways", "USA");
INSERT INTO "airlines" VALUES ("2", "Global Wings", "Canada");
INSERT INTO "airlines" VALUES ("3", "Pacific Air", "Australia");
INSERT INTO "airlines" VALUES ("4", "EuroFly", "Germany");
INSERT INTO "airlines" VALUES ("5", "TransContinental", "UK");
INSERT INTO "airports" VALUES ("Appling", "APG", "USA");
INSERT INTO "airports" VALUES ("Corvallis", "CVO", "USA");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "USA");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Canada");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Australia");
INSERT INTO "airports" VALUES ("Berlin", "BER", "Germany");
INSERT INTO "airports" VALUES ("London", "LHR", "UK");
INSERT INTO "airports" VALUES ("New York", "JFK", "USA");
INSERT INTO "flights" VALUES ("1", "101", "APG", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "CVO", "JFK");
INSERT INTO "flights" VALUES ("1", "103", "APG", "YYZ");
INSERT INTO "flights" VALUES ("2", "201", "CVO", "BER");
INSERT INTO "flights" VALUES ("2", "202", "APG", "LHR");
INSERT INTO "flights" VALUES ("3", "301", "SYD", "LAX");
INSERT INTO "flights" VALUES ("3", "302", "CVO", "SYD");
INSERT INTO "flights" VALUES ("4", "401", "BER", "LHR");
INSERT INTO "flights" VALUES ("4", "402", "APG", "BER");
INSERT INTO "flights" VALUES ("5", "501", "LHR", "JFK");
INSERT INTO "flights" VALUES ("5", "502", "CVO", "LHR");
INSERT INTO "flights" VALUES ("5", "503", "APG", "BER");