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,
"Country" 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,
"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", "Volkswagen", "Germany");
INSERT INTO "car_makers" VALUES ("4", "Hyundai", "South Korea");
INSERT INTO "car_makers" VALUES ("5", "Fiat", "Italy");
INSERT INTO "car_makers" VALUES ("6", "Tesla", "USA");
INSERT INTO "model_list" VALUES ("1", "Corolla");
INSERT INTO "model_list" VALUES ("2", "Focus");
INSERT INTO "model_list" VALUES ("3", "Golf");
INSERT INTO "model_list" VALUES ("4", "Elantra");
INSERT INTO "model_list" VALUES ("5", "500");
INSERT INTO "model_list" VALUES ("6", "Model 3");
INSERT INTO "model_list" VALUES ("7", "Civic");
INSERT INTO "model_list" VALUES ("8", "Mazda3");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("2", "Focus");
INSERT INTO "car_names" VALUES ("3", "Golf");
INSERT INTO "car_names" VALUES ("4", "Elantra");
INSERT INTO "car_names" VALUES ("5", "500");
INSERT INTO "car_names" VALUES ("6", "Model 3");
INSERT INTO "car_names" VALUES ("7", "Civic");
INSERT INTO "car_names" VALUES ("8", "Mazda3");
INSERT INTO "cars_data" VALUES ("1", "4", "132", "2800");
INSERT INTO "cars_data" VALUES ("2", "4", "160", "2900");
INSERT INTO "cars_data" VALUES ("3", "4", "147", "2950");
INSERT INTO "cars_data" VALUES ("4", "4", "147", "2850");
INSERT INTO "cars_data" VALUES ("5", "4", "101", "2500");
INSERT INTO "cars_data" VALUES ("6", "4", "283", "3550");
INSERT INTO "cars_data" VALUES ("7", "4", "158", "2700");
INSERT INTO "cars_data" VALUES ("8", "4", "155", "2650");