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,
"Cylinders" 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", "Chevrolet");
INSERT INTO "car_makers" VALUES ("5", "BMW");
INSERT INTO "model_list" VALUES ("101", "1", "Corolla");
INSERT INTO "model_list" VALUES ("102", "2", "Mustang");
INSERT INTO "model_list" VALUES ("103", "3", "Civic");
INSERT INTO "model_list" VALUES ("104", "4", "Camaro");
INSERT INTO "model_list" VALUES ("105", "5", "320i");
INSERT INTO "model_list" VALUES ("106", "1", "Yaris");
INSERT INTO "model_list" VALUES ("107", "2", "Fiesta");
INSERT INTO "model_list" VALUES ("108", "3", "Accord");
INSERT INTO "model_list" VALUES ("109", "4", "Malibu");
INSERT INTO "model_list" VALUES ("110", "5", "X3");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("2", "Mustang");
INSERT INTO "car_names" VALUES ("3", "Civic");
INSERT INTO "car_names" VALUES ("4", "Camaro");
INSERT INTO "car_names" VALUES ("5", "320i");
INSERT INTO "car_names" VALUES ("6", "Yaris");
INSERT INTO "car_names" VALUES ("7", "Fiesta");
INSERT INTO "car_names" VALUES ("8", "Accord");
INSERT INTO "car_names" VALUES ("9", "Malibu");
INSERT INTO "car_names" VALUES ("10", "X3");
INSERT INTO "cars_data" VALUES ("1", "4", "132");
INSERT INTO "cars_data" VALUES ("2", "8", "450");
INSERT INTO "cars_data" VALUES ("3", "4", "158");
INSERT INTO "cars_data" VALUES ("4", "6", "275");
INSERT INTO "cars_data" VALUES ("5", "4", "180");
INSERT INTO "cars_data" VALUES ("6", "4", "106");
INSERT INTO "cars_data" VALUES ("7", "4", "120");
INSERT INTO "cars_data" VALUES ("8", "4", "192");
INSERT INTO "cars_data" VALUES ("9", "6", "160");
INSERT INTO "cars_data" VALUES ("10", "6", "248");
INSERT INTO "car_makers" VALUES ("11", "Nissan");
INSERT INTO "model_list" VALUES ("111", "11", "Sentra");
INSERT INTO "car_names" VALUES ("11", "Sentra");
INSERT INTO "cars_data" VALUES ("11", "4", "106");
INSERT INTO "car_makers" VALUES ("12", "Mazda");
INSERT INTO "model_list" VALUES ("112", "12", "Mazda3");
INSERT INTO "car_names" VALUES ("12", "Mazda3");
INSERT INTO "cars_data" VALUES ("12", "4", "106");
INSERT INTO "car_makers" VALUES ("13", "Hyundai");
INSERT INTO "model_list" VALUES ("113", "13", "Accent");
INSERT INTO "car_names" VALUES ("13", "Accent");
INSERT INTO "cars_data" VALUES ("13", "4", "106");