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 "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 "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 ("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 "airports" VALUES ("Atlanta", "ATL", "Hartsfield-Jackson Atlanta International Airport");
INSERT INTO "flights" VALUES ("1", "101", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "ORD");
INSERT INTO "flights" VALUES ("1", "103", "ORD", "DFW");
INSERT INTO "flights" VALUES ("1", "104", "DFW", "DEN");
INSERT INTO "flights" VALUES ("1", "105", "DEN", "SFO");
INSERT INTO "flights" VALUES ("1", "106", "SFO", "SEA");
INSERT INTO "flights" VALUES ("1", "107", "SEA", "MIA");
INSERT INTO "flights" VALUES ("1", "108", "MIA", "BOS");
INSERT INTO "flights" VALUES ("1", "109", "BOS", "ATL");
INSERT INTO "flights" VALUES ("1", "110", "ATL", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "JFK", "ORD");
INSERT INTO "flights" VALUES ("2", "202", "ORD", "SFO");
INSERT INTO "flights" VALUES ("2", "203", "SFO", "MIA");
INSERT INTO "flights" VALUES ("2", "204", "MIA", "ATL");
INSERT INTO "flights" VALUES ("2", "205", "ATL", "DEN");
INSERT INTO "flights" VALUES ("3", "301", "LAX", "SEA");
INSERT INTO "flights" VALUES ("3", "302", "SEA", "BOS");
INSERT INTO "flights" VALUES ("3", "303", "BOS", "DFW");
INSERT INTO "flights" VALUES ("3", "304", "DFW", "JFK");
INSERT INTO "flights" VALUES ("4", "401", "DEN", "LAX");
INSERT INTO "flights" VALUES ("4", "402", "LAX", "MIA");
INSERT INTO "flights" VALUES ("5", "501", "ATL", "ORD");
INSERT INTO "flights" VALUES ("6", "601", "BOS", "SEA");