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")
);

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

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





INSERT INTO "car_makers" VALUES ("1", "Toyota", "Toyota Motor Corporation", "Japan");
INSERT INTO "car_makers" VALUES ("2", "Ford", "Ford Motor Company", "USA");
INSERT INTO "car_makers" VALUES ("3", "BMW", "Bayerische Motoren Werke AG", "Germany");
INSERT INTO "car_makers" VALUES ("4", "Hyundai", "Hyundai Motor Company", "South Korea");
INSERT INTO "car_makers" VALUES ("5", "Tesla", "Tesla, Inc.", "USA");
INSERT INTO "model_list" VALUES ("101", "1", "Corolla");
INSERT INTO "model_list" VALUES ("102", "1", "Camry");
INSERT INTO "model_list" VALUES ("103", "1", "Prius");
INSERT INTO "model_list" VALUES ("201", "2", "F-150");
INSERT INTO "model_list" VALUES ("202", "2", "Mustang");
INSERT INTO "model_list" VALUES ("203", "2", "Explorer");
INSERT INTO "model_list" VALUES ("301", "3", "X5");
INSERT INTO "model_list" VALUES ("302", "3", "3 Series");
INSERT INTO "model_list" VALUES ("401", "4", "Elantra");
INSERT INTO "model_list" VALUES ("402", "4", "Santa Fe");
INSERT INTO "model_list" VALUES ("501", "5", "Model S");
INSERT INTO "model_list" VALUES ("502", "5", "Model 3");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("2", "F-150");
INSERT INTO "car_names" VALUES ("3", "X5");
INSERT INTO "car_names" VALUES ("4", "Elantra");
INSERT INTO "car_names" VALUES ("5", "Model S");
INSERT INTO "car_names" VALUES ("6", "Camry");
INSERT INTO "car_names" VALUES ("7", "Mustang");
INSERT INTO "car_names" VALUES ("8", "3 Series");
INSERT INTO "car_names" VALUES ("9", "Santa Fe");
INSERT INTO "car_names" VALUES ("10", "Model 3");
INSERT INTO "car_names" VALUES ("11", "Prius");
INSERT INTO "car_names" VALUES ("12", "Explorer");
INSERT INTO "cars_data" VALUES ("1", "132hp");
INSERT INTO "cars_data" VALUES ("2", "290hp");
INSERT INTO "cars_data" VALUES ("3", "335hp");
INSERT INTO "cars_data" VALUES ("4", "147hp");
INSERT INTO "cars_data" VALUES ("5", "670hp");
INSERT INTO "cars_data" VALUES ("6", "203hp");
INSERT INTO "cars_data" VALUES ("7", "450hp");
INSERT INTO "cars_data" VALUES ("8", "255hp");
INSERT INTO "cars_data" VALUES ("9", "191hp");
INSERT INTO "cars_data" VALUES ("10", "283hp");
INSERT INTO "cars_data" VALUES ("11", "121hp");
INSERT INTO "cars_data" VALUES ("12", "300hp");