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")
);

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

CREATE TABLE "cars_data" (
"Id" INT,
"Horsepower" TEXT,
"Weight" INT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Id") REFERENCES "car_names"("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", "General Motors", "USA");
INSERT INTO "car_makers" VALUES ("2", "Toyota Motor Corporation", "Japan");
INSERT INTO "car_makers" VALUES ("3", "Ford Motor Company", "USA");
INSERT INTO "car_makers" VALUES ("4", "General Motors Europe", "Germany");
INSERT INTO "car_makers" VALUES ("5", "Honda Motor Co.", "Japan");
INSERT INTO "car_makers" VALUES ("6", "General Motors South America", "Brazil");
INSERT INTO "model_list" VALUES ("101", "1", "Impala");
INSERT INTO "model_list" VALUES ("102", "1", "Silverado");
INSERT INTO "model_list" VALUES ("103", "2", "Camry");
INSERT INTO "model_list" VALUES ("104", "3", "F-150");
INSERT INTO "model_list" VALUES ("105", "4", "Astra");
INSERT INTO "model_list" VALUES ("106", "5", "Civic");
INSERT INTO "model_list" VALUES ("107", "6", "Onix");
INSERT INTO "model_list" VALUES ("108", "1", "Tahoe");
INSERT INTO "model_list" VALUES ("109", "3", "Mustang");
INSERT INTO "model_list" VALUES ("110", "2", "Corolla");
INSERT INTO "model_list" VALUES ("111", "4", "Insignia");
INSERT INTO "model_list" VALUES ("112", "6", "S10");
INSERT INTO "car_names" VALUES ("101", "Impala", "General Motors");
INSERT INTO "car_names" VALUES ("102", "Silverado", "General Motors");
INSERT INTO "car_names" VALUES ("103", "Camry", "Toyota Motor Corporation");
INSERT INTO "car_names" VALUES ("104", "F-150", "Ford Motor Company");
INSERT INTO "car_names" VALUES ("105", "Astra", "General Motors Europe");
INSERT INTO "car_names" VALUES ("106", "Civic", "Honda Motor Co.");
INSERT INTO "car_names" VALUES ("107", "Onix", "General Motors South America");
INSERT INTO "car_names" VALUES ("108", "Tahoe", "General Motors");
INSERT INTO "car_names" VALUES ("109", "Mustang", "Ford Motor Company");
INSERT INTO "car_names" VALUES ("110", "Corolla", "Toyota Motor Corporation");
INSERT INTO "car_names" VALUES ("111", "Insignia", "General Motors Europe");
INSERT INTO "car_names" VALUES ("112", "S10", "General Motors South America");
INSERT INTO "cars_data" VALUES ("101", "305 HP", "3600");
INSERT INTO "cars_data" VALUES ("102", "420 HP", "4500");
INSERT INTO "cars_data" VALUES ("103", "203 HP", "3300");
INSERT INTO "cars_data" VALUES ("104", "450 HP", "4700");
INSERT INTO "cars_data" VALUES ("105", "200 HP", "3400");
INSERT INTO "cars_data" VALUES ("106", "158 HP", "2900");
INSERT INTO "cars_data" VALUES ("107", "130 HP", "3550");
INSERT INTO "cars_data" VALUES ("108", "355 HP", "3700");
INSERT INTO "cars_data" VALUES ("109", "460 HP", "3200");
INSERT INTO "cars_data" VALUES ("110", "139 HP", "3100");
INSERT INTO "cars_data" VALUES ("111", "210 HP", "3499");
INSERT INTO "cars_data" VALUES ("112", "180 HP", "3501");