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,
"FullName" TEXT,
PRIMARY KEY ("Id")
);

CREATE TABLE "car_names" (
"MakeId" INT UNIQUE,
"Model" TEXT,
PRIMARY KEY ("MakeId")
);

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,
PRIMARY KEY ("ModelId"),
FOREIGN KEY ("Maker") REFERENCES "car_makers"("Id")
);





INSERT INTO "car_makers" VALUES ("1", "ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("2", "toyota", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("3", "honda", "Honda Motor Co., Ltd.");
INSERT INTO "car_makers" VALUES ("4", "chevrolet", "Chevrolet Division");
INSERT INTO "car_makers" VALUES ("5", "bmw", "Bayerische Motoren Werke AG");
INSERT INTO "car_names" VALUES ("101", "Focus");
INSERT INTO "car_names" VALUES ("102", "Corolla");
INSERT INTO "car_names" VALUES ("103", "Civic");
INSERT INTO "car_names" VALUES ("104", "Cruze");
INSERT INTO "car_names" VALUES ("105", "320i");
INSERT INTO "cars_data" VALUES ("101", "4", "160");
INSERT INTO "cars_data" VALUES ("102", "4", "132");
INSERT INTO "cars_data" VALUES ("103", "4", "158");
INSERT INTO "cars_data" VALUES ("104", "4", "153");
INSERT INTO "cars_data" VALUES ("105", "4", "180");
INSERT INTO "model_list" VALUES ("101", "1");
INSERT INTO "model_list" VALUES ("102", "2");
INSERT INTO "model_list" VALUES ("103", "3");
INSERT INTO "model_list" VALUES ("104", "4");
INSERT INTO "model_list" VALUES ("105", "5");
INSERT INTO "car_names" VALUES ("106", "Mustang");
INSERT INTO "cars_data" VALUES ("106", "8", "450");
INSERT INTO "model_list" VALUES ("106", "1");
INSERT INTO "car_names" VALUES ("107", "Camry");
INSERT INTO "cars_data" VALUES ("107", "6", "301");
INSERT INTO "model_list" VALUES ("107", "2");
INSERT INTO "car_names" VALUES ("108", "Accord");
INSERT INTO "cars_data" VALUES ("108", "4", "192");
INSERT INTO "model_list" VALUES ("108", "3");
INSERT INTO "car_names" VALUES ("109", "Malibu");
INSERT INTO "cars_data" VALUES ("109", "4", "160");
INSERT INTO "model_list" VALUES ("109", "4");
INSERT INTO "car_names" VALUES ("110", "X3");
INSERT INTO "cars_data" VALUES ("110", "6", "248");
INSERT INTO "model_list" VALUES ("110", "5");