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" (
"AirportCode" TEXT,
"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", "Southwest Airlines");
INSERT INTO "airlines" VALUES ("2", "Delta Air Lines");
INSERT INTO "airlines" VALUES ("3", "United Airlines");
INSERT INTO "airlines" VALUES ("4", "American Airlines");
INSERT INTO "airlines" VALUES ("5", "Alaska Airlines");
INSERT INTO "airlines" VALUES ("6", "JetBlue Airways");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("ORD", "OHare International Airport");
INSERT INTO "airports" VALUES ("DFW", "Dallas/Fort Worth International Airport");
INSERT INTO "airports" VALUES ("AHD", "Ardmore Downtown Executive Airport");
INSERT INTO "airports" VALUES ("ATL", "Hartsfield-Jackson Atlanta International Airport");
INSERT INTO "airports" VALUES ("DEN", "Denver International Airport");
INSERT INTO "flights" VALUES ("1", "101", "LAX", "AHD");
INSERT INTO "flights" VALUES ("2", "202", "JFK", "LAX");
INSERT INTO "flights" VALUES ("3", "303", "ORD", "AHD");
INSERT INTO "flights" VALUES ("4", "404", "DFW", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "AHD", "LAX");
INSERT INTO "flights" VALUES ("5", "505", "LAX", "ATL");
INSERT INTO "flights" VALUES ("6", "606", "JFK", "DEN");
INSERT INTO "flights" VALUES ("2", "203", "ATL", "AHD");
INSERT INTO "flights" VALUES ("4", "405", "AHD", "DFW");
INSERT INTO "flights" VALUES ("3", "304", "DEN", "ORD");