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 "countries" VALUES ("6", "UK");
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", "Chrysler", "Chrysler LLC", "1");
INSERT INTO "car_makers" VALUES ("4", "BMW", "Bayerische Motoren Werke AG", "2");
INSERT INTO "car_makers" VALUES ("5", "Mercedes-Benz", "Mercedes-Benz Group AG", "2");
INSERT INTO "car_makers" VALUES ("6", "Toyota", "Toyota Motor Corporation", "3");
INSERT INTO "car_makers" VALUES ("7", "Honda", "Honda Motor Co., Ltd.", "3");
INSERT INTO "car_makers" VALUES ("8", "Ferrari", "Ferrari S.p.A.", "4");
INSERT INTO "car_makers" VALUES ("9", "Peugeot", "Automobiles Peugeot", "5");
INSERT INTO "car_makers" VALUES ("10", "Jaguar", "Jaguar Land Rover", "6");
INSERT INTO "car_names" VALUES ("1", "Ford");
INSERT INTO "car_names" VALUES ("2", "GM");
INSERT INTO "car_names" VALUES ("3", "Chrysler");
INSERT INTO "car_names" VALUES ("4", "BMW");
INSERT INTO "car_names" VALUES ("5", "Mercedes-Benz");
INSERT INTO "car_names" VALUES ("6", "Toyota");
INSERT INTO "car_names" VALUES ("7", "Honda");
INSERT INTO "car_names" VALUES ("8", "Ferrari");
INSERT INTO "car_names" VALUES ("9", "Peugeot");
INSERT INTO "car_names" VALUES ("10", "Jaguar");
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", "2020");
INSERT INTO "cars_data" VALUES ("6", "2021");
INSERT INTO "cars_data" VALUES ("7", "2018");
INSERT INTO "cars_data" VALUES ("8", "2023");
INSERT INTO "cars_data" VALUES ("9", "2017");
INSERT INTO "cars_data" VALUES ("10", "2022");
INSERT INTO "model_list" VALUES ("101", "1", "F-150");
INSERT INTO "model_list" VALUES ("102", "1", "Mustang");
INSERT INTO "model_list" VALUES ("103", "1", "Explorer");
INSERT INTO "model_list" VALUES ("104", "2", "Silverado");
INSERT INTO "model_list" VALUES ("105", "2", "Corvette");
INSERT INTO "model_list" VALUES ("106", "3", "Ram 1500");
INSERT INTO "model_list" VALUES ("107", "3", "Challenger");
INSERT INTO "model_list" VALUES ("108", "4", "3 Series");
INSERT INTO "model_list" VALUES ("109", "4", "X5");
INSERT INTO "model_list" VALUES ("110", "5", "C-Class");
INSERT INTO "model_list" VALUES ("111", "5", "E-Class");
INSERT INTO "model_list" VALUES ("112", "6", "Camry");
INSERT INTO "model_list" VALUES ("113", "6", "Corolla");
INSERT INTO "model_list" VALUES ("114", "7", "Civic");
INSERT INTO "model_list" VALUES ("115", "7", "CR-V");
INSERT INTO "model_list" VALUES ("116", "8", "488 GTB");
INSERT INTO "model_list" VALUES ("117", "9", "208");
INSERT INTO "model_list" VALUES ("118", "10", "F-Pace");
INSERT INTO "model_list" VALUES ("119", "1", "Escape");
INSERT INTO "model_list" VALUES ("120", "2", "Tahoe");
INSERT INTO "model_list" VALUES ("121", "3", "Grand Cherokee");
INSERT INTO "model_list" VALUES ("122", "4", "5 Series");
INSERT INTO "model_list" VALUES ("123", "5", "S-Class");
INSERT INTO "model_list" VALUES ("124", "6", "RAV4");
INSERT INTO "model_list" VALUES ("125", "7", "Accord");