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 UNIQUE,
"Model" 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", "GM", "General Motors");
INSERT INTO "car_makers" VALUES ("2", "FORD", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("3", "TOYOTA", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("4", "HONDA", "Honda Motor Co., Ltd.");
INSERT INTO "car_makers" VALUES ("5", "BMW", "Bayerische Motoren Werke AG");
INSERT INTO "model_list" VALUES ("101", "1", "Camaro");
INSERT INTO "model_list" VALUES ("102", "1", "Silverado");
INSERT INTO "model_list" VALUES ("103", "2", "Mustang");
INSERT INTO "model_list" VALUES ("104", "3", "Camry");
INSERT INTO "model_list" VALUES ("105", "4", "Accord");
INSERT INTO "model_list" VALUES ("106", "5", "X5");
INSERT INTO "model_list" VALUES ("107", "2", "F-150");
INSERT INTO "model_list" VALUES ("108", "3", "Highlander");
INSERT INTO "model_list" VALUES ("109", "1", "Tahoe");
INSERT INTO "model_list" VALUES ("110", "5", "330i");
INSERT INTO "car_names" VALUES ("101", "Camaro");
INSERT INTO "car_names" VALUES ("102", "Silverado");
INSERT INTO "car_names" VALUES ("103", "Mustang");
INSERT INTO "car_names" VALUES ("104", "Camry");
INSERT INTO "car_names" VALUES ("105", "Accord");
INSERT INTO "car_names" VALUES ("106", "X5");
INSERT INTO "car_names" VALUES ("107", "F-150");
INSERT INTO "car_names" VALUES ("108", "Highlander");
INSERT INTO "car_names" VALUES ("109", "Tahoe");
INSERT INTO "car_names" VALUES ("110", "330i");
INSERT INTO "cars_data" VALUES ("101", "455 HP", "3685");
INSERT INTO "cars_data" VALUES ("102", "420 HP", "4500");
INSERT INTO "cars_data" VALUES ("103", "460 HP", "3700");
INSERT INTO "cars_data" VALUES ("104", "203 HP", "3300");
INSERT INTO "cars_data" VALUES ("105", "192 HP", "3200");
INSERT INTO "cars_data" VALUES ("106", "335 HP", "4800");
INSERT INTO "cars_data" VALUES ("107", "400 HP", "4100");
INSERT INTO "cars_data" VALUES ("108", "295 HP", "3900");
INSERT INTO "cars_data" VALUES ("109", "355 HP", "5200");
INSERT INTO "cars_data" VALUES ("110", "255 HP", "3500");