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,
"Abbreviation" 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,
PRIMARY KEY ("Airline", "FlightNo"),
FOREIGN KEY ("SourceAirport") REFERENCES "airports"("AirportCode")
);





INSERT INTO "airlines" VALUES ("1", "United Airlines", "UA", "USA");
INSERT INTO "airlines" VALUES ("2", "Delta Air Lines", "DL", "USA");
INSERT INTO "airlines" VALUES ("3", "British Airways", "BA", "UK");
INSERT INTO "airlines" VALUES ("4", "Lufthansa", "LH", "Germany");
INSERT INTO "airlines" VALUES ("5", "Air Canada", "AC", "Canada");
INSERT INTO "airlines" VALUES ("6", "Southwest Airlines", "WN", "USA");
INSERT INTO "airlines" VALUES ("7", "American Airlines", "AA", "USA");
INSERT INTO "airlines" VALUES ("8", "Qantas", "QF", "Australia");
INSERT INTO "airlines" VALUES ("9", "Emirates", "EK", "UAE");
INSERT INTO "airlines" VALUES ("10", "Air France", "AF", "France");
INSERT INTO "airports" VALUES ("New York", "JFK", "USA");
INSERT INTO "airports" VALUES ("London", "LHR", "UK");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Germany");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Canada");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "USA");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Australia");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "UAE");
INSERT INTO "airports" VALUES ("Paris", "CDG", "France");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "USA");
INSERT INTO "airports" VALUES ("Dallas", "DFW", "USA");
INSERT INTO "flights" VALUES ("1", "101", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "JFK");
INSERT INTO "flights" VALUES ("3", "301", "LHR");
INSERT INTO "flights" VALUES ("4", "401", "FRA");
INSERT INTO "flights" VALUES ("5", "501", "YYZ");
INSERT INTO "flights" VALUES ("6", "601", "LAX");
INSERT INTO "flights" VALUES ("7", "701", "JFK");
INSERT INTO "flights" VALUES ("7", "702", "ORD");
INSERT INTO "flights" VALUES ("7", "703", "DFW");
INSERT INTO "flights" VALUES ("8", "801", "SYD");
INSERT INTO "flights" VALUES ("9", "901", "DXB");
INSERT INTO "flights" VALUES ("10", "1001", "CDG");