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", "SkyHigh Airways", "USA");
INSERT INTO "airlines" VALUES ("2", "Global Wings", "Canada");
INSERT INTO "airlines" VALUES ("3", "Pacific Air", "Australia");
INSERT INTO "airlines" VALUES ("4", "EuroFly", "Germany");
INSERT INTO "airlines" VALUES ("5", "TransContinental", "UK");
INSERT INTO "airports" VALUES ("CVO", "Corvallis Municipal Airport");
INSERT INTO "airports" VALUES ("APG", "Phillips Army Airfield");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("SYD", "Sydney Airport");
INSERT INTO "airports" VALUES ("FRA", "Frankfurt Airport");
INSERT INTO "airports" VALUES ("YYZ", "Toronto Pearson International Airport");
INSERT INTO "flights" VALUES ("1", "101", "CVO", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "CVO", "YYZ");
INSERT INTO "flights" VALUES ("2", "202", "YYZ", "LAX");
INSERT INTO "flights" VALUES ("3", "301", "SYD", "CVO");
INSERT INTO "flights" VALUES ("3", "302", "CVO", "SYD");
INSERT INTO "flights" VALUES ("4", "401", "APG", "FRA");
INSERT INTO "flights" VALUES ("4", "402", "FRA", "APG");
INSERT INTO "flights" VALUES ("5", "501", "LAX", "JFK");
INSERT INTO "flights" VALUES ("5", "502", "JFK", "LAX");
INSERT INTO "flights" VALUES ("5", "503", "CVO", "JFK");