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,
PRIMARY KEY ("Id")
);

CREATE TABLE "car_names" (
"MakeId" INT,
"Model" TEXT,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY ("Model") REFERENCES "model_list"("Model")
);

CREATE TABLE "model_list" (
"ModelId" INT,
"Maker" INT,
"Model" TEXT UNIQUE,
PRIMARY KEY ("ModelId"),
FOREIGN KEY ("Maker") REFERENCES "car_makers"("Id")
);





INSERT INTO "car_makers" VALUES ("1", "AMC", "American Motor Company");
INSERT INTO "car_makers" VALUES ("2", "Ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("3", "GM", "General Motors");
INSERT INTO "car_makers" VALUES ("4", "Toyota", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("5", "BMW", "Bayerische Motoren Werke AG");
INSERT INTO "model_list" VALUES ("101", "1", "Gremlin");
INSERT INTO "model_list" VALUES ("102", "1", "Pacer");
INSERT INTO "model_list" VALUES ("103", "1", "Javelin");
INSERT INTO "model_list" VALUES ("104", "2", "Mustang");
INSERT INTO "model_list" VALUES ("105", "2", "F-150");
INSERT INTO "model_list" VALUES ("106", "3", "Impala");
INSERT INTO "model_list" VALUES ("107", "3", "Camaro");
INSERT INTO "model_list" VALUES ("108", "4", "Corolla");
INSERT INTO "model_list" VALUES ("109", "4", "Camry");
INSERT INTO "model_list" VALUES ("110", "5", "X5");
INSERT INTO "model_list" VALUES ("111", "5", "M3");
INSERT INTO "model_list" VALUES ("112", "1", "Hornet");
INSERT INTO "model_list" VALUES ("113", "1", "Concord");
INSERT INTO "car_names" VALUES ("1", "Gremlin", "AMC");
INSERT INTO "car_names" VALUES ("2", "Pacer", "AMC");
INSERT INTO "car_names" VALUES ("3", "Javelin", "AMC");
INSERT INTO "car_names" VALUES ("4", "Mustang", "Ford");
INSERT INTO "car_names" VALUES ("5", "F-150", "Ford");
INSERT INTO "car_names" VALUES ("6", "Impala", "GM");
INSERT INTO "car_names" VALUES ("7", "Camaro", "GM");
INSERT INTO "car_names" VALUES ("8", "Corolla", "Toyota");
INSERT INTO "car_names" VALUES ("9", "Camry", "Toyota");
INSERT INTO "car_names" VALUES ("10", "X5", "BMW");
INSERT INTO "car_names" VALUES ("11", "M3", "BMW");
INSERT INTO "car_names" VALUES ("12", "Hornet", "AMC");
INSERT INTO "car_names" VALUES ("13", "Concord", "AMC");