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,
"FullName" TEXT,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Country") REFERENCES "countries"("CountryId")
);

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,
"Horsepower" TEXT,
"Year" INT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Id") REFERENCES "car_names"("MakeId")
);

CREATE TABLE "countries" (
"CountryId" INT,
"CountryName" TEXT,
PRIMARY KEY ("CountryId")
);

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





INSERT INTO "countries" VALUES ("1", "Japan");
INSERT INTO "countries" VALUES ("2", "Germany");
INSERT INTO "countries" VALUES ("3", "United States");
INSERT INTO "countries" VALUES ("4", "Italy");
INSERT INTO "countries" VALUES ("5", "France");
INSERT INTO "car_makers" VALUES ("10", "Toyota", "Toyota Motor Corporation", "1");
INSERT INTO "car_makers" VALUES ("20", "BMW", "Bayerische Motoren Werke AG", "2");
INSERT INTO "car_makers" VALUES ("30", "Ford", "Ford Motor Company", "3");
INSERT INTO "car_makers" VALUES ("40", "Ferrari", "Ferrari S.p.A.", "4");
INSERT INTO "car_makers" VALUES ("50", "Peugeot", "Peugeot S.A.", "5");
INSERT INTO "car_makers" VALUES ("60", "Nissan", "Nissan Motor Corporation", "1");
INSERT INTO "model_list" VALUES ("100", "10", "Corolla");
INSERT INTO "model_list" VALUES ("101", "10", "Celica");
INSERT INTO "model_list" VALUES ("102", "20", "320i");
INSERT INTO "model_list" VALUES ("103", "20", "M3");
INSERT INTO "model_list" VALUES ("104", "30", "Mustang");
INSERT INTO "model_list" VALUES ("105", "30", "F-150");
INSERT INTO "model_list" VALUES ("106", "40", "Daytona");
INSERT INTO "model_list" VALUES ("107", "50", "504");
INSERT INTO "model_list" VALUES ("108", "60", "Skyline");
INSERT INTO "model_list" VALUES ("109", "60", "Z");
INSERT INTO "car_names" VALUES ("100", "Corolla");
INSERT INTO "car_names" VALUES ("101", "Celica");
INSERT INTO "car_names" VALUES ("102", "320i");
INSERT INTO "car_names" VALUES ("103", "M3");
INSERT INTO "car_names" VALUES ("104", "Mustang");
INSERT INTO "car_names" VALUES ("105", "F-150");
INSERT INTO "car_names" VALUES ("106", "Daytona");
INSERT INTO "car_names" VALUES ("107", "504");
INSERT INTO "car_names" VALUES ("108", "Skyline");
INSERT INTO "car_names" VALUES ("109", "Z");
INSERT INTO "cars_data" VALUES ("100", "110 HP", "1970");
INSERT INTO "cars_data" VALUES ("101", "120 HP", "1969");
INSERT INTO "cars_data" VALUES ("102", "130 HP", "1970");
INSERT INTO "cars_data" VALUES ("103", "200 HP", "1985");
INSERT INTO "cars_data" VALUES ("104", "250 HP", "1970");
INSERT INTO "cars_data" VALUES ("105", "300 HP", "1975");
INSERT INTO "cars_data" VALUES ("106", "350 HP", "1968");
INSERT INTO "cars_data" VALUES ("107", "90 HP", "1970");
INSERT INTO "cars_data" VALUES ("108", "160 HP", "1971");
INSERT INTO "cars_data" VALUES ("109", "180 HP", "1970");