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 "car_makers" VALUES ("1", "Ford", "Ford Motor Company", "1");
INSERT INTO "car_makers" VALUES ("2", "Toyota", "Toyota Motor Corporation", "2");
INSERT INTO "car_makers" VALUES ("3", "BMW", "Bayerische Motoren Werke AG", "3");
INSERT INTO "car_makers" VALUES ("4", "Hyundai", "Hyundai Motor Company", "4");
INSERT INTO "car_makers" VALUES ("5", "Honda", "Honda Motor Co., Ltd.", "2");
INSERT INTO "model_list" VALUES ("1", "1", "Mustang");
INSERT INTO "model_list" VALUES ("2", "1", "F-150");
INSERT INTO "model_list" VALUES ("3", "2", "Corolla");
INSERT INTO "model_list" VALUES ("4", "2", "Camry");
INSERT INTO "model_list" VALUES ("5", "3", "320i");
INSERT INTO "model_list" VALUES ("6", "3", "X5");
INSERT INTO "model_list" VALUES ("7", "4", "Elantra");
INSERT INTO "model_list" VALUES ("8", "4", "Santa Fe");
INSERT INTO "model_list" VALUES ("9", "5", "Civic");
INSERT INTO "model_list" VALUES ("10", "5", "Accord");
INSERT INTO "car_names" VALUES ("1", "Mustang");
INSERT INTO "car_names" VALUES ("2", "F-150");
INSERT INTO "car_names" VALUES ("3", "Corolla");
INSERT INTO "car_names" VALUES ("4", "Camry");
INSERT INTO "car_names" VALUES ("5", "320i");
INSERT INTO "car_names" VALUES ("6", "X5");
INSERT INTO "car_names" VALUES ("7", "Elantra");
INSERT INTO "car_names" VALUES ("8", "Santa Fe");
INSERT INTO "car_names" VALUES ("9", "Civic");
INSERT INTO "car_names" VALUES ("10", "Accord");
INSERT INTO "cars_data" VALUES ("1", "450 HP", "3700");
INSERT INTO "cars_data" VALUES ("2", "400 HP", "4500");
INSERT INTO "cars_data" VALUES ("3", "132 HP", "2800");
INSERT INTO "cars_data" VALUES ("4", "203 HP", "3300");
INSERT INTO "cars_data" VALUES ("5", "180 HP", "3200");
INSERT INTO "cars_data" VALUES ("6", "300 HP", "4800");
INSERT INTO "cars_data" VALUES ("7", "147 HP", "2900");
INSERT INTO "cars_data" VALUES ("8", "235 HP", "4100");
INSERT INTO "cars_data" VALUES ("9", "158 HP", "2700");
INSERT INTO "cars_data" VALUES ("10", "192 HP", "3400");