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,
"Year" INT,
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", "Ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("2", "GM", "General Motors");
INSERT INTO "car_makers" VALUES ("3", "Toyota", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("4", "Honda", "Honda Motor Co.");
INSERT INTO "car_makers" VALUES ("5", "BMW", "Bayerische Motoren Werke AG");
INSERT INTO "car_makers" VALUES ("6", "Mercedes", "Mercedes-Benz Group AG");
INSERT INTO "car_makers" VALUES ("7", "Nissan", "Nissan Motor Corporation");
INSERT INTO "car_makers" VALUES ("8", "Hyundai", "Hyundai Motor Company");
INSERT INTO "car_makers" VALUES ("9", "Kia", "Kia Corporation");
INSERT INTO "car_makers" VALUES ("10", "Audi", "Audi AG");
INSERT INTO "model_list" VALUES ("101", "1", "F-150");
INSERT INTO "model_list" VALUES ("102", "1", "Explorer");
INSERT INTO "model_list" VALUES ("103", "1", "Mustang");
INSERT INTO "model_list" VALUES ("104", "1", "Escape");
INSERT INTO "model_list" VALUES ("201", "2", "Silverado");
INSERT INTO "model_list" VALUES ("202", "2", "Equinox");
INSERT INTO "model_list" VALUES ("203", "2", "Tahoe");
INSERT INTO "model_list" VALUES ("301", "3", "Camry");
INSERT INTO "model_list" VALUES ("302", "3", "Corolla");
INSERT INTO "model_list" VALUES ("303", "3", "RAV4");
INSERT INTO "model_list" VALUES ("304", "3", "Highlander");
INSERT INTO "model_list" VALUES ("401", "4", "Civic");
INSERT INTO "model_list" VALUES ("402", "4", "CR-V");
INSERT INTO "model_list" VALUES ("501", "5", "3 Series");
INSERT INTO "model_list" VALUES ("502", "5", "X5");
INSERT INTO "model_list" VALUES ("601", "6", "C-Class");
INSERT INTO "model_list" VALUES ("701", "7", "Altima");
INSERT INTO "model_list" VALUES ("702", "7", "Rogue");
INSERT INTO "model_list" VALUES ("801", "8", "Elantra");
INSERT INTO "model_list" VALUES ("901", "9", "Sportage");
INSERT INTO "model_list" VALUES ("1001", "10", "A4");
INSERT INTO "car_names" VALUES ("1", "F-150", "Ford");
INSERT INTO "car_names" VALUES ("2", "Explorer", "Ford");
INSERT INTO "car_names" VALUES ("3", "Mustang", "Ford");
INSERT INTO "car_names" VALUES ("4", "Escape", "Ford");
INSERT INTO "car_names" VALUES ("5", "Silverado", "GM");
INSERT INTO "car_names" VALUES ("6", "Equinox", "GM");
INSERT INTO "car_names" VALUES ("7", "Tahoe", "GM");
INSERT INTO "car_names" VALUES ("8", "Camry", "Toyota");
INSERT INTO "car_names" VALUES ("9", "Corolla", "Toyota");
INSERT INTO "car_names" VALUES ("10", "RAV4", "Toyota");
INSERT INTO "car_names" VALUES ("11", "Highlander", "Toyota");
INSERT INTO "car_names" VALUES ("12", "Civic", "Honda");
INSERT INTO "car_names" VALUES ("13", "CR-V", "Honda");
INSERT INTO "car_names" VALUES ("14", "3 Series", "BMW");
INSERT INTO "car_names" VALUES ("15", "X5", "BMW");
INSERT INTO "car_names" VALUES ("16", "C-Class", "Mercedes");
INSERT INTO "car_names" VALUES ("17", "Altima", "Nissan");
INSERT INTO "car_names" VALUES ("18", "Rogue", "Nissan");
INSERT INTO "car_names" VALUES ("19", "Elantra", "Hyundai");
INSERT INTO "car_names" VALUES ("20", "Sportage", "Kia");
INSERT INTO "car_names" VALUES ("21", "A4", "Audi");
INSERT INTO "cars_data" VALUES ("1", "2020");
INSERT INTO "cars_data" VALUES ("2", "2021");
INSERT INTO "cars_data" VALUES ("3", "2022");
INSERT INTO "cars_data" VALUES ("4", "2023");
INSERT INTO "cars_data" VALUES ("5", "2020");
INSERT INTO "cars_data" VALUES ("6", "2021");
INSERT INTO "cars_data" VALUES ("7", "2022");
INSERT INTO "cars_data" VALUES ("8", "2020");
INSERT INTO "cars_data" VALUES ("9", "2021");
INSERT INTO "cars_data" VALUES ("10", "2022");
INSERT INTO "cars_data" VALUES ("11", "2023");
INSERT INTO "cars_data" VALUES ("12", "2020");
INSERT INTO "cars_data" VALUES ("13", "2021");
INSERT INTO "cars_data" VALUES ("14", "2020");
INSERT INTO "cars_data" VALUES ("15", "2021");
INSERT INTO "cars_data" VALUES ("16", "2020");
INSERT INTO "cars_data" VALUES ("17", "2021");
INSERT INTO "cars_data" VALUES ("18", "2022");
INSERT INTO "cars_data" VALUES ("19", "2020");
INSERT INTO "cars_data" VALUES ("20", "2021");
INSERT INTO "cars_data" VALUES ("21", "2020");
INSERT INTO "cars_data" VALUES ("1", "2019");
INSERT INTO "cars_data" VALUES ("2", "2018");
INSERT INTO "cars_data" VALUES ("3", "2017");
INSERT INTO "cars_data" VALUES ("5", "2019");
INSERT INTO "cars_data" VALUES ("6", "2018");
INSERT INTO "cars_data" VALUES ("8", "2019");
INSERT INTO "cars_data" VALUES ("9", "2018");
INSERT INTO "cars_data" VALUES ("10", "2017");
INSERT INTO "cars_data" VALUES ("12", "2019");
INSERT INTO "cars_data" VALUES ("14", "2019");
INSERT INTO "cars_data" VALUES ("17", "2019");