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 ("Boston", "BOS", "USA");
INSERT INTO "airports" VALUES ("Denver", "DEN", "USA");
INSERT INTO "flights" VALUES ("1", "1001", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "1002", "JFK", "ORD");
INSERT INTO "flights" VALUES ("1", "1003", "JFK", "ATL");
INSERT INTO "flights" VALUES ("1", "1004", "JFK", "DFW");
INSERT INTO "flights" VALUES ("2", "2001", "LAX", "JFK");
INSERT INTO "flights" VALUES ("2", "2002", "LAX", "ORD");
INSERT INTO "flights" VALUES ("2", "2003", "LAX", "SEA");
INSERT INTO "flights" VALUES ("3", "3001", "ORD", "ATL");
INSERT INTO "flights" VALUES ("3", "3002", "ORD", "DFW");
INSERT INTO "flights" VALUES ("3", "3003", "ORD", "MIA");
INSERT INTO "flights" VALUES ("3", "3004", "ORD", "BOS");
INSERT INTO "flights" VALUES ("3", "3005", "ORD", "DEN");
INSERT INTO "flights" VALUES ("4", "4001", "ATL", "JFK");
INSERT INTO "flights" VALUES ("4", "4002", "ATL", "LAX");
INSERT INTO "flights" VALUES ("4", "4003", "ATL", "SFO");
INSERT INTO "flights" VALUES ("4", "4004", "ATL", "SEA");
INSERT INTO "flights" VALUES ("4", "4005", "ATL", "MIA");
INSERT INTO "flights" VALUES ("4", "4006", "ATL", "BOS");
INSERT INTO "flights" VALUES ("5", "5001", "DFW", "JFK");
INSERT INTO "flights" VALUES ("5", "5002", "DFW", "LAX");
INSERT INTO "flights" VALUES ("5", "5003", "DFW", "ORD");
INSERT INTO "flights" VALUES ("5", "5004", "DFW", "SEA");
INSERT INTO "flights" VALUES ("5", "5005", "DFW", "MIA");
INSERT INTO "flights" VALUES ("5", "5006", "DFW", "BOS");
INSERT INTO "flights" VALUES ("5", "5007", "DFW", "DEN");
INSERT INTO "flights" VALUES ("5", "5008", "DFW", "SFO");
INSERT INTO "flights" VALUES ("5", "5009", "DFW", "ATL");