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,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Country") REFERENCES "countries"("CountryId")
);

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,
"Cylinders" INT,
"Horsepower" TEXT,
"Accelerate" FLOAT,
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 "countries" VALUES ("1", "Sweden");
INSERT INTO "countries" VALUES ("2", "Japan");
INSERT INTO "countries" VALUES ("3", "Germany");
INSERT INTO "countries" VALUES ("4", "USA");
INSERT INTO "countries" VALUES ("5", "South Korea");
INSERT INTO "car_makers" VALUES ("10", "volvo", "1");
INSERT INTO "car_makers" VALUES ("20", "Toyota", "2");
INSERT INTO "car_makers" VALUES ("30", "BMW", "3");
INSERT INTO "car_makers" VALUES ("40", "Ford", "4");
INSERT INTO "car_makers" VALUES ("50", "Hyundai", "5");
INSERT INTO "model_list" VALUES ("100", "10", "XC90");
INSERT INTO "model_list" VALUES ("101", "10", "S60");
INSERT INTO "model_list" VALUES ("102", "10", "V60");
INSERT INTO "model_list" VALUES ("103", "20", "Corolla");
INSERT INTO "model_list" VALUES ("104", "20", "Camry");
INSERT INTO "model_list" VALUES ("105", "30", "X5");
INSERT INTO "model_list" VALUES ("106", "30", "M3");
INSERT INTO "model_list" VALUES ("107", "40", "Mustang");
INSERT INTO "model_list" VALUES ("108", "50", "Elantra");
INSERT INTO "car_names" VALUES ("100", "XC90");
INSERT INTO "car_names" VALUES ("101", "S60");
INSERT INTO "car_names" VALUES ("102", "V60");
INSERT INTO "car_names" VALUES ("103", "Corolla");
INSERT INTO "car_names" VALUES ("104", "Camry");
INSERT INTO "car_names" VALUES ("105", "X5");
INSERT INTO "car_names" VALUES ("106", "M3");
INSERT INTO "car_names" VALUES ("107", "Mustang");
INSERT INTO "car_names" VALUES ("108", "Elantra");
INSERT INTO "cars_data" VALUES ("100", "6", "316", "7.5");
INSERT INTO "cars_data" VALUES ("101", "4", "250", "6.8");
INSERT INTO "cars_data" VALUES ("102", "4", "240", "7.0");
INSERT INTO "cars_data" VALUES ("103", "4", "132", "9.0");
INSERT INTO "cars_data" VALUES ("104", "4", "203", "8.2");
INSERT INTO "cars_data" VALUES ("105", "6", "335", "6.0");
INSERT INTO "cars_data" VALUES ("106", "6", "425", "4.1");
INSERT INTO "cars_data" VALUES ("107", "8", "450", "4.3");
INSERT INTO "cars_data" VALUES ("108", "4", "147", "8.5");
INSERT INTO "cars_data" VALUES ("109", "4", "200", "6.8");
INSERT INTO "car_names" VALUES ("109", "S60 Polestar");
INSERT INTO "model_list" VALUES ("109", "10", "S60 Polestar");