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", "Golf");
INSERT INTO "car_names" VALUES ("103", "Mustang");
INSERT INTO "car_names" VALUES ("104", "Fiat 500");
INSERT INTO "car_names" VALUES ("105", "Peugeot 205");
INSERT INTO "car_names" VALUES ("106", "Camry");
INSERT INTO "car_names" VALUES ("107", "911");
INSERT INTO "car_names" VALUES ("108", "Charger");
INSERT INTO "car_names" VALUES ("109", "Spider");
INSERT INTO "car_names" VALUES ("110", "Renault 5");
INSERT INTO "cars_data" VALUES ("101", "75", "1979");
INSERT INTO "cars_data" VALUES ("102", "110", "1980");
INSERT INTO "cars_data" VALUES ("103", "165", "1967");
INSERT INTO "cars_data" VALUES ("104", "43", "1970");
INSERT INTO "cars_data" VALUES ("105", "60", "1979");
INSERT INTO "cars_data" VALUES ("106", "120", "1985");
INSERT INTO "cars_data" VALUES ("107", "130", "1978");
INSERT INTO "cars_data" VALUES ("108", "150", "1979");
INSERT INTO "cars_data" VALUES ("109", "missing", "1975");
INSERT INTO "cars_data" VALUES ("110", "85 hp", "1979");
INSERT INTO "model_list" VALUES ("101", "1");
INSERT INTO "model_list" VALUES ("102", "2");
INSERT INTO "model_list" VALUES ("103", "3");
INSERT INTO "model_list" VALUES ("104", "4");
INSERT INTO "model_list" VALUES ("105", "5");
INSERT INTO "model_list" VALUES ("106", "1");
INSERT INTO "model_list" VALUES ("107", "2");
INSERT INTO "model_list" VALUES ("108", "3");
INSERT INTO "model_list" VALUES ("109", "4");
INSERT INTO "model_list" VALUES ("110", "5");