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", "Volkswagen AG", "Germany");
INSERT INTO "car_makers" VALUES ("4", "Ford Motor Company", "USA");
INSERT INTO "car_makers" VALUES ("5", "Hyundai Motor Company", "South Korea");
INSERT INTO "model_list" VALUES ("101", "1", "Camaro");
INSERT INTO "model_list" VALUES ("102", "1", "Silverado");
INSERT INTO "model_list" VALUES ("103", "2", "Corolla");
INSERT INTO "model_list" VALUES ("104", "2", "Camry");
INSERT INTO "model_list" VALUES ("105", "3", "Golf");
INSERT INTO "model_list" VALUES ("106", "3", "Passat");
INSERT INTO "model_list" VALUES ("107", "4", "F-150");
INSERT INTO "model_list" VALUES ("108", "4", "Mustang");
INSERT INTO "model_list" VALUES ("109", "5", "Elantra");
INSERT INTO "model_list" VALUES ("110", "5", "Santa Fe");
INSERT INTO "car_names" VALUES ("201", "Camaro", "General Motors");
INSERT INTO "car_names" VALUES ("202", "Silverado", "General Motors");
INSERT INTO "car_names" VALUES ("203", "Corolla", "Toyota Motor Corporation");
INSERT INTO "car_names" VALUES ("204", "Camry", "Toyota Motor Corporation");
INSERT INTO "car_names" VALUES ("205", "Golf", "Volkswagen AG");
INSERT INTO "car_names" VALUES ("206", "Passat", "Volkswagen AG");
INSERT INTO "car_names" VALUES ("207", "F-150", "Ford Motor Company");
INSERT INTO "car_names" VALUES ("208", "Mustang", "Ford Motor Company");
INSERT INTO "car_names" VALUES ("209", "Elantra", "Hyundai Motor Company");
INSERT INTO "car_names" VALUES ("210", "Santa Fe", "Hyundai Motor Company");
INSERT INTO "cars_data" VALUES ("201", "455 HP", "3700");
INSERT INTO "cars_data" VALUES ("202", "420 HP", "4500");
INSERT INTO "cars_data" VALUES ("203", "132 HP", "2800");
INSERT INTO "cars_data" VALUES ("204", "203 HP", "3300");
INSERT INTO "cars_data" VALUES ("205", "147 HP", "2900");
INSERT INTO "cars_data" VALUES ("206", "174 HP", "3200");
INSERT INTO "cars_data" VALUES ("207", "290 HP", "4100");
INSERT INTO "cars_data" VALUES ("208", "450 HP", "3500");
INSERT INTO "cars_data" VALUES ("209", "147 HP", "2900");
INSERT INTO "cars_data" VALUES ("210", "191 HP", "3600");