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 "airports" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
"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 "airports" VALUES ("Aberdeen", "ABZ", "Aberdeen International Airport", "United Kingdom");
INSERT INTO "airports" VALUES ("Ashley", "ASH", "Ashley Municipal Airport", "United States");
INSERT INTO "airports" VALUES ("London", "LHR", "Heathrow Airport", "United Kingdom");
INSERT INTO "airports" VALUES ("Paris", "CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport", "United States");
INSERT INTO "airports" VALUES ("Tokyo", "NRT", "Narita International Airport", "Japan");
INSERT INTO "airports" VALUES ("Sydney", "SYD", "Sydney Airport", "Australia");
INSERT INTO "airports" VALUES ("Berlin", "BER", "Berlin Brandenburg Airport", "Germany");
INSERT INTO "airports" VALUES ("Rome", "FCO", "Leonardo da Vinci–Fiumicino Airport", "Italy");
INSERT INTO "airports" VALUES ("Dubai", "DXB", "Dubai International Airport", "United Arab Emirates");
INSERT INTO "flights" VALUES ("101", "1", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("101", "2", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("102", "3", "ABZ", "LHR");
INSERT INTO "flights" VALUES ("103", "4", "LHR", "ASH");
INSERT INTO "flights" VALUES ("104", "5", "ASH", "CDG");
INSERT INTO "flights" VALUES ("105", "6", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("106", "7", "JFK", "ABZ");
INSERT INTO "flights" VALUES ("107", "8", "ASH", "JFK");
INSERT INTO "flights" VALUES ("108", "9", "ABZ", "NRT");
INSERT INTO "flights" VALUES ("109", "10", "SYD", "ASH");
INSERT INTO "flights" VALUES ("110", "11", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("111", "12", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("112", "13", "BER", "ABZ");
INSERT INTO "flights" VALUES ("113", "14", "ASH", "FCO");
INSERT INTO "flights" VALUES ("114", "15", "DXB", "ABZ");
INSERT INTO "flights" VALUES ("115", "16", "ABZ", "DXB");