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" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
"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 Air Lines");
INSERT INTO "airlines" VALUES ("2", "American Airlines");
INSERT INTO "airlines" VALUES ("3", "United Airlines");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines");
INSERT INTO "airlines" VALUES ("5", "JetBlue Airways");
INSERT INTO "airports" VALUES ("New York", "JFK", "USA");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "USA");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "USA");
INSERT INTO "airports" VALUES ("Atlanta", "ATL", "USA");
INSERT INTO "airports" VALUES ("Dallas", "DFW", "USA");
INSERT INTO "airports" VALUES ("San Francisco", "SFO", "USA");
INSERT INTO "airports" VALUES ("Seattle", "SEA", "USA");
INSERT INTO "airports" VALUES ("Miami", "MIA", "USA");
INSERT INTO "airports" VALUES ("Denver", "DEN", "USA");
INSERT INTO "airports" VALUES ("Boston", "BOS", "USA");
INSERT INTO "flights" VALUES ("1", "100", "LAX", "JFK");
INSERT INTO "flights" VALUES ("1", "101", "ORD", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "ATL", "JFK");
INSERT INTO "flights" VALUES ("2", "200", "DFW", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "SFO", "JFK");
INSERT INTO "flights" VALUES ("2", "202", "SEA", "JFK");
INSERT INTO "flights" VALUES ("3", "300", "MIA", "JFK");
INSERT INTO "flights" VALUES ("3", "301", "DEN", "JFK");
INSERT INTO "flights" VALUES ("3", "302", "BOS", "JFK");
INSERT INTO "flights" VALUES ("4", "400", "JFK", "LAX");
INSERT INTO "flights" VALUES ("4", "401", "ORD", "LAX");
INSERT INTO "flights" VALUES ("4", "402", "ATL", "LAX");
INSERT INTO "flights" VALUES ("5", "500", "DFW", "LAX");
INSERT INTO "flights" VALUES ("5", "501", "SFO", "LAX");
INSERT INTO "flights" VALUES ("5", "502", "SEA", "LAX");
INSERT INTO "flights" VALUES ("1", "103", "MIA", "ORD");
INSERT INTO "flights" VALUES ("2", "203", "DEN", "ORD");
INSERT INTO "flights" VALUES ("3", "303", "BOS", "ORD");
INSERT INTO "flights" VALUES ("4", "403", "JFK", "ATL");
INSERT INTO "flights" VALUES ("5", "503", "LAX", "ATL");
INSERT INTO "flights" VALUES ("1", "104", "ORD", "ATL");
INSERT INTO "flights" VALUES ("2", "204", "DFW", "ATL");
INSERT INTO "flights" VALUES ("3", "304", "SFO", "ATL");
INSERT INTO "flights" VALUES ("4", "404", "SEA", "ATL");
INSERT INTO "flights" VALUES ("5", "504", "MIA", "ATL");
INSERT INTO "flights" VALUES ("1", "105", "BOS", "DFW");
INSERT INTO "flights" VALUES ("2", "205", "JFK", "DFW");
INSERT INTO "flights" VALUES ("3", "305", "LAX", "DFW");
INSERT INTO "flights" VALUES ("4", "405", "ORD", "DFW");
INSERT INTO "flights" VALUES ("5", "505", "ATL", "DFW");