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,
"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", "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", "Alaska Airlines");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "O'Hare International Airport");
INSERT INTO "airports" VALUES ("Atlanta", "ATL", "Hartsfield-Jackson Atlanta International Airport");
INSERT INTO "airports" VALUES ("Dallas", "DFW", "Dallas/Fort Worth International Airport");
INSERT INTO "airports" VALUES ("Denver", "DEN", "Denver International Airport");
INSERT INTO "airports" VALUES ("San Francisco", "SFO", "San Francisco International Airport");
INSERT INTO "airports" VALUES ("Seattle", "SEA", "Seattle-Tacoma International Airport");
INSERT INTO "airports" VALUES ("Miami", "MIA", "Miami International Airport");
INSERT INTO "airports" VALUES ("Boston", "BOS", "Logan International Airport");
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", "ATL");
INSERT INTO "flights" VALUES ("3", "3001", "ORD", "JFK");
INSERT INTO "flights" VALUES ("3", "3002", "ORD", "LAX");
INSERT INTO "flights" VALUES ("3", "3003", "ORD", "ATL");
INSERT INTO "flights" VALUES ("3", "3004", "ORD", "DFW");
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", "ORD");
INSERT INTO "flights" VALUES ("4", "4004", "ATL", "DFW");
INSERT INTO "flights" VALUES ("4", "4005", "ATL", "DEN");
INSERT INTO "flights" VALUES ("4", "4006", "ATL", "SFO");
INSERT INTO "flights" VALUES ("5", "5001", "SEA", "SFO");
INSERT INTO "flights" VALUES ("5", "5002", "SEA", "DEN");
INSERT INTO "flights" VALUES ("5", "5003", "SEA", "ORD");
INSERT INTO "flights" VALUES ("5", "5004", "SEA", "ATL");
INSERT INTO "flights" VALUES ("5", "5005", "SEA", "MIA");
INSERT INTO "flights" VALUES ("5", "5006", "SEA", "BOS");
INSERT INTO "flights" VALUES ("5", "5007", "SEA", "JFK");
INSERT INTO "flights" VALUES ("5", "5008", "SEA", "DFW");
INSERT INTO "flights" VALUES ("5", "5009", "SEA", "LAX");
INSERT INTO "flights" VALUES ("5", "5010", "SEA", "SFO");