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

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 "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", "BMW", "Bayerische Motoren Werke AG", "2");
INSERT INTO "car_makers" VALUES ("3", "Toyota", "Toyota Motor Corporation", "3");
INSERT INTO "car_makers" VALUES ("4", "Ferrari", "Ferrari S.p.A.", "4");
INSERT INTO "car_makers" VALUES ("5", "Peugeot", "Peugeot S.A.", "5");
INSERT INTO "car_makers" VALUES ("6", "Honda", "Honda Motor Co., Ltd.", "3");
INSERT INTO "car_makers" VALUES ("7", "Mercedes-Benz", "Mercedes-Benz AG", "2");
INSERT INTO "car_makers" VALUES ("8", "Nissan", "Nissan Motor Corporation", "3");
INSERT INTO "car_makers" VALUES ("9", "Audi", "Audi AG", "2");
INSERT INTO "car_makers" VALUES ("10", "Chevrolet", "Chevrolet", "1");
INSERT INTO "model_list" VALUES ("1", "1", "F-150");
INSERT INTO "model_list" VALUES ("2", "1", "Mustang");
INSERT INTO "model_list" VALUES ("3", "1", "Explorer");
INSERT INTO "model_list" VALUES ("4", "1", "Focus");
INSERT INTO "model_list" VALUES ("5", "2", "3 Series");
INSERT INTO "model_list" VALUES ("6", "2", "X5");
INSERT INTO "model_list" VALUES ("7", "2", "M3");
INSERT INTO "model_list" VALUES ("8", "3", "Camry");
INSERT INTO "model_list" VALUES ("9", "3", "Corolla");
INSERT INTO "model_list" VALUES ("10", "3", "RAV4");
INSERT INTO "model_list" VALUES ("11", "3", "Highlander");
INSERT INTO "model_list" VALUES ("12", "4", "488 GTB");
INSERT INTO "model_list" VALUES ("13", "4", "Portofino");
INSERT INTO "model_list" VALUES ("14", "5", "208");
INSERT INTO "model_list" VALUES ("15", "5", "3008");
INSERT INTO "model_list" VALUES ("16", "6", "Civic");
INSERT INTO "model_list" VALUES ("17", "6", "CR-V");
INSERT INTO "model_list" VALUES ("18", "6", "Accord");
INSERT INTO "model_list" VALUES ("19", "6", "Pilot");
INSERT INTO "model_list" VALUES ("20", "7", "C-Class");
INSERT INTO "model_list" VALUES ("21", "7", "E-Class");
INSERT INTO "model_list" VALUES ("22", "7", "GLC");
INSERT INTO "model_list" VALUES ("23", "8", "Altima");
INSERT INTO "model_list" VALUES ("24", "8", "Rogue");
INSERT INTO "model_list" VALUES ("25", "9", "A4");
INSERT INTO "model_list" VALUES ("26", "9", "Q5");
INSERT INTO "model_list" VALUES ("27", "10", "Silverado");
INSERT INTO "model_list" VALUES ("28", "10", "Malibu");
INSERT INTO "model_list" VALUES ("29", "10", "Equinox");
INSERT INTO "model_list" VALUES ("30", "10", "Tahoe");
INSERT INTO "car_names" VALUES ("1", "F-150");
INSERT INTO "car_names" VALUES ("2", "Mustang");
INSERT INTO "car_names" VALUES ("3", "Explorer");
INSERT INTO "car_names" VALUES ("4", "Focus");
INSERT INTO "car_names" VALUES ("5", "3 Series");
INSERT INTO "car_names" VALUES ("6", "X5");
INSERT INTO "car_names" VALUES ("7", "M3");
INSERT INTO "car_names" VALUES ("8", "Camry");
INSERT INTO "car_names" VALUES ("9", "Corolla");
INSERT INTO "car_names" VALUES ("10", "RAV4");
INSERT INTO "car_names" VALUES ("11", "Highlander");
INSERT INTO "car_names" VALUES ("12", "488 GTB");
INSERT INTO "car_names" VALUES ("13", "Portofino");
INSERT INTO "car_names" VALUES ("14", "208");
INSERT INTO "car_names" VALUES ("15", "3008");
INSERT INTO "car_names" VALUES ("16", "Civic");
INSERT INTO "car_names" VALUES ("17", "CR-V");
INSERT INTO "car_names" VALUES ("18", "Accord");
INSERT INTO "car_names" VALUES ("19", "Pilot");
INSERT INTO "car_names" VALUES ("20", "C-Class");
INSERT INTO "car_names" VALUES ("21", "E-Class");
INSERT INTO "car_names" VALUES ("22", "GLC");
INSERT INTO "car_names" VALUES ("23", "Altima");
INSERT INTO "car_names" VALUES ("24", "Rogue");
INSERT INTO "car_names" VALUES ("25", "A4");
INSERT INTO "car_names" VALUES ("26", "Q5");
INSERT INTO "car_names" VALUES ("27", "Silverado");
INSERT INTO "car_names" VALUES ("28", "Malibu");
INSERT INTO "car_names" VALUES ("29", "Equinox");
INSERT INTO "car_names" VALUES ("30", "Tahoe");