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", "AMC", "American Motor Company", "1");
INSERT INTO "car_makers" VALUES ("2", "Ford", "Ford Motor Company", "1");
INSERT INTO "car_makers" VALUES ("3", "BMW", "Bayerische Motoren Werke AG", "2");
INSERT INTO "car_makers" VALUES ("4", "Toyota", "Toyota Motor Corporation", "3");
INSERT INTO "car_makers" VALUES ("5", "Fiat", "Fiat S.p.A.", "4");
INSERT INTO "car_makers" VALUES ("6", "Renault", "Groupe Renault", "5");
INSERT INTO "car_makers" VALUES ("7", "Chrysler", "Chrysler LLC", "1");
INSERT INTO "model_list" VALUES ("101", "1", "Gremlin");
INSERT INTO "model_list" VALUES ("102", "1", "Hornet");
INSERT INTO "model_list" VALUES ("103", "1", "Javelin");
INSERT INTO "model_list" VALUES ("104", "1", "Pacer");
INSERT INTO "model_list" VALUES ("105", "2", "Mustang");
INSERT INTO "model_list" VALUES ("106", "2", "F-150");
INSERT INTO "model_list" VALUES ("107", "3", "3 Series");
INSERT INTO "model_list" VALUES ("108", "4", "Camry");
INSERT INTO "model_list" VALUES ("109", "5", "500");
INSERT INTO "model_list" VALUES ("110", "6", "Clio");
INSERT INTO "model_list" VALUES ("111", "1", "Concord");
INSERT INTO "model_list" VALUES ("112", "7", "Charger");
INSERT INTO "car_names" VALUES ("101", "Gremlin");
INSERT INTO "car_names" VALUES ("102", "Hornet");
INSERT INTO "car_names" VALUES ("103", "Javelin");
INSERT INTO "car_names" VALUES ("104", "Pacer");
INSERT INTO "car_names" VALUES ("105", "Mustang");
INSERT INTO "car_names" VALUES ("106", "F-150");
INSERT INTO "car_names" VALUES ("107", "3 Series");
INSERT INTO "car_names" VALUES ("108", "Camry");
INSERT INTO "car_names" VALUES ("109", "500");
INSERT INTO "car_names" VALUES ("110", "Clio");
INSERT INTO "car_names" VALUES ("111", "Concord");
INSERT INTO "car_names" VALUES ("112", "Charger");