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", "ANT", "Anthony Regional Airport", "USA");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport", "USA");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "Los Angeles International Airport", "USA");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Toronto Pearson International Airport", "Canada");
INSERT INTO "airports" VALUES ("Vancouver", "YVR", "Vancouver International Airport", "Canada");
INSERT INTO "airports" VALUES ("Mexico City", "MEX", "Mexico City International Airport", "Mexico");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport", "UK");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "airports" VALUES ("Anthony", "ANH", "Anthony International Airport", "USA");
INSERT INTO "airports" VALUES ("Anthony", "ANT2", "Anthony Small Airport", "USA");
INSERT INTO "flights" VALUES ("1", "101", "ANT");
INSERT INTO "flights" VALUES ("1", "102", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "YYZ");
INSERT INTO "flights" VALUES ("3", "301", "MEX");
INSERT INTO "flights" VALUES ("4", "401", "LHR");
INSERT INTO "flights" VALUES ("5", "501", "CDG");
INSERT INTO "flights" VALUES ("1", "103", "ANH");
INSERT INTO "flights" VALUES ("2", "202", "ANT2");