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,
"Abbreviation" 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", "UA");
INSERT INTO "airlines" VALUES ("2", "Delta Air Lines", "DL");
INSERT INTO "airlines" VALUES ("3", "American Airlines", "AA");
INSERT INTO "airlines" VALUES ("4", "Southwest Airlines", "WN");
INSERT INTO "airlines" VALUES ("5", "Alaska Airlines", "AS");
INSERT INTO "airlines" VALUES ("6", "JetBlue Airways", "B6");
INSERT INTO "airlines" VALUES ("7", "Spirit Airlines", "NK");
INSERT INTO "airports" VALUES ("CVO", "Corvallis Municipal Airport");
INSERT INTO "airports" VALUES ("APG", "Phillips Army Airfield");
INSERT INTO "airports" VALUES ("PDX", "Portland International Airport");
INSERT INTO "airports" VALUES ("SEA", "Seattle-Tacoma International Airport");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("ORD", "OHare International Airport");
INSERT INTO "airports" VALUES ("DFW", "Dallas/Fort Worth International Airport");
INSERT INTO "airports" VALUES ("MIA", "Miami International Airport");
INSERT INTO "flights" VALUES ("1", "101", "CVO", "PDX");
INSERT INTO "flights" VALUES ("1", "102", "CVO", "SEA");
INSERT INTO "flights" VALUES ("2", "201", "CVO", "LAX");
INSERT INTO "flights" VALUES ("3", "301", "CVO", "SFO");
INSERT INTO "flights" VALUES ("4", "401", "APG", "JFK");
INSERT INTO "flights" VALUES ("4", "402", "APG", "ORD");
INSERT INTO "flights" VALUES ("5", "501", "CVO", "DFW");
INSERT INTO "flights" VALUES ("5", "502", "APG", "MIA");
INSERT INTO "flights" VALUES ("6", "601", "CVO", "JFK");
INSERT INTO "flights" VALUES ("7", "701", "APG", "LAX");
INSERT INTO "flights" VALUES ("1", "103", "APG", "PDX");
INSERT INTO "flights" VALUES ("2", "202", "APG", "SEA");
INSERT INTO "flights" VALUES ("3", "302", "APG", "LAX");