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", "Delta Airlines", "DL");
INSERT INTO "airlines" VALUES ("3", "American Airlines", "AA");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines", "WN");
INSERT INTO "airlines" VALUES ("5", "Alaska Airlines", "AS");
INSERT INTO "airlines" VALUES ("6", "JetBlue Airways", "B6");
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 ("Kolkata", "CCU");
INSERT INTO "airports" VALUES ("Hyderabad", "HYD");
INSERT INTO "airports" VALUES ("Chicago", "ORD");
INSERT INTO "airports" VALUES ("New York", "JFK");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX");
INSERT INTO "flights" VALUES ("1", "101", "AHD", "BOM");
INSERT INTO "flights" VALUES ("1", "102", "AHD", "DEL");
INSERT INTO "flights" VALUES ("1", "103", "AHD", "BLR");
INSERT INTO "flights" VALUES ("1", "104", "BOM", "AHD");
INSERT INTO "flights" VALUES ("1", "105", "DEL", "AHD");
INSERT INTO "flights" VALUES ("2", "201", "AHD", "MAA");
INSERT INTO "flights" VALUES ("2", "202", "CCU", "AHD");
INSERT INTO "flights" VALUES ("3", "301", "AHD", "HYD");
INSERT INTO "flights" VALUES ("3", "302", "HYD", "AHD");
INSERT INTO "flights" VALUES ("1", "106", "AHD", "ORD");
INSERT INTO "flights" VALUES ("1", "107", "AHD", "JFK");
INSERT INTO "flights" VALUES ("4", "401", "LAX", "AHD");
INSERT INTO "flights" VALUES ("5", "501", "AHD", "LAX");
INSERT INTO "flights" VALUES ("6", "601", "AHD", "JFK");
INSERT INTO "flights" VALUES ("1", "108", "AHD", "BOM");
INSERT INTO "flights" VALUES ("1", "109", "AHD", "DEL");