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,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY ("Model") REFERENCES "model_list"("Model")
);

CREATE TABLE "cars_data" (
"Id" INT,
"Cylinders" INT,
"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.");
INSERT INTO "car_makers" VALUES ("5", "Chrysler", "Chrysler Group LLC");
INSERT INTO "car_makers" VALUES ("6", "BMW", "Bayerische Motoren Werke AG");
INSERT INTO "model_list" VALUES ("101", "1", "Impala");
INSERT INTO "model_list" VALUES ("102", "1", "Malibu");
INSERT INTO "model_list" VALUES ("103", "1", "Silverado");
INSERT INTO "model_list" VALUES ("104", "2", "F-150");
INSERT INTO "model_list" VALUES ("105", "2", "Mustang");
INSERT INTO "model_list" VALUES ("106", "3", "Camry");
INSERT INTO "model_list" VALUES ("107", "3", "Corolla");
INSERT INTO "model_list" VALUES ("108", "4", "Civic");
INSERT INTO "model_list" VALUES ("109", "5", "Charger");
INSERT INTO "model_list" VALUES ("110", "6", "X5");
INSERT INTO "model_list" VALUES ("111", "1", "Tahoe");
INSERT INTO "model_list" VALUES ("112", "2", "Explorer");
INSERT INTO "model_list" VALUES ("113", "3", "RAV4");
INSERT INTO "model_list" VALUES ("114", "1", "Cruze");
INSERT INTO "car_names" VALUES ("1", "Impala", "Chevrolet");
INSERT INTO "car_names" VALUES ("2", "F-150", "Ford");
INSERT INTO "car_names" VALUES ("3", "Camry", "Toyota");
INSERT INTO "car_names" VALUES ("4", "Civic", "Honda");
INSERT INTO "car_names" VALUES ("5", "Charger", "Dodge");
INSERT INTO "car_names" VALUES ("6", "X5", "BMW");
INSERT INTO "car_names" VALUES ("7", "Malibu", "Chevrolet");
INSERT INTO "car_names" VALUES ("8", "Silverado", "Chevrolet");
INSERT INTO "car_names" VALUES ("9", "Mustang", "Ford");
INSERT INTO "car_names" VALUES ("10", "Corolla", "Toyota");
INSERT INTO "car_names" VALUES ("11", "Tahoe", "Chevrolet");
INSERT INTO "car_names" VALUES ("12", "Explorer", "Ford");
INSERT INTO "car_names" VALUES ("13", "RAV4", "Toyota");
INSERT INTO "car_names" VALUES ("14", "Cruze", "Chevrolet");
INSERT INTO "cars_data" VALUES ("1", "6", "3800");
INSERT INTO "cars_data" VALUES ("2", "8", "4500");
INSERT INTO "cars_data" VALUES ("3", "4", "3200");
INSERT INTO "cars_data" VALUES ("4", "4", "2800");
INSERT INTO "cars_data" VALUES ("5", "8", "4000");
INSERT INTO "cars_data" VALUES ("6", "6", "4200");
INSERT INTO "cars_data" VALUES ("7", "4", "3100");
INSERT INTO "cars_data" VALUES ("8", "8", "5000");
INSERT INTO "cars_data" VALUES ("9", "8", "3600");
INSERT INTO "cars_data" VALUES ("10", "4", "2900");
INSERT INTO "cars_data" VALUES ("11", "8", "5200");
INSERT INTO "cars_data" VALUES ("12", "6", "4100");
INSERT INTO "cars_data" VALUES ("13", "4", "3400");
INSERT INTO "cars_data" VALUES ("14", "4", "3000");