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,
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", "Emirates", "United Arab Emirates");
INSERT INTO "airlines" VALUES ("4", "Lufthansa", "Germany");
INSERT INTO "airlines" VALUES ("5", "Air Canada", "Canada");
INSERT INTO "airports" VALUES ("Asyut", "ASY");
INSERT INTO "airports" VALUES ("New York", "JFK");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA");
INSERT INTO "airports" VALUES ("Dubai", "DXB");
INSERT INTO "airports" VALUES ("Toronto", "YYZ");
INSERT INTO "flights" VALUES ("1", "101", "JFK", "ASY");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "ASY");
INSERT INTO "flights" VALUES ("1", "103", "FRA", "ASY");
INSERT INTO "flights" VALUES ("1", "104", "DXB", "ASY");
INSERT INTO "flights" VALUES ("1", "105", "YYZ", "ASY");
INSERT INTO "flights" VALUES ("1", "106", "ASY", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "JFK", "ASY");
INSERT INTO "flights" VALUES ("2", "202", "LAX", "FRA");
INSERT INTO "flights" VALUES ("3", "301", "DXB", "JFK");
INSERT INTO "flights" VALUES ("4", "401", "FRA", "ASY");
INSERT INTO "flights" VALUES ("5", "501", "YYZ", "LAX");
INSERT INTO "flights" VALUES ("5", "502", "ASY", "YYZ");