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,
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 Airlines");
INSERT INTO "airlines" VALUES ("2", "Delta Air Lines");
INSERT INTO "airlines" VALUES ("3", "American Airlines");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines");
INSERT INTO "airlines" VALUES ("5", "Alaska Airlines");
INSERT INTO "airlines" VALUES ("6", "JetBlue Airways");
INSERT INTO "airlines" VALUES ("7", "Spirit Airlines");
INSERT INTO "airlines" VALUES ("8", "Frontier Airlines");
INSERT INTO "airports" VALUES ("Chicago", "ORD");
INSERT INTO "airports" VALUES ("New York", "JFK");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX");
INSERT INTO "airports" VALUES ("Dallas", "DFW");
INSERT INTO "airports" VALUES ("Atlanta", "ATL");
INSERT INTO "airports" VALUES ("Denver", "DEN");
INSERT INTO "airports" VALUES ("San Francisco", "SFO");
INSERT INTO "airports" VALUES ("Seattle", "SEA");
INSERT INTO "airports" VALUES ("Miami", "MIA");
INSERT INTO "airports" VALUES ("Boston", "BOS");
INSERT INTO "flights" VALUES ("1", "101", "ORD", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "JFK", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "LAX", "DFW");
INSERT INTO "flights" VALUES ("2", "202", "DFW", "ATL");
INSERT INTO "flights" VALUES ("3", "301", "ATL", "DEN");
INSERT INTO "flights" VALUES ("3", "302", "DEN", "SFO");
INSERT INTO "flights" VALUES ("4", "401", "SFO", "SEA");
INSERT INTO "flights" VALUES ("4", "402", "SEA", "MIA");
INSERT INTO "flights" VALUES ("5", "501", "MIA", "BOS");
INSERT INTO "flights" VALUES ("5", "502", "BOS", "ORD");
INSERT INTO "flights" VALUES ("1", "103", "ORD", "LAX");
INSERT INTO "flights" VALUES ("2", "203", "JFK", "ATL");
INSERT INTO "flights" VALUES ("3", "303", "DFW", "SFO");
INSERT INTO "flights" VALUES ("4", "403", "ATL", "SEA");
INSERT INTO "flights" VALUES ("5", "503", "DEN", "MIA");
INSERT INTO "flights" VALUES ("6", "601", "JFK", "ORD");
INSERT INTO "flights" VALUES ("7", "701", "LAX", "JFK");
INSERT INTO "flights" VALUES ("8", "801", "DFW", "LAX");