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" (
"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 ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("ORD", "OHare International Airport");
INSERT INTO "airports" VALUES ("DFW", "Dallas/Fort Worth International Airport");
INSERT INTO "airports" VALUES ("DEN", "Denver International Airport");
INSERT INTO "airports" VALUES ("ATL", "Hartsfield-Jackson Atlanta International Airport");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport");
INSERT INTO "airports" VALUES ("MIA", "Miami International Airport");
INSERT INTO "airports" VALUES ("CLT", "Charlotte Douglas International Airport");
INSERT INTO "airports" VALUES ("SEA", "Seattle-Tacoma International Airport");
INSERT INTO "flights" VALUES ("101", "1001", "JFK", "LAX");
INSERT INTO "flights" VALUES ("101", "1002", "LAX", "JFK");
INSERT INTO "flights" VALUES ("102", "2001", "ORD", "DFW");
INSERT INTO "flights" VALUES ("102", "2002", "DFW", "ORD");
INSERT INTO "flights" VALUES ("103", "3001", "DEN", "ATL");
INSERT INTO "flights" VALUES ("103", "3002", "ATL", "DEN");
INSERT INTO "flights" VALUES ("104", "4001", "SFO", "MIA");
INSERT INTO "flights" VALUES ("104", "4002", "MIA", "SFO");
INSERT INTO "flights" VALUES ("105", "5001", "CLT", "SEA");
INSERT INTO "flights" VALUES ("105", "5002", "SEA", "CLT");
INSERT INTO "flights" VALUES ("101", "1003", "JFK", "ORD");
INSERT INTO "flights" VALUES ("102", "2003", "LAX", "DEN");
INSERT INTO "flights" VALUES ("103", "3003", "ORD", "SFO");
INSERT INTO "flights" VALUES ("104", "4003", "DFW", "MIA");
INSERT INTO "flights" VALUES ("105", "5003", "ATL", "CLT");