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 UNIQUE,
"AirportName" TEXT,
"Country" TEXT,
"CountryAbbrev" 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", "Delta Air Lines", "DL", "United States");
INSERT INTO "airlines" VALUES ("2", "Lufthansa", "LH", "Germany");
INSERT INTO "airlines" VALUES ("3", "Air Canada", "AC", "Canada");
INSERT INTO "airlines" VALUES ("4", "Qantas", "QF", "Australia");
INSERT INTO "airlines" VALUES ("5", "Emirates", "EK", "United Arab Emirates");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport", "United States", "US");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "Los Angeles International Airport", "United States", "US");
INSERT INTO "airports" VALUES ("Frankfurt", "FRA", "Frankfurt Airport", "Germany", "DE");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Toronto Pearson International Airport", "Canada", "CA");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Sydney Kingsford Smith Airport", "Australia", "AU");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "Dubai International Airport", "United Arab Emirates", "AE");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "O'Hare International Airport", "United States", "US");
INSERT INTO "airports" VALUES ("Munich", "MUC", "Munich Airport", "Germany", "DE");
INSERT INTO "flights" VALUES ("1", "1001", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "1002", "LAX", "JFK");
INSERT INTO "flights" VALUES ("2", "2001", "FRA", "JFK");
INSERT INTO "flights" VALUES ("2", "2002", "MUC", "FRA");
INSERT INTO "flights" VALUES ("3", "3001", "YYZ", "LAX");
INSERT INTO "flights" VALUES ("3", "3002", "LAX", "YYZ");
INSERT INTO "flights" VALUES ("4", "4001", "SYD", "DXB");
INSERT INTO "flights" VALUES ("4", "4002", "DXB", "SYD");
INSERT INTO "flights" VALUES ("5", "5001", "DXB", "ORD");
INSERT INTO "flights" VALUES ("5", "5002", "ORD", "DXB");
INSERT INTO "flights" VALUES ("1", "1003", "ORD", "JFK");
INSERT INTO "flights" VALUES ("2", "2003", "FRA", "MUC");
INSERT INTO "flights" VALUES ("3", "3003", "YYZ", "FRA");
INSERT INTO "flights" VALUES ("4", "4003", "SYD", "JFK");
INSERT INTO "flights" VALUES ("5", "5003", "DXB", "LAX");