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" (
"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", "Delta Air Lines");
INSERT INTO "airlines" VALUES ("2", "American Airlines");
INSERT INTO "airlines" VALUES ("3", "United Airlines");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines");
INSERT INTO "airlines" VALUES ("5", "Alaska Airlines");
INSERT INTO "airports" VALUES ("APG", "Phillips Army Airfield", "United States");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport", "United States");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport", "United Kingdom");
INSERT INTO "airports" VALUES ("CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "airports" VALUES ("NRT", "Narita International Airport", "Japan");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport", "United States");
INSERT INTO "airports" VALUES ("ORD", "O'Hare International Airport", "United States");
INSERT INTO "flights" VALUES ("1", "100", "APG");
INSERT INTO "flights" VALUES ("1", "101", "APG");
INSERT INTO "flights" VALUES ("2", "200", "APG");
INSERT INTO "flights" VALUES ("2", "201", "JFK");
INSERT INTO "flights" VALUES ("3", "300", "LHR");
INSERT INTO "flights" VALUES ("3", "301", "APG");
INSERT INTO "flights" VALUES ("4", "400", "APG");
INSERT INTO "flights" VALUES ("4", "401", "SFO");
INSERT INTO "flights" VALUES ("5", "500", "ORD");
INSERT INTO "flights" VALUES ("5", "501", "APG");