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", "1", "Camry");
INSERT INTO "model_list" VALUES ("103", "2", "Mustang");
INSERT INTO "model_list" VALUES ("104", "2", "Focus");
INSERT INTO "model_list" VALUES ("105", "3", "Civic");
INSERT INTO "model_list" VALUES ("106", "3", "Accord");
INSERT INTO "model_list" VALUES ("107", "4", "Malibu");
INSERT INTO "model_list" VALUES ("108", "4", "Impala");
INSERT INTO "model_list" VALUES ("109", "5", "320i");
INSERT INTO "model_list" VALUES ("110", "5", "X5");
INSERT INTO "car_names" VALUES ("101", "Corolla");
INSERT INTO "car_names" VALUES ("102", "Camry");
INSERT INTO "car_names" VALUES ("103", "Mustang");
INSERT INTO "car_names" VALUES ("104", "Focus");
INSERT INTO "car_names" VALUES ("105", "Civic");
INSERT INTO "car_names" VALUES ("106", "Accord");
INSERT INTO "car_names" VALUES ("107", "Malibu");
INSERT INTO "car_names" VALUES ("108", "Impala");
INSERT INTO "car_names" VALUES ("109", "320i");
INSERT INTO "car_names" VALUES ("110", "X5");
INSERT INTO "cars_data" VALUES ("101", "4", "132");
INSERT INTO "cars_data" VALUES ("102", "4", "203");
INSERT INTO "cars_data" VALUES ("103", "8", "450");
INSERT INTO "cars_data" VALUES ("104", "4", "160");
INSERT INTO "cars_data" VALUES ("105", "4", "158");
INSERT INTO "cars_data" VALUES ("106", "4", "192");
INSERT INTO "cars_data" VALUES ("107", "6", "250");
INSERT INTO "cars_data" VALUES ("108", "6", "305");
INSERT INTO "cars_data" VALUES ("109", "4", "180");
INSERT INTO "cars_data" VALUES ("110", "6", "335");
INSERT INTO "car_names" VALUES ("111", "SmartFortwo");
INSERT INTO "model_list" VALUES ("111", "1", "SmartFortwo");
INSERT INTO "cars_data" VALUES ("111", "3", "70");