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,
"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", "Southwest Airlines", "SWA");
INSERT INTO "airlines" VALUES ("2", "Delta Air Lines", "DAL");
INSERT INTO "airlines" VALUES ("3", "United Airlines", "UAL");
INSERT INTO "airlines" VALUES ("4", "American Airlines", "AAL");
INSERT INTO "airlines" VALUES ("5", "Alaska Airlines", "ASA");
INSERT INTO "airlines" VALUES ("6", "Spirit Airlines", "NKS");
INSERT INTO "airlines" VALUES ("7", "Frontier Airlines", "FFT");
INSERT INTO "airports" VALUES ("Ahmedabad", "AHD");
INSERT INTO "airports" VALUES ("Dallas/Fort Worth", "DFW");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX");
INSERT INTO "airports" VALUES ("Chicago", "ORD");
INSERT INTO "airports" VALUES ("Atlanta", "ATL");
INSERT INTO "airports" VALUES ("Seattle", "SEA");
INSERT INTO "airports" VALUES ("Denver", "DEN");
INSERT INTO "airports" VALUES ("New York", "JFK");
INSERT INTO "airports" VALUES ("Houston", "IAH");
INSERT INTO "flights" VALUES ("1", "101", "AHD", "DFW");
INSERT INTO "flights" VALUES ("1", "102", "DFW", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "AHD", "ATL");
INSERT INTO "flights" VALUES ("2", "202", "ATL", "ORD");
INSERT INTO "flights" VALUES ("3", "301", "LAX", "JFK");
INSERT INTO "flights" VALUES ("4", "401", "AHD", "SEA");
INSERT INTO "flights" VALUES ("5", "501", "DEN", "IAH");
INSERT INTO "flights" VALUES ("6", "601", "AHD", "ORD");
INSERT INTO "flights" VALUES ("7", "701", "DFW", "DEN");
INSERT INTO "flights" VALUES ("1", "103", "AHD", "JFK");
INSERT INTO "flights" VALUES ("2", "203", "LAX", "AHD");