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", "SkyHigh Airways", "SHA");
INSERT INTO "airlines" VALUES ("2", "Global Wings", "GLW");
INSERT INTO "airlines" VALUES ("3", "AeroFly", "AFY");
INSERT INTO "airlines" VALUES ("4", "CloudJet", "CLJ");
INSERT INTO "airlines" VALUES ("5", "Sunset Airlines", "SSA");
INSERT INTO "airports" VALUES ("AHD", "Ashland Harbor Domestic");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International");
INSERT INTO "airports" VALUES ("ORD", "O'Hare International");
INSERT INTO "airports" VALUES ("ATL", "Hartsfield-Jackson Atlanta International");
INSERT INTO "airports" VALUES ("DFW", "Dallas/Fort Worth International");
INSERT INTO "flights" VALUES ("1", "101", "JFK", "AHD");
INSERT INTO "flights" VALUES ("1", "102", "AHD", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "ORD", "ATL");
INSERT INTO "flights" VALUES ("2", "202", "ATL", "AHD");
INSERT INTO "flights" VALUES ("3", "301", "LAX", "ORD");
INSERT INTO "flights" VALUES ("3", "302", "ORD", "LAX");
INSERT INTO "flights" VALUES ("4", "401", "DFW", "JFK");
INSERT INTO "flights" VALUES ("4", "402", "JFK", "DFW");
INSERT INTO "flights" VALUES ("5", "501", "AHD", "ORD");
INSERT INTO "flights" VALUES ("5", "502", "ORD", "AHD");