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", "United Airlines", "USA");
INSERT INTO "airlines" VALUES ("2", "Delta Airlines", "USA");
INSERT INTO "airlines" VALUES ("3", "Emirates", "UAE");
INSERT INTO "airlines" VALUES ("4", "Lufthansa", "Germany");
INSERT INTO "airlines" VALUES ("5", "Air Canada", "Canada");
INSERT INTO "airports" VALUES ("AHD", "Ahmedabad Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport");
INSERT INTO "airports" VALUES ("DXB", "Dubai International Airport");
INSERT INTO "airports" VALUES ("YYZ", "Toronto Pearson International Airport");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport");
INSERT INTO "flights" VALUES ("1", "101", "AHD", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "AHD", "LHR");
INSERT INTO "flights" VALUES ("1", "103", "AHD", "DXB");
INSERT INTO "flights" VALUES ("1", "104", "JFK", "AHD");
INSERT INTO "flights" VALUES ("1", "105", "SFO", "AHD");
INSERT INTO "flights" VALUES ("2", "201", "AHD", "YYZ");
INSERT INTO "flights" VALUES ("2", "202", "JFK", "LHR");
INSERT INTO "flights" VALUES ("3", "301", "DXB", "AHD");
INSERT INTO "flights" VALUES ("4", "401", "LHR", "AHD");
INSERT INTO "flights" VALUES ("5", "501", "YYZ", "AHD");
INSERT INTO "flights" VALUES ("1", "106", "AHD", "SFO");
INSERT INTO "flights" VALUES ("1", "107", "AHD", "YYZ");