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

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

CREATE TABLE "cars_data" (
"Id" INT,
"Cylinders" INT,
"Horsepower" TEXT,
"Weight" INT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Id") REFERENCES "car_names"("MakeId")
);

CREATE TABLE "model_list" (
"ModelId" INT,
"Model" TEXT UNIQUE,
PRIMARY KEY ("ModelId")
);





INSERT INTO "car_makers" VALUES ("1", "Toyota", "Japan");
INSERT INTO "car_makers" VALUES ("2", "Ford", "USA");
INSERT INTO "car_makers" VALUES ("3", "Fiat", "Italy");
INSERT INTO "car_makers" VALUES ("4", "Tesla", "USA");
INSERT INTO "car_makers" VALUES ("5", "Smart", "Germany");
INSERT INTO "car_makers" VALUES ("6", "Peugeot", "France");
INSERT INTO "car_makers" VALUES ("7", "Honda", "Japan");
INSERT INTO "car_makers" VALUES ("8", "Mini", "UK");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("2", "Mustang");
INSERT INTO "car_names" VALUES ("3", "500");
INSERT INTO "car_names" VALUES ("4", "Model S");
INSERT INTO "car_names" VALUES ("5", "Fortwo");
INSERT INTO "car_names" VALUES ("6", "208");
INSERT INTO "car_names" VALUES ("7", "Civic");
INSERT INTO "car_names" VALUES ("8", "Cooper");
INSERT INTO "cars_data" VALUES ("1", "4", "130", "2800");
INSERT INTO "cars_data" VALUES ("2", "8", "450", "3700");
INSERT INTO "cars_data" VALUES ("3", "2", "69", "1900");
INSERT INTO "cars_data" VALUES ("4", "0", "0", "4900");
INSERT INTO "cars_data" VALUES ("5", "3", "69", "1800");
INSERT INTO "cars_data" VALUES ("6", "3", "69", "2100");
INSERT INTO "cars_data" VALUES ("7", "4", "158", "2900");
INSERT INTO "cars_data" VALUES ("8", "3", "69", "2200");
INSERT INTO "model_list" VALUES ("1", "Sedan");
INSERT INTO "model_list" VALUES ("2", "Coupe");
INSERT INTO "model_list" VALUES ("3", "Hatchback");
INSERT INTO "model_list" VALUES ("4", "Electric");
INSERT INTO "model_list" VALUES ("5", "Microcar");
INSERT INTO "model_list" VALUES ("6", "Compact");
INSERT INTO "model_list" VALUES ("7", "Sport");
INSERT INTO "model_list" VALUES ("8", "Convertible");