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

CREATE TABLE "cars_data" (
"Id" INT,
"Horsepower" TEXT,
"Year" INT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Id") REFERENCES "car_names"("MakeId")
);

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 "car_makers" VALUES ("1", "ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("2", "chevy", "Chevrolet Division");
INSERT INTO "car_makers" VALUES ("3", "toyota", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("4", "bmw", "Bayerische Motoren Werke AG");
INSERT INTO "car_makers" VALUES ("5", "honda", "Honda Motor Co., Ltd.");
INSERT INTO "car_makers" VALUES ("6", "fiat", "Fabbrica Italiana Automobili Torino");
INSERT INTO "model_list" VALUES ("101", "1", "Mustang");
INSERT INTO "model_list" VALUES ("102", "1", "F-150");
INSERT INTO "model_list" VALUES ("103", "2", "Camaro");
INSERT INTO "model_list" VALUES ("104", "2", "Impala");
INSERT INTO "model_list" VALUES ("105", "3", "Corolla");
INSERT INTO "model_list" VALUES ("106", "3", "Celica");
INSERT INTO "model_list" VALUES ("107", "4", "320i");
INSERT INTO "model_list" VALUES ("108", "4", "M3");
INSERT INTO "model_list" VALUES ("109", "5", "Civic");
INSERT INTO "model_list" VALUES ("110", "5", "Accord");
INSERT INTO "model_list" VALUES ("111", "6", "500");
INSERT INTO "model_list" VALUES ("112", "6", "Panda");
INSERT INTO "car_names" VALUES ("1", "Mustang");
INSERT INTO "car_names" VALUES ("2", "Camaro");
INSERT INTO "car_names" VALUES ("3", "Corolla");
INSERT INTO "car_names" VALUES ("4", "320i");
INSERT INTO "car_names" VALUES ("5", "Civic");
INSERT INTO "car_names" VALUES ("6", "500");
INSERT INTO "cars_data" VALUES ("1", "250 HP", "1970");
INSERT INTO "cars_data" VALUES ("2", "300 HP", "1970");
INSERT INTO "cars_data" VALUES ("3", "110 HP", "1969");
INSERT INTO "cars_data" VALUES ("4", "130 HP", "1970");
INSERT INTO "cars_data" VALUES ("5", "100 HP", "1971");
INSERT INTO "cars_data" VALUES ("6", "45 HP", "1970");
INSERT INTO "countries" VALUES ("1", "USA");
INSERT INTO "countries" VALUES ("2", "Japan");
INSERT INTO "countries" VALUES ("3", "Germany");
INSERT INTO "countries" VALUES ("4", "Italy");