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", "United Airlines", "UA");
INSERT INTO "airlines" VALUES ("2", "American Airlines", "AA");
INSERT INTO "airlines" VALUES ("3", "Delta Airlines", "DL");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines", "SW");
INSERT INTO "airlines" VALUES ("5", "Lufthansa", "LH");
INSERT INTO "airports" VALUES ("Ahmedabad", "AHD");
INSERT INTO "airports" VALUES ("Mumbai", "BOM");
INSERT INTO "airports" VALUES ("Delhi", "DEL");
INSERT INTO "airports" VALUES ("Bangalore", "BLR");
INSERT INTO "airports" VALUES ("Chennai", "MAA");
INSERT INTO "airports" VALUES ("Hyderabad", "HYD");
INSERT INTO "flights" VALUES ("1", "101", "AHD", "BOM");
INSERT INTO "flights" VALUES ("1", "102", "AHD", "DEL");
INSERT INTO "flights" VALUES ("1", "103", "BOM", "AHD");
INSERT INTO "flights" VALUES ("2", "201", "AHD", "BLR");
INSERT INTO "flights" VALUES ("2", "202", "DEL", "MAA");
INSERT INTO "flights" VALUES ("1", "104", "AHD", "HYD");
INSERT INTO "flights" VALUES ("3", "301", "BOM", "DEL");
INSERT INTO "flights" VALUES ("1", "105", "AHD", "BOM");
INSERT INTO "flights" VALUES ("4", "401", "BLR", "MAA");
INSERT INTO "flights" VALUES ("1", "106", "AHD", "DEL");
INSERT INTO "flights" VALUES ("5", "501", "DEL", "BOM");