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

CREATE TABLE "airports" (
"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", "United Airlines", "USA");
INSERT INTO "airlines" VALUES ("2", "Delta Airlines", "USA");
INSERT INTO "airlines" VALUES ("3", "American Airlines", "USA");
INSERT INTO "airlines" VALUES ("4", "Lufthansa", "Germany");
INSERT INTO "airlines" VALUES ("5", "Emirates", "UAE");
INSERT INTO "airports" VALUES ("AHD", "Ahmedabad International Airport");
INSERT INTO "airports" VALUES ("JFK", "John F. Kennedy International Airport");
INSERT INTO "airports" VALUES ("LAX", "Los Angeles International Airport");
INSERT INTO "airports" VALUES ("ORD", "O'Hare International Airport");
INSERT INTO "airports" VALUES ("FRA", "Frankfurt Airport");
INSERT INTO "airports" VALUES ("DXB", "Dubai International Airport");
INSERT INTO "airports" VALUES ("SFO", "San Francisco International Airport");
INSERT INTO "flights" VALUES ("1", "101", "AHD", "JFK");
INSERT INTO "flights" VALUES ("1", "102", "AHD", "LAX");
INSERT INTO "flights" VALUES ("1", "103", "AHD", "ORD");
INSERT INTO "flights" VALUES ("1", "104", "JFK", "AHD");
INSERT INTO "flights" VALUES ("1", "105", "ORD", "LAX");
INSERT INTO "flights" VALUES ("2", "201", "AHD", "FRA");
INSERT INTO "flights" VALUES ("2", "202", "FRA", "AHD");
INSERT INTO "flights" VALUES ("3", "301", "AHD", "DXB");
INSERT INTO "flights" VALUES ("3", "302", "DXB", "AHD");
INSERT INTO "flights" VALUES ("4", "401", "AHD", "SFO");
INSERT INTO "flights" VALUES ("5", "501", "SFO", "AHD");
INSERT INTO "flights" VALUES ("1", "106", "AHD", "SFO");
INSERT INTO "flights" VALUES ("1", "107", "LAX", "AHD");