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

CREATE TABLE "car_names" (
"MakeId" INT UNIQUE,
"Model" TEXT,
"Make" 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 "car_makers" VALUES ("1", "ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("2", "toyota", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("3", "bmw", "Bayerische Motoren Werke AG");
INSERT INTO "car_makers" VALUES ("4", "honda", "Honda Motor Co., Ltd.");
INSERT INTO "car_makers" VALUES ("5", "tesla", "Tesla, Inc.");
INSERT INTO "model_list" VALUES ("1", "1", "mustang");
INSERT INTO "model_list" VALUES ("2", "1", "focus");
INSERT INTO "model_list" VALUES ("3", "2", "corolla");
INSERT INTO "model_list" VALUES ("4", "2", "camry");
INSERT INTO "model_list" VALUES ("5", "3", "x5");
INSERT INTO "model_list" VALUES ("6", "3", "m3");
INSERT INTO "model_list" VALUES ("7", "4", "civic");
INSERT INTO "model_list" VALUES ("8", "4", "accord");
INSERT INTO "model_list" VALUES ("9", "5", "model_s");
INSERT INTO "model_list" VALUES ("10", "5", "model_3");
INSERT INTO "car_names" VALUES ("101", "mustang", "ford");
INSERT INTO "car_names" VALUES ("102", "focus", "ford");
INSERT INTO "car_names" VALUES ("103", "corolla", "toyota");
INSERT INTO "car_names" VALUES ("104", "camry", "toyota");
INSERT INTO "car_names" VALUES ("105", "x5", "bmw");
INSERT INTO "car_names" VALUES ("106", "m3", "bmw");
INSERT INTO "car_names" VALUES ("107", "civic", "honda");
INSERT INTO "car_names" VALUES ("108", "accord", "honda");
INSERT INTO "car_names" VALUES ("109", "model_s", "tesla");
INSERT INTO "car_names" VALUES ("110", "model_3", "tesla");
INSERT INTO "cars_data" VALUES ("101", "450hp", "1964");
INSERT INTO "cars_data" VALUES ("102", "160hp", "1998");
INSERT INTO "cars_data" VALUES ("103", "132hp", "1966");
INSERT INTO "cars_data" VALUES ("104", "178hp", "1982");
INSERT INTO "cars_data" VALUES ("105", "300hp", "1999");
INSERT INTO "cars_data" VALUES ("106", "425hp", "2007");
INSERT INTO "cars_data" VALUES ("107", "158hp", "1972");
INSERT INTO "cars_data" VALUES ("108", "190hp", "1976");
INSERT INTO "cars_data" VALUES ("109", "670hp", "2012");
INSERT INTO "cars_data" VALUES ("110", "450hp", "2017");
INSERT INTO "countries" VALUES ("1", "USA");
INSERT INTO "countries" VALUES ("2", "Japan");
INSERT INTO "countries" VALUES ("3", "Germany");