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

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

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", "Japan");
INSERT INTO "car_makers" VALUES ("2", "Ford", "Ford Motor Company", "USA");
INSERT INTO "car_makers" VALUES ("3", "BMW", "Bayerische Motoren Werke AG", "Germany");
INSERT INTO "car_makers" VALUES ("4", "Hyundai", "Hyundai Motor Company", "South Korea");
INSERT INTO "car_makers" VALUES ("5", "Tesla", "Tesla, Inc.", "USA");
INSERT INTO "car_makers" VALUES ("6", "Fiat", "Fiat Chrysler Automobiles", "Italy");
INSERT INTO "car_names" VALUES ("1", "Toyota");
INSERT INTO "car_names" VALUES ("2", "Ford");
INSERT INTO "car_names" VALUES ("3", "BMW");
INSERT INTO "car_names" VALUES ("4", "Hyundai");
INSERT INTO "car_names" VALUES ("5", "Tesla");
INSERT INTO "car_names" VALUES ("6", "Fiat");
INSERT INTO "model_list" VALUES ("101", "1", "Corolla");
INSERT INTO "model_list" VALUES ("102", "1", "Camry");
INSERT INTO "model_list" VALUES ("103", "1", "Prius");
INSERT INTO "model_list" VALUES ("104", "1", "RAV4");
INSERT INTO "model_list" VALUES ("105", "2", "F-150");
INSERT INTO "model_list" VALUES ("106", "2", "Mustang");
INSERT INTO "model_list" VALUES ("107", "2", "Explorer");
INSERT INTO "model_list" VALUES ("108", "3", "3 Series");
INSERT INTO "model_list" VALUES ("109", "3", "5 Series");
INSERT INTO "model_list" VALUES ("110", "3", "X5");
INSERT INTO "model_list" VALUES ("111", "3", "X3");
INSERT INTO "model_list" VALUES ("112", "4", "Elantra");
INSERT INTO "model_list" VALUES ("113", "4", "Sonata");
INSERT INTO "model_list" VALUES ("114", "5", "Model S");
INSERT INTO "model_list" VALUES ("115", "5", "Model 3");
INSERT INTO "model_list" VALUES ("116", "6", "500");
INSERT INTO "model_list" VALUES ("117", "6", "Panda");
INSERT INTO "model_list" VALUES ("118", "6", "Tipo");
INSERT INTO "model_list" VALUES ("119", "6", "Punto");