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", "Hyundai", "South Korea");
INSERT INTO "car_makers" VALUES ("5", "Renault", "France");
INSERT INTO "car_names" VALUES ("101", "Corolla");
INSERT INTO "car_names" VALUES ("102", "Fiesta");
INSERT INTO "car_names" VALUES ("103", "500");
INSERT INTO "car_names" VALUES ("104", "Accent");
INSERT INTO "car_names" VALUES ("105", "Clio");
INSERT INTO "cars_data" VALUES ("101", "4", "132", "2800");
INSERT INTO "cars_data" VALUES ("102", "3", "120", "2500");
INSERT INTO "cars_data" VALUES ("103", "3", "105", "2100");
INSERT INTO "cars_data" VALUES ("104", "3", "110", "2300");
INSERT INTO "cars_data" VALUES ("105", "4", "140", "2700");
INSERT INTO "model_list" VALUES ("201", "Corolla LE");
INSERT INTO "model_list" VALUES ("202", "Fiesta ST");
INSERT INTO "model_list" VALUES ("203", "500 Pop");
INSERT INTO "model_list" VALUES ("204", "Accent GLS");
INSERT INTO "model_list" VALUES ("205", "Clio RS");