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 UNIQUE,
"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", "Mexico");
INSERT INTO "airlines" VALUES ("4", "UK");
INSERT INTO "airlines" VALUES ("5", "France");
INSERT INTO "airports" VALUES ("Anthony", "ANT1", "Anthony International Airport", "USA");
INSERT INTO "airports" VALUES ("Anthony", "ANT2", "Anthony Regional Airport", "USA");
INSERT INTO "airports" VALUES ("Springfield", "SPR1", "Springfield Airport", "USA");
INSERT INTO "airports" VALUES ("Dallas", "DAL1", "Dallas Fort Worth Airport", "USA");
INSERT INTO "airports" VALUES ("Toronto", "TOR1", "Toronto Pearson Airport", "Canada");
INSERT INTO "airports" VALUES ("Mexico City", "MEX1", "Mexico City International Airport", "Mexico");
INSERT INTO "airports" VALUES ("London", "LON1", "Heathrow Airport", "UK");
INSERT INTO "airports" VALUES ("Paris", "PAR1", "Charles de Gaulle Airport", "France");
INSERT INTO "flights" VALUES ("1", "101", "ANT1");
INSERT INTO "flights" VALUES ("1", "102", "SPR1");
INSERT INTO "flights" VALUES ("2", "201", "TOR1");
INSERT INTO "flights" VALUES ("3", "301", "MEX1");
INSERT INTO "flights" VALUES ("4", "401", "LON1");
INSERT INTO "flights" VALUES ("5", "501", "PAR1");
INSERT INTO "flights" VALUES ("1", "103", "ANT2");
INSERT INTO "flights" VALUES ("2", "202", "DAL1");