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

CREATE TABLE "airports" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
"Country" TEXT,
PRIMARY KEY ("AirportCode")
);

CREATE TABLE "flights" (
"Airline" INT,
"FlightNo" INT,
"DestAirport" TEXT,
PRIMARY KEY ("Airline", "FlightNo"),
FOREIGN KEY ("DestAirport") REFERENCES "airports"("AirportCode")
);





INSERT INTO "airlines" VALUES ("1", "Delta Airlines");
INSERT INTO "airlines" VALUES ("2", "United Airlines");
INSERT INTO "airlines" VALUES ("3", "American Airlines");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines");
INSERT INTO "airlines" VALUES ("5", "JetBlue Airways");
INSERT INTO "airports" VALUES ("New York", "JFK", "USA");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "USA");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "USA");
INSERT INTO "airports" VALUES ("Washington", "DCA", "USA");
INSERT INTO "airports" VALUES ("Annapolis", "APG", "USA");
INSERT INTO "airports" VALUES ("Toronto", "YYZ", "Canada");
INSERT INTO "airports" VALUES ("London", "LHR", "UK");
INSERT INTO "airports" VALUES ("Paris", "CDG", "France");
INSERT INTO "flights" VALUES ("1", "101", "APG");
INSERT INTO "flights" VALUES ("1", "102", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "APG");
INSERT INTO "flights" VALUES ("2", "202", "LAX");
INSERT INTO "flights" VALUES ("3", "301", "ORD");
INSERT INTO "flights" VALUES ("3", "302", "APG");
INSERT INTO "flights" VALUES ("4", "401", "DCA");
INSERT INTO "flights" VALUES ("4", "402", "APG");
INSERT INTO "flights" VALUES ("5", "501", "YYZ");
INSERT INTO "flights" VALUES ("5", "502", "LHR");
INSERT INTO "flights" VALUES ("5", "503", "APG");