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", "USA");
INSERT INTO "airlines" VALUES ("2", "Delta Airlines", "USA");
INSERT INTO "airlines" VALUES ("3", "Lufthansa", "Germany");
INSERT INTO "airlines" VALUES ("4", "Emirates", "UAE");
INSERT INTO "airlines" VALUES ("5", "Air France", "France");
INSERT INTO "airports" VALUES ("New York", "JFK");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX");
INSERT INTO "airports" VALUES ("Chicago", "ORD");
INSERT INTO "airports" VALUES ("Asyut", "ASY");
INSERT INTO "airports" VALUES ("Paris", "CDG");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA");
INSERT INTO "airports" VALUES ("Dubai", "DXB");
INSERT INTO "flights" VALUES ("1", "1001", "JFK", "ASY");
INSERT INTO "flights" VALUES ("1", "1002", "LAX", "ASY");
INSERT INTO "flights" VALUES ("1", "1003", "ORD", "LAX");
INSERT INTO "flights" VALUES ("1", "1004", "JFK", "ORD");
INSERT INTO "flights" VALUES ("2", "2001", "JFK", "ASY");
INSERT INTO "flights" VALUES ("2", "2002", "LAX", "ORD");
INSERT INTO "flights" VALUES ("3", "3001", "FRA", "JFK");
INSERT INTO "flights" VALUES ("3", "3002", "FRA", "ASY");
INSERT INTO "flights" VALUES ("4", "4001", "DXB", "ASY");
INSERT INTO "flights" VALUES ("5", "5001", "CDG", "JFK");
INSERT INTO "flights" VALUES ("1", "1005", "ORD", "ASY");
INSERT INTO "flights" VALUES ("1", "1006", "LAX", "CDG");