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

CREATE TABLE "airports" (
"AirportCode" TEXT UNIQUE,
"AirportName" 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", "Air India", "India");
INSERT INTO "airlines" VALUES ("2", "SpiceJet", "India");
INSERT INTO "airlines" VALUES ("3", "IndiGo", "India");
INSERT INTO "airlines" VALUES ("4", "Emirates", "UAE");
INSERT INTO "airlines" VALUES ("5", "Qatar Airways", "Qatar");
INSERT INTO "airlines" VALUES ("6", "Lufthansa", "Germany");
INSERT INTO "airports" VALUES ("AHD", "Ahmedabad Airport");
INSERT INTO "airports" VALUES ("BOM", "Mumbai Airport");
INSERT INTO "airports" VALUES ("DEL", "Delhi Airport");
INSERT INTO "airports" VALUES ("BLR", "Bengaluru Airport");
INSERT INTO "airports" VALUES ("DXB", "Dubai International Airport");
INSERT INTO "airports" VALUES ("DOH", "Hamad International Airport");
INSERT INTO "airports" VALUES ("FRA", "Frankfurt Airport");
INSERT INTO "airports" VALUES ("CCU", "Kolkata Airport");
INSERT INTO "flights" VALUES ("1", "101", "AHD", "BOM");
INSERT INTO "flights" VALUES ("1", "102", "BOM", "DEL");
INSERT INTO "flights" VALUES ("2", "201", "AHD", "DEL");
INSERT INTO "flights" VALUES ("3", "301", "DEL", "BLR");
INSERT INTO "flights" VALUES ("4", "401", "DXB", "AHD");
INSERT INTO "flights" VALUES ("1", "103", "AHD", "CCU");
INSERT INTO "flights" VALUES ("5", "501", "DOH", "BOM");
INSERT INTO "flights" VALUES ("6", "601", "FRA", "DEL");
INSERT INTO "flights" VALUES ("2", "202", "BOM", "AHD");
INSERT INTO "flights" VALUES ("3", "302", "AHD", "BLR");