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

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

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

CREATE TABLE "model_list" (
"ModelId" INT,
"Maker" INT,
PRIMARY KEY ("ModelId"),
FOREIGN KEY ("Maker") REFERENCES "car_makers"("Id")
);





INSERT INTO "car_makers" VALUES ("1", "Japan");
INSERT INTO "car_makers" VALUES ("2", "Germany");
INSERT INTO "car_makers" VALUES ("3", "USA");
INSERT INTO "car_makers" VALUES ("4", "Italy");
INSERT INTO "car_makers" VALUES ("5", "France");
INSERT INTO "car_names" VALUES ("101", "Corolla");
INSERT INTO "car_names" VALUES ("102", "Mustang");
INSERT INTO "car_names" VALUES ("103", "911");
INSERT INTO "car_names" VALUES ("104", "Civic");
INSERT INTO "car_names" VALUES ("105", "Camaro");
INSERT INTO "car_names" VALUES ("106", "Alfa Romeo Spider");
INSERT INTO "car_names" VALUES ("107", "Peugeot 504");
INSERT INTO "car_names" VALUES ("108", "Beetle");
INSERT INTO "car_names" VALUES ("109", "Fiat 124");
INSERT INTO "car_names" VALUES ("110", "Datsun 240Z");
INSERT INTO "cars_data" VALUES ("101", "75", "1975");
INSERT INTO "cars_data" VALUES ("102", "210", "1969");
INSERT INTO "cars_data" VALUES ("103", "180", "1985");
INSERT INTO "cars_data" VALUES ("104", "67", "1978");
INSERT INTO "cars_data" VALUES ("105", "190", "1979");
INSERT INTO "cars_data" VALUES ("106", "118", "1977");
INSERT INTO "cars_data" VALUES ("107", "96", "1982");
INSERT INTO "cars_data" VALUES ("108", "40", "1970");
INSERT INTO "cars_data" VALUES ("109", "90", "1973");
INSERT INTO "cars_data" VALUES ("110", "151", "1971");
INSERT INTO "model_list" VALUES ("201", "1");
INSERT INTO "model_list" VALUES ("202", "3");
INSERT INTO "model_list" VALUES ("203", "2");
INSERT INTO "model_list" VALUES ("204", "1");
INSERT INTO "model_list" VALUES ("205", "3");
INSERT INTO "model_list" VALUES ("206", "4");
INSERT INTO "model_list" VALUES ("207", "5");
INSERT INTO "model_list" VALUES ("208", "3");
INSERT INTO "model_list" VALUES ("209", "4");
INSERT INTO "model_list" VALUES ("210", "1");