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", "SkyHigh Airways");
INSERT INTO "airlines" VALUES ("2", "Global Wings");
INSERT INTO "airlines" VALUES ("3", "Continental Flyers");
INSERT INTO "airlines" VALUES ("4", "Oceanic Air");
INSERT INTO "airlines" VALUES ("5", "MetroJet");
INSERT INTO "airports" VALUES ("New York", "JFK", "USA");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "USA");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "USA");
INSERT INTO "airports" VALUES ("London", "LHR", "UK");
INSERT INTO "airports" VALUES ("Paris", "CDG", "France");
INSERT INTO "airports" VALUES ("Tokyo", "HND", "Japan");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "UAE");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Australia");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Germany");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Canada");
INSERT INTO "flights" VALUES ("1", "101", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "JFK");
INSERT INTO "flights" VALUES ("1", "103", "ORD", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "LHR", "JFK");
INSERT INTO "flights" VALUES ("2", "202", "CDG", "LHR");
INSERT INTO "flights" VALUES ("2", "203", "JFK", "LHR");
INSERT INTO "flights" VALUES ("3", "301", "HND", "LAX");
INSERT INTO "flights" VALUES ("3", "302", "DXB", "LAX");
INSERT INTO "flights" VALUES ("3", "303", "SYD", "LAX");
INSERT INTO "flights" VALUES ("3", "304", "FRA", "LAX");
INSERT INTO "flights" VALUES ("4", "401", "YYZ", "LAX");
INSERT INTO "flights" VALUES ("4", "402", "JFK", "LAX");
INSERT INTO "flights" VALUES ("4", "403", "ORD", "LAX");
INSERT INTO "flights" VALUES ("5", "501", "LAX", "ORD");
INSERT INTO "flights" VALUES ("5", "502", "LAX", "ORD");
INSERT INTO "flights" VALUES ("5", "503", "LAX", "ORD");
INSERT INTO "flights" VALUES ("5", "504", "LAX", "ORD");
INSERT INTO "flights" VALUES ("5", "505", "LAX", "ORD");