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", "Hyundai", "South Korea");
INSERT INTO "car_makers" VALUES ("6", "Renault", "France");
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", "Accent");
INSERT INTO "car_names" VALUES ("6", "Clio");
INSERT INTO "cars_data" VALUES ("1", "4", "132", "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", "670", "4900");
INSERT INTO "cars_data" VALUES ("5", "3", "120", "2600");
INSERT INTO "cars_data" VALUES ("6", "4", "90", "2400");
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", "Compact");
INSERT INTO "model_list" VALUES ("6", "Subcompact");