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 "car_makers" (
"Id" INT UNIQUE,
"FullName" TEXT,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Country") REFERENCES "countries"("CountryId")
);

CREATE TABLE "car_names" (
"MakeId" INT,
"Make" TEXT,
PRIMARY KEY ("MakeId")
);

CREATE TABLE "countries" (
"CountryId" INT,
"CountryName" TEXT,
PRIMARY KEY ("CountryId")
);

CREATE TABLE "model_list" (
"ModelId" INT,
"Maker" INT,
"Model" TEXT UNIQUE,
PRIMARY KEY ("ModelId"),
FOREIGN KEY ("Maker") REFERENCES "car_makers"("Id")
);





INSERT INTO "countries" VALUES ("1", "Japan");
INSERT INTO "countries" VALUES ("2", "Germany");
INSERT INTO "countries" VALUES ("3", "United States");
INSERT INTO "countries" VALUES ("4", "South Korea");
INSERT INTO "countries" VALUES ("5", "Italy");
INSERT INTO "car_makers" VALUES ("101", "Toyota Motor Corporation", "1");
INSERT INTO "car_makers" VALUES ("102", "Volkswagen AG", "2");
INSERT INTO "car_makers" VALUES ("103", "Ford Motor Company", "3");
INSERT INTO "car_makers" VALUES ("104", "Hyundai Motor Company", "4");
INSERT INTO "car_makers" VALUES ("105", "Fiat Chrysler Automobiles", "5");
INSERT INTO "car_makers" VALUES ("106", "Tesla, Inc.", "3");
INSERT INTO "car_makers" VALUES ("107", "BMW AG", "2");
INSERT INTO "car_names" VALUES ("101", "Toyota");
INSERT INTO "car_names" VALUES ("102", "Volkswagen");
INSERT INTO "car_names" VALUES ("103", "Ford");
INSERT INTO "car_names" VALUES ("104", "Hyundai");
INSERT INTO "car_names" VALUES ("105", "Fiat");
INSERT INTO "car_names" VALUES ("106", "Tesla");
INSERT INTO "car_names" VALUES ("107", "BMW");
INSERT INTO "model_list" VALUES ("1001", "101", "Corolla");
INSERT INTO "model_list" VALUES ("1002", "101", "Camry");
INSERT INTO "model_list" VALUES ("1003", "101", "Prius");
INSERT INTO "model_list" VALUES ("1004", "101", "RAV4");
INSERT INTO "model_list" VALUES ("1005", "102", "Golf");
INSERT INTO "model_list" VALUES ("1006", "102", "Passat");
INSERT INTO "model_list" VALUES ("1007", "102", "Tiguan");
INSERT INTO "model_list" VALUES ("1008", "102", "Polo");
INSERT INTO "model_list" VALUES ("1009", "103", "F-150");
INSERT INTO "model_list" VALUES ("1010", "103", "Mustang");
INSERT INTO "model_list" VALUES ("1011", "103", "Explorer");
INSERT INTO "model_list" VALUES ("1012", "104", "Elantra");
INSERT INTO "model_list" VALUES ("1013", "104", "Sonata");
INSERT INTO "model_list" VALUES ("1014", "104", "Tucson");
INSERT INTO "model_list" VALUES ("1015", "105", "500");
INSERT INTO "model_list" VALUES ("1016", "105", "Panda");
INSERT INTO "model_list" VALUES ("1017", "106", "Model S");
INSERT INTO "model_list" VALUES ("1018", "106", "Model 3");
INSERT INTO "model_list" VALUES ("1019", "107", "3 Series");
INSERT INTO "model_list" VALUES ("1020", "107", "5 Series");
INSERT INTO "model_list" VALUES ("1021", "107", "X5");
INSERT INTO "model_list" VALUES ("1022", "107", "X3");
INSERT INTO "model_list" VALUES ("1023", "107", "7 Series");