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

CREATE TABLE "airports" (
"AirportCode" TEXT UNIQUE,
"AirportName" TEXT,
"Country" 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");
INSERT INTO "airlines" VALUES ("2", "United");
INSERT INTO "airlines" VALUES ("3", "American Airlines");
INSERT INTO "airlines" VALUES ("4", "Southwest");
INSERT INTO "airlines" VALUES ("5", "JetBlue");
INSERT INTO "airports" VALUES ("JFK", "John F Kennedy International", "USA");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International", "USA");
INSERT INTO "airports" VALUES ("ORD", "O'Hare International", "USA");
INSERT INTO "airports" VALUES ("ATL", "Hartsfield-Jackson Atlanta International", "USA");
INSERT INTO "airports" VALUES ("DFW", "Dallas/Fort Worth International", "USA");
INSERT INTO "airports" VALUES ("DEN", "Denver International", "USA");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International", "USA");
INSERT INTO "airports" VALUES ("SEA", "Seattle-Tacoma International", "USA");
INSERT INTO "airports" VALUES ("MIA", "Miami International", "USA");
INSERT INTO "airports" VALUES ("BOS", "Logan International", "USA");
INSERT INTO "flights" VALUES ("1", "100", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "101", "LAX", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "JFK", "ORD");
INSERT INTO "flights" VALUES ("2", "200", "ORD", "ATL");
INSERT INTO "flights" VALUES ("2", "201", "ATL", "ORD");
INSERT INTO "flights" VALUES ("2", "202", "ORD", "DFW");
INSERT INTO "flights" VALUES ("3", "300", "DFW", "DEN");
INSERT INTO "flights" VALUES ("3", "301", "DEN", "DFW");
INSERT INTO "flights" VALUES ("3", "302", "DFW", "SFO");
INSERT INTO "flights" VALUES ("4", "400", "SFO", "SEA");
INSERT INTO "flights" VALUES ("4", "401", "SEA", "SFO");
INSERT INTO "flights" VALUES ("4", "402", "SFO", "MIA");
INSERT INTO "flights" VALUES ("5", "500", "MIA", "BOS");
INSERT INTO "flights" VALUES ("5", "501", "BOS", "MIA");
INSERT INTO "flights" VALUES ("5", "502", "MIA", "JFK");
INSERT INTO "flights" VALUES ("1", "103", "JFK", "ATL");
INSERT INTO "flights" VALUES ("2", "203", "ATL", "JFK");
INSERT INTO "flights" VALUES ("3", "303", "JFK", "DEN");
INSERT INTO "flights" VALUES ("4", "403", "DEN", "JFK");
INSERT INTO "flights" VALUES ("5", "503", "JFK", "SEA");
INSERT INTO "flights" VALUES ("1", "104", "SEA", "JFK");
INSERT INTO "flights" VALUES ("2", "204", "JFK", "BOS");
INSERT INTO "flights" VALUES ("3", "304", "BOS", "JFK");
INSERT INTO "flights" VALUES ("4", "404", "JFK", "MIA");
INSERT INTO "flights" VALUES ("5", "504", "MIA", "JFK");