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 ("Aberdeen", "DAB", "Dabok Airport", "India");
INSERT INTO "airports" VALUES ("Ashley", "ASL", "Ashley Airport", "Australia");
INSERT INTO "airports" VALUES ("Aberdeen", "APG", "Phillips Army Airfield", "United States");
INSERT INTO "flights" VALUES ("101", "1001", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("101", "1002", "ABZ", "LHR");
INSERT INTO "flights" VALUES ("102", "2001", "LHR", "ASH");
INSERT INTO "flights" VALUES ("103", "3001", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("104", "4001", "CDG", "JFK");
INSERT INTO "flights" VALUES ("105", "5001", "ABZ", "ASH");
INSERT INTO "flights" VALUES ("106", "6001", "DAB", "ASH");
INSERT INTO "flights" VALUES ("107", "7001", "APG", "ASH");
INSERT INTO "flights" VALUES ("108", "8001", "ABZ", "ASL");