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

CREATE TABLE "car_names" (
"MakeId" INT,
"Model" 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 "car_makers" VALUES ("1", "Toyota", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("2", "Ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("3", "Honda", "Honda Motor Co., Ltd.");
INSERT INTO "car_makers" VALUES ("4", "BMW", "Bayerische Motoren Werke AG");
INSERT INTO "car_makers" VALUES ("5", "Tesla", "Tesla, Inc.");
INSERT INTO "car_makers" VALUES ("6", "Mazda", "Mazda Motor Corporation");
INSERT INTO "model_list" VALUES ("1", "1", "Corolla");
INSERT INTO "model_list" VALUES ("2", "1", "Camry");
INSERT INTO "model_list" VALUES ("3", "2", "Mustang");
INSERT INTO "model_list" VALUES ("4", "2", "F-150");
INSERT INTO "model_list" VALUES ("5", "3", "Civic");
INSERT INTO "model_list" VALUES ("6", "3", "Accord");
INSERT INTO "model_list" VALUES ("7", "4", "X5");
INSERT INTO "model_list" VALUES ("8", "4", "X3");
INSERT INTO "model_list" VALUES ("9", "5", "Model S");
INSERT INTO "model_list" VALUES ("10", "5", "Model 3");
INSERT INTO "model_list" VALUES ("11", "6", "CX-5");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("1", "Camry");
INSERT INTO "car_names" VALUES ("2", "Mustang");
INSERT INTO "car_names" VALUES ("2", "F-150");
INSERT INTO "car_names" VALUES ("3", "Civic");
INSERT INTO "car_names" VALUES ("3", "Accord");
INSERT INTO "car_names" VALUES ("4", "X5");
INSERT INTO "car_names" VALUES ("4", "X3");
INSERT INTO "car_names" VALUES ("5", "Model S");
INSERT INTO "car_names" VALUES ("5", "Model 3");
INSERT INTO "car_names" VALUES ("6", "CX-5");
INSERT INTO "countries" VALUES ("1", "Japan");
INSERT INTO "countries" VALUES ("2", "United States");
INSERT INTO "countries" VALUES ("3", "Germany");