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", "SkyHigh Airways", "USA");
INSERT INTO "airlines" VALUES ("2", "Global Wings", "UK");
INSERT INTO "airlines" VALUES ("3", "Sunshine Flights", "Australia");
INSERT INTO "airlines" VALUES ("4", "Northern Air", "Canada");
INSERT INTO "airlines" VALUES ("5", "Eastern Express", "Japan");
INSERT INTO "airports" VALUES ("AHD", "Ahmedabad International Airport");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport");
INSERT INTO "airports" VALUES ("SYD", "Sydney Kingsford Smith Airport");
INSERT INTO "airports" VALUES ("YYZ", "Toronto Pearson International Airport");
INSERT INTO "airports" VALUES ("NRT", "Narita International Airport");
INSERT INTO "airports" VALUES ("DEL", "Indira Gandhi International Airport");
INSERT INTO "flights" VALUES ("1", "101", "AHD", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "AHD");
INSERT INTO "flights" VALUES ("2", "201", "AHD", "LHR");
INSERT INTO "flights" VALUES ("2", "202", "LHR", "AHD");
INSERT INTO "flights" VALUES ("3", "301", "SYD", "AHD");
INSERT INTO "flights" VALUES ("3", "302", "AHD", "SYD");
INSERT INTO "flights" VALUES ("4", "401", "YYZ", "NRT");
INSERT INTO "flights" VALUES ("4", "402", "NRT", "YYZ");
INSERT INTO "flights" VALUES ("5", "501", "DEL", "AHD");
INSERT INTO "flights" VALUES ("5", "502", "AHD", "DEL");
INSERT INTO "flights" VALUES ("5", "503", "AHD", "LHR");