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

CREATE TABLE "car_names" (
"MakeId" INT,
"Model" TEXT,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY ("Model") REFERENCES "model_list"("Model")
);

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", "USA");
INSERT INTO "countries" VALUES ("4", "South Korea");
INSERT INTO "countries" VALUES ("5", "France");
INSERT INTO "car_makers" VALUES ("1", "Toyota", "1");
INSERT INTO "car_makers" VALUES ("2", "Honda", "1");
INSERT INTO "car_makers" VALUES ("3", "BMW", "2");
INSERT INTO "car_makers" VALUES ("4", "Mercedes", "2");
INSERT INTO "car_makers" VALUES ("5", "Ford", "3");
INSERT INTO "car_makers" VALUES ("6", "Chevrolet", "3");
INSERT INTO "car_makers" VALUES ("7", "Hyundai", "4");
INSERT INTO "car_makers" VALUES ("8", "Kia", "4");
INSERT INTO "car_makers" VALUES ("9", "Peugeot", "5");
INSERT INTO "car_makers" VALUES ("10", "Citroen", "5");
INSERT INTO "model_list" VALUES ("1", "1", "Corolla");
INSERT INTO "model_list" VALUES ("2", "2", "Civic");
INSERT INTO "model_list" VALUES ("3", "3", "X5");
INSERT INTO "model_list" VALUES ("4", "4", "C-Class");
INSERT INTO "model_list" VALUES ("5", "5", "Mustang");
INSERT INTO "model_list" VALUES ("6", "6", "Camaro");
INSERT INTO "model_list" VALUES ("7", "7", "Elantra");
INSERT INTO "model_list" VALUES ("8", "8", "Sorento");
INSERT INTO "model_list" VALUES ("9", "9", "208");
INSERT INTO "model_list" VALUES ("10", "10", "C3");
INSERT INTO "model_list" VALUES ("11", "1", "Camry");
INSERT INTO "model_list" VALUES ("12", "2", "Accord");
INSERT INTO "model_list" VALUES ("13", "3", "3 Series");
INSERT INTO "model_list" VALUES ("14", "4", "E-Class");
INSERT INTO "car_names" VALUES ("1", "Corolla", "Toyota");
INSERT INTO "car_names" VALUES ("2", "Corolla", "Honda");
INSERT INTO "car_names" VALUES ("3", "Corolla", "Ford");
INSERT INTO "car_names" VALUES ("4", "Civic", "Honda");
INSERT INTO "car_names" VALUES ("5", "Civic", "Toyota");
INSERT INTO "car_names" VALUES ("6", "X5", "BMW");
INSERT INTO "car_names" VALUES ("7", "X5", "Mercedes");
INSERT INTO "car_names" VALUES ("8", "C-Class", "Mercedes");
INSERT INTO "car_names" VALUES ("9", "Mustang", "Ford");
INSERT INTO "car_names" VALUES ("10", "Mustang", "Chevrolet");
INSERT INTO "car_names" VALUES ("11", "Elantra", "Hyundai");
INSERT INTO "car_names" VALUES ("12", "Sorento", "Kia");
INSERT INTO "car_names" VALUES ("13", "208", "Peugeot");
INSERT INTO "car_names" VALUES ("14", "C3", "Citroen");
INSERT INTO "car_names" VALUES ("15", "Camry", "Toyota");
INSERT INTO "car_names" VALUES ("16", "Camry", "Hyundai");
INSERT INTO "car_names" VALUES ("17", "Accord", "Honda");
INSERT INTO "car_names" VALUES ("18", "3 Series", "BMW");
INSERT INTO "car_names" VALUES ("19", "3 Series", "Mercedes");
INSERT INTO "car_names" VALUES ("20", "E-Class", "Mercedes");
INSERT INTO "car_names" VALUES ("21", "E-Class", "BMW");