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 UNIQUE,
"AirportName" TEXT,
"Country" 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 Airlines", "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 "airports" VALUES ("ASY", "Ashley Airport", "USA");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport", "USA");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport", "USA");
INSERT INTO "airports" VALUES ("ORD", "O'Hare International Airport", "USA");
INSERT INTO "airports" VALUES ("DFW", "Dallas/Fort Worth International Airport", "USA");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport", "USA");
INSERT INTO "airports" VALUES ("LHR", "London Heathrow Airport", "UK");
INSERT INTO "airports" VALUES ("CDG", "Charles de Gaulle Airport", "France");
INSERT INTO "flights" VALUES ("1", "101", "LAX", "ASY");
INSERT INTO "flights" VALUES ("1", "102", "JFK", "ASY");
INSERT INTO "flights" VALUES ("1", "103", "ORD", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "DFW", "JFK");
INSERT INTO "flights" VALUES ("1", "104", "SFO", "ASY");
INSERT INTO "flights" VALUES ("3", "301", "LAX", "ORD");
INSERT INTO "flights" VALUES ("1", "105", "LHR", "ASY");
INSERT INTO "flights" VALUES ("4", "401", "CDG", "DFW");
INSERT INTO "flights" VALUES ("1", "106", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "107", "ORD", "ASY");
INSERT INTO "flights" VALUES ("2", "202", "LAX", "ASY");
INSERT INTO "flights" VALUES ("3", "302", "JFK", "ASY");
INSERT INTO "flights" VALUES ("1", "108", "DFW", "ASY");
INSERT INTO "flights" VALUES ("5", "501", "SFO", "JFK");