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,
"Country" TEXT,
PRIMARY KEY ("uid")
);

CREATE TABLE "airports" (
"AirportCode" TEXT UNIQUE,
"AirportName" 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 States");
INSERT INTO "airlines" VALUES ("2", "Canada");
INSERT INTO "airlines" VALUES ("3", "Mexico");
INSERT INTO "airlines" VALUES ("4", "United Kingdom");
INSERT INTO "airlines" VALUES ("5", "Germany");
INSERT INTO "airports" VALUES ("AKO", "Colorado Plains Regional Airport");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("YYZ", "Toronto Pearson International Airport");
INSERT INTO "airports" VALUES ("MEX", "Mexico City International Airport");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport");
INSERT INTO "airports" VALUES ("FRA", "Frankfurt Airport");
INSERT INTO "airports" VALUES ("DEN", "Denver International Airport");
INSERT INTO "airports" VALUES ("ORD", "Chicago O'Hare International Airport");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport");
INSERT INTO "flights" VALUES ("1", "100", "LAX", "AKO");
INSERT INTO "flights" VALUES ("1", "101", "AKO", "DEN");
INSERT INTO "flights" VALUES ("2", "200", "YYZ", "LHR");
INSERT INTO "flights" VALUES ("3", "300", "MEX", "JFK");
INSERT INTO "flights" VALUES ("4", "400", "LHR", "FRA");
INSERT INTO "flights" VALUES ("5", "500", "FRA", "ORD");
INSERT INTO "flights" VALUES ("1", "102", "DEN", "SFO");
INSERT INTO "flights" VALUES ("2", "201", "YYZ", "ORD");
INSERT INTO "flights" VALUES ("3", "301", "MEX", "LAX");
INSERT INTO "flights" VALUES ("4", "401", "LHR", "JFK");