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,
"Weight" 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", "USA");
INSERT INTO "countries" VALUES ("2", "Japan");
INSERT INTO "countries" VALUES ("3", "Germany");
INSERT INTO "countries" VALUES ("4", "South Korea");
INSERT INTO "countries" VALUES ("5", "Italy");
INSERT INTO "car_makers" VALUES ("10", "Ford", "Ford Motor Company", "1");
INSERT INTO "car_makers" VALUES ("20", "Toyota", "Toyota Motor Corporation", "2");
INSERT INTO "car_makers" VALUES ("30", "BMW", "Bayerische Motoren Werke AG", "3");
INSERT INTO "car_makers" VALUES ("40", "Hyundai", "Hyundai Motor Company", "4");
INSERT INTO "car_makers" VALUES ("50", "Ferrari", "Ferrari S.p.A.", "5");
INSERT INTO "model_list" VALUES ("100", "10", "F-150");
INSERT INTO "model_list" VALUES ("101", "10", "Mustang");
INSERT INTO "model_list" VALUES ("102", "20", "Corolla");
INSERT INTO "model_list" VALUES ("103", "20", "Camry");
INSERT INTO "model_list" VALUES ("104", "30", "320i");
INSERT INTO "model_list" VALUES ("105", "30", "X5");
INSERT INTO "model_list" VALUES ("106", "40", "Elantra");
INSERT INTO "model_list" VALUES ("107", "40", "Santa Fe");
INSERT INTO "model_list" VALUES ("108", "50", "488 Spider");
INSERT INTO "model_list" VALUES ("109", "50", "Portofino");
INSERT INTO "model_list" VALUES ("110", "20", "Yaris");
INSERT INTO "model_list" VALUES ("111", "30", "M3");
INSERT INTO "model_list" VALUES ("112", "40", "Kona");
INSERT INTO "car_names" VALUES ("100", "F-150");
INSERT INTO "car_names" VALUES ("101", "Mustang");
INSERT INTO "car_names" VALUES ("102", "Corolla");
INSERT INTO "car_names" VALUES ("103", "Camry");
INSERT INTO "car_names" VALUES ("104", "320i");
INSERT INTO "car_names" VALUES ("105", "X5");
INSERT INTO "car_names" VALUES ("106", "Elantra");
INSERT INTO "car_names" VALUES ("107", "Santa Fe");
INSERT INTO "car_names" VALUES ("108", "488 Spider");
INSERT INTO "car_names" VALUES ("109", "Portofino");
INSERT INTO "car_names" VALUES ("110", "Yaris");
INSERT INTO "car_names" VALUES ("111", "M3");
INSERT INTO "car_names" VALUES ("112", "Kona");
INSERT INTO "cars_data" VALUES ("100", "290 HP", "4500");
INSERT INTO "cars_data" VALUES ("101", "450 HP", "3700");
INSERT INTO "cars_data" VALUES ("102", "132 HP", "2800");
INSERT INTO "cars_data" VALUES ("103", "203 HP", "3300");
INSERT INTO "cars_data" VALUES ("104", "180 HP", "3200");
INSERT INTO "cars_data" VALUES ("105", "335 HP", "4800");
INSERT INTO "cars_data" VALUES ("106", "147 HP", "2900");
INSERT INTO "cars_data" VALUES ("107", "235 HP", "3600");
INSERT INTO "cars_data" VALUES ("108", "661 HP", "3200");
INSERT INTO "cars_data" VALUES ("109", "591 HP", "3400");
INSERT INTO "cars_data" VALUES ("110", "106 HP", "2400");
INSERT INTO "cars_data" VALUES ("111", "473 HP", "3500");
INSERT INTO "cars_data" VALUES ("112", "175 HP", "3200");