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,
"Country" TEXT,
PRIMARY KEY ("uid")
);

CREATE TABLE "airports" (
"City" TEXT,
"AirportCode" TEXT UNIQUE,
"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", "USA");
INSERT INTO "airlines" VALUES ("2", "Canada");
INSERT INTO "airlines" VALUES ("3", "Mexico");
INSERT INTO "airlines" VALUES ("4", "UK");
INSERT INTO "airlines" VALUES ("5", "Germany");
INSERT INTO "airports" VALUES ("Anthony", "ANY", "Anthony Regional Airport");
INSERT INTO "airports" VALUES ("New York", "JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("Los Angeles", "LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("Chicago", "ORD", "O'Hare International Airport");
INSERT INTO "airports" VALUES ("Houston", "IAH", "George Bush Intercontinental Airport");
INSERT INTO "airports" VALUES ("Dallas", "DFW", "Dallas/Fort Worth International Airport");
INSERT INTO "airports" VALUES ("Anthony", "ATY", "Anthony Municipal Airport");
INSERT INTO "airports" VALUES ("Miami", "MIA", "Miami International Airport");
INSERT INTO "airports" VALUES ("San Francisco", "SFO", "San Francisco International Airport");
INSERT INTO "airports" VALUES ("Denver", "DEN", "Denver International Airport");
INSERT INTO "flights" VALUES ("1", "101", "JFK", "LAX");
INSERT INTO "flights" VALUES ("1", "102", "LAX", "JFK");
INSERT INTO "flights" VALUES ("2", "201", "ORD", "DFW");
INSERT INTO "flights" VALUES ("2", "202", "DFW", "ORD");
INSERT INTO "flights" VALUES ("3", "301", "IAH", "ANY");
INSERT INTO "flights" VALUES ("3", "302", "ANY", "IAH");
INSERT INTO "flights" VALUES ("4", "401", "JFK", "ATY");
INSERT INTO "flights" VALUES ("4", "402", "ATY", "JFK");
INSERT INTO "flights" VALUES ("5", "501", "MIA", "SFO");
INSERT INTO "flights" VALUES ("5", "502", "SFO", "MIA");