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", "Skyways", "SKY");
INSERT INTO "airlines" VALUES ("2", "Global Air", "GLB");
INSERT INTO "airlines" VALUES ("3", "Trans Continental", "TCO");
INSERT INTO "airlines" VALUES ("4", "AeroFly", "AFY");
INSERT INTO "airlines" VALUES ("5", "JetStream", "JST");
INSERT INTO "airports" VALUES ("AHD", "Ashland Airport");
INSERT INTO "airports" VALUES ("BTR", "Baton Rouge Airport");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International");
INSERT INTO "airports" VALUES ("JFK", "John F Kennedy International");
INSERT INTO "airports" VALUES ("ORD", "Chicago O'Hare International");
INSERT INTO "airports" VALUES ("MIA", "Miami International");
INSERT INTO "flights" VALUES ("1", "101", "LAX", "AHD");
INSERT INTO "flights" VALUES ("1", "102", "AHD", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "ORD", "AHD");
INSERT INTO "flights" VALUES ("2", "202", "BTR", "MIA");
INSERT INTO "flights" VALUES ("3", "301", "JFK", "ORD");
INSERT INTO "flights" VALUES ("3", "302", "MIA", "AHD");
INSERT INTO "flights" VALUES ("4", "401", "AHD", "BTR");
INSERT INTO "flights" VALUES ("5", "501", "LAX", "JFK");
INSERT INTO "flights" VALUES ("5", "502", "BTR", "ORD");