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,
"Maker" 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,
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", "Toyota");
INSERT INTO "car_makers" VALUES ("2", "Ford");
INSERT INTO "car_makers" VALUES ("3", "Honda");
INSERT INTO "car_makers" VALUES ("4", "BMW");
INSERT INTO "car_makers" VALUES ("5", "Tesla");
INSERT INTO "model_list" VALUES ("101", "1", "Corolla");
INSERT INTO "model_list" VALUES ("102", "1", "Camry");
INSERT INTO "model_list" VALUES ("103", "2", "Mustang");
INSERT INTO "model_list" VALUES ("104", "2", "F-150");
INSERT INTO "model_list" VALUES ("105", "3", "Civic");
INSERT INTO "model_list" VALUES ("106", "3", "Accord");
INSERT INTO "model_list" VALUES ("107", "4", "X5");
INSERT INTO "model_list" VALUES ("108", "4", "M3");
INSERT INTO "model_list" VALUES ("109", "5", "Model S");
INSERT INTO "model_list" VALUES ("110", "5", "Model 3");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("2", "Camry");
INSERT INTO "car_names" VALUES ("3", "Mustang");
INSERT INTO "car_names" VALUES ("4", "F-150");
INSERT INTO "car_names" VALUES ("5", "Civic");
INSERT INTO "car_names" VALUES ("6", "Accord");
INSERT INTO "car_names" VALUES ("7", "X5");
INSERT INTO "car_names" VALUES ("8", "M3");
INSERT INTO "car_names" VALUES ("9", "Model S");
INSERT INTO "car_names" VALUES ("10", "Model 3");
INSERT INTO "cars_data" VALUES ("1", "132");
INSERT INTO "cars_data" VALUES ("2", "203");
INSERT INTO "cars_data" VALUES ("3", "450");
INSERT INTO "cars_data" VALUES ("4", "290");
INSERT INTO "cars_data" VALUES ("5", "158");
INSERT INTO "cars_data" VALUES ("6", "192");
INSERT INTO "cars_data" VALUES ("7", "335");
INSERT INTO "cars_data" VALUES ("8", "473");
INSERT INTO "cars_data" VALUES ("9", "670");
INSERT INTO "cars_data" VALUES ("10", "283");
INSERT INTO "car_names" VALUES ("11", "EcoBoost");
INSERT INTO "model_list" VALUES ("111", "2", "EcoBoost");
INSERT INTO "cars_data" VALUES ("11", "120");
INSERT INTO "car_makers" VALUES ("6", "Chevrolet");
INSERT INTO "model_list" VALUES ("112", "6", "Spark");
INSERT INTO "car_names" VALUES ("12", "Spark");
INSERT INTO "cars_data" VALUES ("12", "98");