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

CREATE TABLE "airports" (
"City" TEXT,
"AirportCode" TEXT,
"AirportName" TEXT,
"Country" 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", "USA");
INSERT INTO "airlines" VALUES ("2", "Canada");
INSERT INTO "airlines" VALUES ("3", "UK");
INSERT INTO "airlines" VALUES ("4", "Germany");
INSERT INTO "airlines" VALUES ("5", "France");
INSERT INTO "airports" VALUES ("Alton", "ALN", "Alton International Airport", "USA");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F Kennedy International Airport", "USA");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Toronto Pearson International Airport", "Canada");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport", "UK");
INSERT INTO "airports" VALUES ("Berlin", "TXL", "Tegel Airport", "Germany");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "airports" VALUES ("Alton", "ALX", "Alton Regional Airport", "Canada");
INSERT INTO "flights" VALUES ("1", "101", "ALN", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "JFK", "ALN");
INSERT INTO "flights" VALUES ("2", "201", "YYZ", "ALN");
INSERT INTO "flights" VALUES ("2", "202", "ALN", "YYZ");
INSERT INTO "flights" VALUES ("3", "301", "LHR", "ALN");
INSERT INTO "flights" VALUES ("3", "302", "ALN", "LHR");
INSERT INTO "flights" VALUES ("4", "401", "TXL", "CDG");
INSERT INTO "flights" VALUES ("4", "402", "CDG", "TXL");
INSERT INTO "flights" VALUES ("5", "501", "ALX", "YYZ");
INSERT INTO "flights" VALUES ("5", "502", "YYZ", "ALX");