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,
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", "Air Alpha");
INSERT INTO "airlines" VALUES ("2", "Beta Airways");
INSERT INTO "airlines" VALUES ("3", "Gamma Flights");
INSERT INTO "airports" VALUES ("AAA", "Alpha International", "CountryA");
INSERT INTO "airports" VALUES ("BBB", "Beta Regional", "CountryB");
INSERT INTO "airports" VALUES ("CCC", "Gamma City Airport", "CountryC");
INSERT INTO "airports" VALUES ("DDD", "Delta Domestic", "CountryD");
INSERT INTO "airports" VALUES ("EEE", "Epsilon Airfield", "CountryE");
INSERT INTO "airports" VALUES ("FFF", "Zeta Hub", "CountryF");
INSERT INTO "airports" VALUES ("GGG", "Eta Terminal", "CountryG");
INSERT INTO "flights" VALUES ("1", "101", "AAA", "BBB");
INSERT INTO "flights" VALUES ("1", "102", "BBB", "CCC");
INSERT INTO "flights" VALUES ("2", "201", "CCC", "AAA");
INSERT INTO "flights" VALUES ("2", "202", "BBB", "AAA");
INSERT INTO "flights" VALUES ("3", "301", "AAA", "CCC");
INSERT INTO "flights" VALUES ("3", "302", "CCC", "BBB");