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,
"Abbreviation" TEXT,
PRIMARY KEY ("uid")
);

CREATE TABLE "airports" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
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", "AA");
INSERT INTO "airlines" VALUES ("2", "DL");
INSERT INTO "airlines" VALUES ("3", "UA");
INSERT INTO "airlines" VALUES ("4", "SW");
INSERT INTO "airlines" VALUES ("5", "B6");
INSERT INTO "airlines" VALUES ("6", "AS");
INSERT INTO "airports" VALUES ("Atlanta", "ATL");
INSERT INTO "airports" VALUES ("Chicago", "ORD");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX");
INSERT INTO "airports" VALUES ("New York", "JFK");
INSERT INTO "airports" VALUES ("Dallas", "DFW");
INSERT INTO "airports" VALUES ("Houston", "IAH");
INSERT INTO "airports" VALUES ("Orlando", "MCO");
INSERT INTO "airports" VALUES ("Denver", "DEN");
INSERT INTO "airports" VALUES ("Charlotte", "CLT");
INSERT INTO "airports" VALUES ("San Francisco", "SFO");
INSERT INTO "airports" VALUES ("Austin", "ATO");
INSERT INTO "airports" VALUES ("Miami", "MIA");
INSERT INTO "airports" VALUES ("Seattle", "SEA");
INSERT INTO "flights" VALUES ("1", "101", "ATL", "ATO");
INSERT INTO "flights" VALUES ("1", "102", "ORD", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "JFK", "ATO");
INSERT INTO "flights" VALUES ("2", "202", "DFW", "ORD");
INSERT INTO "flights" VALUES ("3", "301", "IAH", "MCO");
INSERT INTO "flights" VALUES ("3", "302", "DEN", "ATO");
INSERT INTO "flights" VALUES ("4", "401", "CLT", "SFO");
INSERT INTO "flights" VALUES ("4", "402", "LAX", "JFK");
INSERT INTO "flights" VALUES ("5", "501", "MCO", "DFW");
INSERT INTO "flights" VALUES ("5", "502", "SFO", "ATL");
INSERT INTO "flights" VALUES ("6", "601", "ATO", "MIA");
INSERT INTO "flights" VALUES ("6", "602", "SEA", "DEN");
INSERT INTO "flights" VALUES ("1", "103", "JFK", "ATO");
INSERT INTO "flights" VALUES ("2", "203", "LAX", "ATO");
INSERT INTO "flights" VALUES ("3", "303", "ORD", "ATO");
INSERT INTO "flights" VALUES ("4", "403", "DFW", "ATO");
INSERT INTO "flights" VALUES ("5", "503", "IAH", "ATO");
INSERT INTO "flights" VALUES ("6", "603", "MCO", "ATO");
INSERT INTO "flights" VALUES ("1", "104", "DEN", "JFK");
INSERT INTO "flights" VALUES ("2", "204", "CLT", "LAX");
INSERT INTO "flights" VALUES ("3", "304", "SFO", "ORD");
INSERT INTO "flights" VALUES ("4", "404", "MIA", "DFW");
INSERT INTO "flights" VALUES ("5", "504", "SEA", "IAH");
INSERT INTO "flights" VALUES ("6", "604", "ATL", "MCO");