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" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
"Country" 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", "Delta Air Lines");
INSERT INTO "airlines" VALUES ("2", "American Airlines");
INSERT INTO "airlines" VALUES ("3", "United Airlines");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines");
INSERT INTO "airlines" VALUES ("5", "JetBlue Airways");
INSERT INTO "airports" VALUES ("Atlanta", "ATL", "USA");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "USA");
INSERT INTO "airports" VALUES ("New York", "JFK", "USA");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "USA");
INSERT INTO "airports" VALUES ("Austin", "ATO", "USA");
INSERT INTO "airports" VALUES ("Dallas", "DFW", "USA");
INSERT INTO "airports" VALUES ("Miami", "MIA", "USA");
INSERT INTO "airports" VALUES ("Denver", "DEN", "USA");
INSERT INTO "airports" VALUES ("Seattle", "SEA", "USA");
INSERT INTO "airports" VALUES ("Boston", "BOS", "USA");
INSERT INTO "flights" VALUES ("1", "101", "ATL", "ATO");
INSERT INTO "flights" VALUES ("1", "102", "ORD", "ATO");
INSERT INTO "flights" VALUES ("2", "201", "JFK", "ATO");
INSERT INTO "flights" VALUES ("2", "202", "LAX", "ORD");
INSERT INTO "flights" VALUES ("3", "301", "DFW", "ATO");
INSERT INTO "flights" VALUES ("3", "302", "MIA", "ATL");
INSERT INTO "flights" VALUES ("4", "401", "DEN", "ATO");
INSERT INTO "flights" VALUES ("4", "402", "SEA", "LAX");
INSERT INTO "flights" VALUES ("5", "501", "BOS", "ATO");
INSERT INTO "flights" VALUES ("5", "502", "ATL", "JFK");
INSERT INTO "flights" VALUES ("1", "103", "SEA", "ORD");
INSERT INTO "flights" VALUES ("2", "203", "MIA", "DFW");
INSERT INTO "flights" VALUES ("3", "303", "LAX", "SEA");
INSERT INTO "flights" VALUES ("4", "403", "ORD", "BOS");
INSERT INTO "flights" VALUES ("5", "503", "JFK", "DEN");