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"),
FOREIGN KEY ("Country") REFERENCES "countries"("CountryId")
);

CREATE TABLE "car_names" (
"MakeId" INT,
"Make" TEXT,
PRIMARY KEY ("MakeId")
);

CREATE TABLE "cars_data" (
"Id" INT,
"Year" INT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Id") REFERENCES "car_names"("MakeId")
);

CREATE TABLE "countries" (
"CountryId" INT UNIQUE,
"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 "countries" VALUES ("1", "USA");
INSERT INTO "countries" VALUES ("2", "Germany");
INSERT INTO "countries" VALUES ("3", "Japan");
INSERT INTO "countries" VALUES ("4", "Italy");
INSERT INTO "countries" VALUES ("5", "France");
INSERT INTO "car_makers" VALUES ("1", "Ford", "Ford Motor Company", "1");
INSERT INTO "car_makers" VALUES ("2", "GM", "General Motors", "1");
INSERT INTO "car_makers" VALUES ("3", "Toyota", "Toyota Motor Corporation", "3");
INSERT INTO "car_makers" VALUES ("4", "BMW", "Bayerische Motoren Werke AG", "2");
INSERT INTO "car_makers" VALUES ("5", "Fiat", "Fiat S.p.A.", "4");
INSERT INTO "car_makers" VALUES ("6", "Chrysler", "Chrysler Group LLC", "1");
INSERT INTO "car_makers" VALUES ("7", "Honda", "Honda Motor Co., Ltd.", "3");
INSERT INTO "car_makers" VALUES ("8", "Mercedes-Benz", "Daimler AG", "2");
INSERT INTO "car_makers" VALUES ("9", "Peugeot", "Groupe PSA", "5");
INSERT INTO "car_names" VALUES ("1", "Ford F-150");
INSERT INTO "car_names" VALUES ("2", "Chevrolet Silverado");
INSERT INTO "car_names" VALUES ("3", "Toyota Camry");
INSERT INTO "car_names" VALUES ("4", "BMW 3 Series");
INSERT INTO "car_names" VALUES ("5", "Fiat 500");
INSERT INTO "car_names" VALUES ("6", "Dodge Ram");
INSERT INTO "car_names" VALUES ("7", "Honda Civic");
INSERT INTO "car_names" VALUES ("8", "Mercedes-Benz C-Class");
INSERT INTO "car_names" VALUES ("9", "Peugeot 208");
INSERT INTO "car_names" VALUES ("10", "Ford Mustang");
INSERT INTO "car_names" VALUES ("11", "Chevrolet Malibu");
INSERT INTO "car_names" VALUES ("12", "Toyota Corolla");
INSERT INTO "car_names" VALUES ("13", "BMW X5");
INSERT INTO "car_names" VALUES ("14", "Jeep Wrangler");
INSERT INTO "car_names" VALUES ("15", "Honda CR-V");
INSERT INTO "car_names" VALUES ("16", "Ford Explorer");
INSERT INTO "car_names" VALUES ("17", "Cadillac Escalade");
INSERT INTO "car_names" VALUES ("18", "Tesla Model S");
INSERT INTO "car_names" VALUES ("19", "Tesla Model 3");
INSERT INTO "cars_data" VALUES ("1", "2020");
INSERT INTO "cars_data" VALUES ("2", "2021");
INSERT INTO "cars_data" VALUES ("3", "2019");
INSERT INTO "cars_data" VALUES ("4", "2022");
INSERT INTO "cars_data" VALUES ("5", "2018");
INSERT INTO "cars_data" VALUES ("6", "2020");
INSERT INTO "cars_data" VALUES ("7", "2021");
INSERT INTO "cars_data" VALUES ("8", "2022");
INSERT INTO "cars_data" VALUES ("9", "2019");
INSERT INTO "cars_data" VALUES ("10", "2023");
INSERT INTO "cars_data" VALUES ("11", "2022");
INSERT INTO "cars_data" VALUES ("12", "2020");
INSERT INTO "cars_data" VALUES ("13", "2021");
INSERT INTO "cars_data" VALUES ("14", "2023");
INSERT INTO "cars_data" VALUES ("15", "2022");
INSERT INTO "cars_data" VALUES ("16", "2021");
INSERT INTO "cars_data" VALUES ("17", "2023");
INSERT INTO "cars_data" VALUES ("18", "2022");
INSERT INTO "cars_data" VALUES ("19", "2023");
INSERT INTO "model_list" VALUES ("1", "1", "F-150");
INSERT INTO "model_list" VALUES ("2", "2", "Silverado");
INSERT INTO "model_list" VALUES ("3", "3", "Camry");
INSERT INTO "model_list" VALUES ("4", "4", "3 Series");
INSERT INTO "model_list" VALUES ("5", "5", "500");
INSERT INTO "model_list" VALUES ("6", "6", "Ram 1500");
INSERT INTO "model_list" VALUES ("7", "7", "Civic");
INSERT INTO "model_list" VALUES ("8", "8", "C-Class");
INSERT INTO "model_list" VALUES ("9", "9", "208");
INSERT INTO "model_list" VALUES ("10", "1", "Mustang");
INSERT INTO "model_list" VALUES ("11", "2", "Malibu");
INSERT INTO "model_list" VALUES ("12", "3", "Corolla");
INSERT INTO "model_list" VALUES ("13", "4", "X5");
INSERT INTO "model_list" VALUES ("14", "6", "Wrangler");
INSERT INTO "model_list" VALUES ("15", "7", "CR-V");
INSERT INTO "model_list" VALUES ("16", "1", "Explorer");
INSERT INTO "model_list" VALUES ("17", "2", "Escalade");
INSERT INTO "model_list" VALUES ("18", "1", "Model S");
INSERT INTO "model_list" VALUES ("19", "1", "Model 3");