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,
"MPG" TEXT,
"Cylinders" INT,
"Horsepower" TEXT,
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", "honda", "Honda Motor Co., Ltd.");
INSERT INTO "car_makers" VALUES ("4", "fiat", "Fiat Automobiles");
INSERT INTO "car_makers" VALUES ("5", "bmw", "Bayerische Motoren Werke AG");
INSERT INTO "model_list" VALUES ("101", "1", "focus");
INSERT INTO "model_list" VALUES ("102", "1", "fiesta");
INSERT INTO "model_list" VALUES ("103", "2", "yaris");
INSERT INTO "model_list" VALUES ("104", "2", "aygo");
INSERT INTO "model_list" VALUES ("105", "3", "fit");
INSERT INTO "model_list" VALUES ("106", "3", "civic");
INSERT INTO "model_list" VALUES ("107", "4", "500");
INSERT INTO "model_list" VALUES ("108", "4", "panda");
INSERT INTO "model_list" VALUES ("109", "5", "i3");
INSERT INTO "model_list" VALUES ("110", "5", "x1");
INSERT INTO "car_names" VALUES ("201", "focus", "ford");
INSERT INTO "car_names" VALUES ("202", "fiesta", "ford");
INSERT INTO "car_names" VALUES ("203", "yaris", "toyota");
INSERT INTO "car_names" VALUES ("204", "aygo", "toyota");
INSERT INTO "car_names" VALUES ("205", "fit", "honda");
INSERT INTO "car_names" VALUES ("206", "civic", "honda");
INSERT INTO "car_names" VALUES ("207", "500", "fiat");
INSERT INTO "car_names" VALUES ("208", "panda", "fiat");
INSERT INTO "car_names" VALUES ("209", "i3", "bmw");
INSERT INTO "car_names" VALUES ("210", "x1", "bmw");
INSERT INTO "cars_data" VALUES ("201", "30", "4", "120");
INSERT INTO "cars_data" VALUES ("202", "35", "3", "95");
INSERT INTO "cars_data" VALUES ("203", "40", "3", "105");
INSERT INTO "cars_data" VALUES ("204", "42", "3", "90");
INSERT INTO "cars_data" VALUES ("205", "38", "3", "110");
INSERT INTO "cars_data" VALUES ("206", "33", "4", "140");
INSERT INTO "cars_data" VALUES ("207", "36", "3", "85");
INSERT INTO "cars_data" VALUES ("208", "34", "4", "100");
INSERT INTO "cars_data" VALUES ("209", "28", "4", "170");
INSERT INTO "cars_data" VALUES ("210", "25", "6", "240");