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 ("AKO", "Colorado Plains Regional Airport");
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 ("ATL", "Hartsfield-Jackson Atlanta International Airport");
INSERT INTO "airports" VALUES ("DEN", "Denver International Airport");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport");
INSERT INTO "airports" VALUES ("SEA", "Seattle-Tacoma International Airport");
INSERT INTO "airports" VALUES ("MIA", "Miami International Airport");
INSERT INTO "airports" VALUES ("BOS", "Logan International Airport");
INSERT INTO "flights" VALUES ("1", "101", "AKO", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "JFK", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "LAX", "ORD");
INSERT INTO "flights" VALUES ("2", "202", "ORD", "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", "AKO");