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

CREATE TABLE "airports" (
"AirportCode" TEXT,
"AirportName" 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 "airlines" VALUES ("1", "United Airlines", "USA");
INSERT INTO "airlines" VALUES ("2", "Delta Airlines", "USA");
INSERT INTO "airlines" VALUES ("3", "Lufthansa", "Germany");
INSERT INTO "airlines" VALUES ("4", "Air France", "France");
INSERT INTO "airlines" VALUES ("5", "British Airways", "UK");
INSERT INTO "airlines" VALUES ("6", "Southwest Airlines", "USA");
INSERT INTO "airlines" VALUES ("7", "Emirates", "UAE");
INSERT INTO "airports" VALUES ("APG", "Phillips Army Airfield");
INSERT INTO "airports" VALUES ("CVO", "Albany Airport");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("ORD", "O'Hare International Airport");
INSERT INTO "airports" VALUES ("DFW", "Dallas/Fort Worth International Airport");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport");
INSERT INTO "airports" VALUES ("CDG", "Charles de Gaulle Airport");
INSERT INTO "airports" VALUES ("FRA", "Frankfurt Airport");
INSERT INTO "flights" VALUES ("1", "101", "APG", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "CVO", "JFK");
INSERT INTO "flights" VALUES ("1", "103", "LAX", "APG");
INSERT INTO "flights" VALUES ("2", "201", "APG", "ORD");
INSERT INTO "flights" VALUES ("2", "202", "CVO", "DFW");
INSERT INTO "flights" VALUES ("3", "301", "APG", "FRA");
INSERT INTO "flights" VALUES ("3", "302", "CVO", "CDG");
INSERT INTO "flights" VALUES ("4", "401", "APG", "CDG");
INSERT INTO "flights" VALUES ("5", "501", "CVO", "LHR");
INSERT INTO "flights" VALUES ("6", "601", "APG", "SFO");
INSERT INTO "flights" VALUES ("7", "701", "LAX", "APG");
INSERT INTO "flights" VALUES ("7", "702", "JFK", "CVO");
INSERT INTO "flights" VALUES ("1", "104", "APG", "SFO");
INSERT INTO "flights" VALUES ("1", "105", "CVO", "ORD");
INSERT INTO "flights" VALUES ("2", "203", "APG", "JFK");
INSERT INTO "flights" VALUES ("3", "303", "CVO", "FRA");
INSERT INTO "flights" VALUES ("4", "402", "CVO", "CDG");
INSERT INTO "flights" VALUES ("5", "502", "APG", "LHR");