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 ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("ORD", "O'Hare International Airport");
INSERT INTO "airports" VALUES ("ATL", "Hartsfield-Jackson Atlanta International Airport");
INSERT INTO "airports" VALUES ("AKL", "Auckland Airport");
INSERT INTO "airports" VALUES ("AKN", "King Salmon Airport");
INSERT INTO "airports" VALUES ("AKR", "Akure Airport");
INSERT INTO "airports" VALUES ("XYZ", "Fictional Airport XYZ");
INSERT INTO "airports" VALUES ("AKO1", "Fake Airport Similar Code");
INSERT INTO "flights" VALUES ("1", "100", "AKO", "LAX");
INSERT INTO "flights" VALUES ("1", "101", "LAX", "AKO");
INSERT INTO "flights" VALUES ("2", "200", "JFK", "ORD");
INSERT INTO "flights" VALUES ("2", "201", "ORD", "ATL");
INSERT INTO "flights" VALUES ("3", "300", "AKL", "AKO");
INSERT INTO "flights" VALUES ("3", "301", "AKO", "AKN");
INSERT INTO "flights" VALUES ("4", "400", "AKR", "XYZ");
INSERT INTO "flights" VALUES ("4", "401", "XYZ", "AKO1");