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,
PRIMARY KEY ("Airline", "FlightNo"),
FOREIGN KEY ("SourceAirport") 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", "Australia");
INSERT INTO "airlines" VALUES ("5", "Germany");
INSERT INTO "airports" VALUES ("Alton", "ALN", "Alton 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 ("Sydney", "SYD", "Sydney Kingsford Smith Airport", "Australia");
INSERT INTO "airports" VALUES ("Berlin", "TXL", "Berlin Tegel Airport", "Germany");
INSERT INTO "airports" VALUES ("Alton", "ALX", "Alton Regional Airport", "USA");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "flights" VALUES ("1", "100", "ALN");
INSERT INTO "flights" VALUES ("1", "101", "YYZ");
INSERT INTO "flights" VALUES ("2", "200", "YYZ");
INSERT INTO "flights" VALUES ("3", "300", "LHR");
INSERT INTO "flights" VALUES ("4", "400", "SYD");
INSERT INTO "flights" VALUES ("5", "500", "TXL");
INSERT INTO "flights" VALUES ("1", "102", "ALX");
INSERT INTO "flights" VALUES ("2", "201", "CDG");