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 UNIQUE,
"Model" TEXT,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY ("Model") REFERENCES "model_list"("Model")
);

CREATE TABLE "cars_data" (
"Id" 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", "Italy");
INSERT INTO "countries" VALUES ("4", "Japan");
INSERT INTO "countries" VALUES ("5", "France");
INSERT INTO "countries" VALUES ("6", "UK");
INSERT INTO "countries" VALUES ("7", "Sweden");
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", "Daimler AG", "2");
INSERT INTO "car_makers" VALUES ("6", "Audi", "Audi AG", "2");
INSERT INTO "car_makers" VALUES ("7", "fiat", "Fiat S.p.A.", "3");
INSERT INTO "car_makers" VALUES ("8", "Ferrari", "Ferrari S.p.A.", "3");
INSERT INTO "car_makers" VALUES ("9", "Toyota", "Toyota Motor Corporation", "4");
INSERT INTO "car_makers" VALUES ("10", "Honda", "Honda Motor Co., Ltd.", "4");
INSERT INTO "car_makers" VALUES ("11", "Nissan", "Nissan Motor Corporation", "4");
INSERT INTO "car_makers" VALUES ("12", "Renault", "Groupe Renault", "5");
INSERT INTO "car_makers" VALUES ("13", "Peugeot", "Peugeot S.A.", "5");
INSERT INTO "car_makers" VALUES ("14", "Volvo", "Volvo Cars", "7");
INSERT INTO "car_makers" VALUES ("15", "Jaguar", "Jaguar Land Rover", "6");
INSERT INTO "car_makers" VALUES ("16", "Volkswagen", "Volkswagen AG", "2");
INSERT INTO "model_list" VALUES ("1", "1", "F-150");
INSERT INTO "model_list" VALUES ("2", "1", "Mustang");
INSERT INTO "model_list" VALUES ("3", "2", "Silverado");
INSERT INTO "model_list" VALUES ("4", "2", "Corvette");
INSERT INTO "model_list" VALUES ("5", "3", "Ram 1500");
INSERT INTO "model_list" VALUES ("6", "3", "Jeep Wrangler");
INSERT INTO "model_list" VALUES ("7", "4", "3 Series");
INSERT INTO "model_list" VALUES ("8", "4", "X5");
INSERT INTO "model_list" VALUES ("9", "5", "C-Class");
INSERT INTO "model_list" VALUES ("10", "5", "E-Class");
INSERT INTO "model_list" VALUES ("11", "6", "A4");
INSERT INTO "model_list" VALUES ("12", "6", "Q5");
INSERT INTO "model_list" VALUES ("13", "7", "Fiat 500");
INSERT INTO "model_list" VALUES ("14", "7", "Panda");
INSERT INTO "model_list" VALUES ("15", "8", "488 GTB");
INSERT INTO "model_list" VALUES ("16", "9", "Camry");
INSERT INTO "model_list" VALUES ("17", "9", "Corolla");
INSERT INTO "model_list" VALUES ("18", "10", "Civic");
INSERT INTO "model_list" VALUES ("19", "10", "CR-V");
INSERT INTO "model_list" VALUES ("20", "11", "Altima");
INSERT INTO "model_list" VALUES ("21", "11", "Rogue");
INSERT INTO "model_list" VALUES ("22", "12", "Clio");
INSERT INTO "model_list" VALUES ("23", "13", "208");
INSERT INTO "model_list" VALUES ("24", "14", "XC90");
INSERT INTO "model_list" VALUES ("25", "15", "F-Pace");
INSERT INTO "model_list" VALUES ("26", "16", "Golf");
INSERT INTO "model_list" VALUES ("27", "16", "Passat");
INSERT INTO "car_names" VALUES ("1", "F-150", "Ford");
INSERT INTO "car_names" VALUES ("2", "Mustang", "Ford");
INSERT INTO "car_names" VALUES ("3", "Silverado", "GM");
INSERT INTO "car_names" VALUES ("4", "Corvette", "GM");
INSERT INTO "car_names" VALUES ("5", "Ram 1500", "Chrysler");
INSERT INTO "car_names" VALUES ("6", "Jeep Wrangler", "Chrysler");
INSERT INTO "car_names" VALUES ("7", "3 Series", "BMW");
INSERT INTO "car_names" VALUES ("8", "X5", "BMW");
INSERT INTO "car_names" VALUES ("9", "C-Class", "Mercedes-Benz");
INSERT INTO "car_names" VALUES ("10", "E-Class", "Mercedes-Benz");
INSERT INTO "car_names" VALUES ("11", "A4", "Audi");
INSERT INTO "car_names" VALUES ("12", "Q5", "Audi");
INSERT INTO "car_names" VALUES ("13", "Fiat 500", "fiat");
INSERT INTO "car_names" VALUES ("14", "Panda", "fiat");
INSERT INTO "car_names" VALUES ("15", "488 GTB", "Ferrari");
INSERT INTO "car_names" VALUES ("16", "Camry", "Toyota");
INSERT INTO "car_names" VALUES ("17", "Corolla", "Toyota");
INSERT INTO "car_names" VALUES ("18", "Civic", "Honda");
INSERT INTO "car_names" VALUES ("19", "CR-V", "Honda");
INSERT INTO "car_names" VALUES ("20", "Altima", "Nissan");
INSERT INTO "car_names" VALUES ("21", "Rogue", "Nissan");
INSERT INTO "car_names" VALUES ("22", "Clio", "Renault");
INSERT INTO "car_names" VALUES ("23", "208", "Peugeot");
INSERT INTO "car_names" VALUES ("24", "XC90", "Volvo");
INSERT INTO "car_names" VALUES ("25", "F-Pace", "Jaguar");
INSERT INTO "car_names" VALUES ("26", "Golf", "Volkswagen");
INSERT INTO "car_names" VALUES ("27", "Passat", "Volkswagen");
INSERT INTO "cars_data" VALUES ("1");
INSERT INTO "cars_data" VALUES ("2");
INSERT INTO "cars_data" VALUES ("3");
INSERT INTO "cars_data" VALUES ("4");
INSERT INTO "cars_data" VALUES ("5");
INSERT INTO "cars_data" VALUES ("6");
INSERT INTO "cars_data" VALUES ("7");
INSERT INTO "cars_data" VALUES ("8");
INSERT INTO "cars_data" VALUES ("9");
INSERT INTO "cars_data" VALUES ("10");
INSERT INTO "cars_data" VALUES ("11");
INSERT INTO "cars_data" VALUES ("12");
INSERT INTO "cars_data" VALUES ("13");
INSERT INTO "cars_data" VALUES ("14");
INSERT INTO "cars_data" VALUES ("15");
INSERT INTO "cars_data" VALUES ("16");
INSERT INTO "cars_data" VALUES ("17");
INSERT INTO "cars_data" VALUES ("18");
INSERT INTO "cars_data" VALUES ("19");
INSERT INTO "cars_data" VALUES ("20");
INSERT INTO "cars_data" VALUES ("21");
INSERT INTO "cars_data" VALUES ("22");
INSERT INTO "cars_data" VALUES ("23");
INSERT INTO "cars_data" VALUES ("24");
INSERT INTO "cars_data" VALUES ("25");
INSERT INTO "cars_data" VALUES ("26");
INSERT INTO "cars_data" VALUES ("27");