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

CREATE TABLE "model_list" (
"ModelId" INT,
"Model" TEXT UNIQUE,
PRIMARY KEY ("ModelId")
);





INSERT INTO "car_makers" VALUES ("1", "Toyota", "Japan");
INSERT INTO "car_makers" VALUES ("2", "Ford", "USA");
INSERT INTO "car_makers" VALUES ("3", "Volkswagen", "Germany");
INSERT INTO "car_makers" VALUES ("4", "Hyundai", "South Korea");
INSERT INTO "car_makers" VALUES ("5", "Tesla", "USA");
INSERT INTO "car_makers" VALUES ("6", "Fiat", "Italy");
INSERT INTO "car_makers" VALUES ("7", "Renault", "France");
INSERT INTO "model_list" VALUES ("101", "Corolla");
INSERT INTO "model_list" VALUES ("102", "Mustang");
INSERT INTO "model_list" VALUES ("103", "Golf");
INSERT INTO "model_list" VALUES ("104", "Elantra");
INSERT INTO "model_list" VALUES ("105", "Model S");
INSERT INTO "model_list" VALUES ("106", "500");
INSERT INTO "model_list" VALUES ("107", "Clio");
INSERT INTO "model_list" VALUES ("108", "Prius");
INSERT INTO "model_list" VALUES ("109", "F-150");
INSERT INTO "model_list" VALUES ("110", "Tiguan");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("2", "Mustang");
INSERT INTO "car_names" VALUES ("3", "Golf");
INSERT INTO "car_names" VALUES ("4", "Elantra");
INSERT INTO "car_names" VALUES ("5", "Model S");
INSERT INTO "car_names" VALUES ("6", "500");
INSERT INTO "car_names" VALUES ("7", "Clio");
INSERT INTO "car_names" VALUES ("8", "Prius");
INSERT INTO "car_names" VALUES ("9", "F-150");
INSERT INTO "car_names" VALUES ("10", "Tiguan");
INSERT INTO "cars_data" VALUES ("1", "32", "132");
INSERT INTO "cars_data" VALUES ("2", "21", "450");
INSERT INTO "cars_data" VALUES ("3", "29", "170");
INSERT INTO "cars_data" VALUES ("4", "33", "147");
INSERT INTO "cars_data" VALUES ("5", "102", "670");
INSERT INTO "cars_data" VALUES ("6", "28", "101");
INSERT INTO "cars_data" VALUES ("7", "35", "90");
INSERT INTO "cars_data" VALUES ("8", "56", "121");
INSERT INTO "cars_data" VALUES ("9", "19", "400");
INSERT INTO "cars_data" VALUES ("10", "27", "184");