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", "United Airlines", "United States");
INSERT INTO "airlines" VALUES ("2", "Delta Airlines", "United States");
INSERT INTO "airlines" VALUES ("3", "British Airways", "United Kingdom");
INSERT INTO "airlines" VALUES ("4", "Lufthansa", "Germany");
INSERT INTO "airlines" VALUES ("5", "Emirates", "United Arab Emirates");
INSERT INTO "airports" VALUES ("New York", "JFK", "United States");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "United States");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "United States");
INSERT INTO "airports" VALUES ("Aberdeen", "ABZ", "United Kingdom");
INSERT INTO "airports" VALUES ("London", "LHR", "United Kingdom");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Germany");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "United Arab Emirates");
INSERT INTO "airports" VALUES ("Aberdeen", "ABD", "United States");
INSERT INTO "flights" VALUES ("1", "100", "JFK", "ABZ");
INSERT INTO "flights" VALUES ("1", "101", "LAX", "ABZ");
INSERT INTO "flights" VALUES ("1", "102", "ORD", "LHR");
INSERT INTO "flights" VALUES ("1", "103", "JFK", "LHR");
INSERT INTO "flights" VALUES ("2", "200", "ORD", "ABZ");
INSERT INTO "flights" VALUES ("3", "300", "LHR", "ABZ");
INSERT INTO "flights" VALUES ("4", "400", "FRA", "LHR");
INSERT INTO "flights" VALUES ("5", "500", "DXB", "LHR");
INSERT INTO "flights" VALUES ("1", "104", "JFK", "ABD");
INSERT INTO "flights" VALUES ("1", "105", "LAX", "DXB");
INSERT INTO "flights" VALUES ("2", "201", "LAX", "ABD");