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,
PRIMARY KEY ("Airline", "FlightNo"),
FOREIGN KEY ("SourceAirport") REFERENCES "airports"("AirportCode")
);





INSERT INTO "airlines" VALUES ("1", "SkyHigh Airways", "USA");
INSERT INTO "airlines" VALUES ("2", "Global Wings", "UK");
INSERT INTO "airlines" VALUES ("3", "Sunset Flights", "Canada");
INSERT INTO "airlines" VALUES ("4", "AeroLink", "Australia");
INSERT INTO "airlines" VALUES ("5", "CloudNine Air", "Germany");
INSERT INTO "airports" VALUES ("AHD", "Ahmedabad International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport");
INSERT INTO "airports" VALUES ("YYZ", "Toronto Pearson International Airport");
INSERT INTO "airports" VALUES ("SYD", "Sydney Kingsford Smith Airport");
INSERT INTO "airports" VALUES ("FRA", "Frankfurt Airport");
INSERT INTO "flights" VALUES ("1", "101", "AHD");
INSERT INTO "flights" VALUES ("1", "102", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "LHR");
INSERT INTO "flights" VALUES ("2", "202", "AHD");
INSERT INTO "flights" VALUES ("3", "301", "YYZ");
INSERT INTO "flights" VALUES ("4", "401", "SYD");
INSERT INTO "flights" VALUES ("5", "501", "FRA");
INSERT INTO "flights" VALUES ("5", "502", "AHD");