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,
"Maker" 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,
"MPG" TEXT,
"Cylinders" INT,
"Edispl" FLOAT,
"Horsepower" TEXT,
"Weight" INT,
"Accelerate" FLOAT,
"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,
"Model" TEXT UNIQUE,
PRIMARY KEY ("ModelId")
);





INSERT INTO "car_makers" VALUES ("1", "Toyota");
INSERT INTO "car_makers" VALUES ("2", "Ford");
INSERT INTO "car_makers" VALUES ("3", "Honda");
INSERT INTO "car_makers" VALUES ("4", "Chevrolet");
INSERT INTO "car_makers" VALUES ("5", "BMW");
INSERT INTO "model_list" VALUES ("1", "Corolla");
INSERT INTO "model_list" VALUES ("2", "Mustang");
INSERT INTO "model_list" VALUES ("3", "Civic");
INSERT INTO "model_list" VALUES ("4", "Camaro");
INSERT INTO "model_list" VALUES ("5", "3 Series");
INSERT INTO "car_names" VALUES ("1", "Corolla");
INSERT INTO "car_names" VALUES ("2", "Mustang");
INSERT INTO "car_names" VALUES ("3", "Civic");
INSERT INTO "car_names" VALUES ("4", "Camaro");
INSERT INTO "car_names" VALUES ("5", "3 Series");
INSERT INTO "cars_data" VALUES ("1", "30", "4", "1.8", "132", "2800", "8.5", "2010");
INSERT INTO "cars_data" VALUES ("1", "32", "4", "1.8", "140", "2750", "8.3", "2011");
INSERT INTO "cars_data" VALUES ("1", "28", "4", "2.0", "150", "2900", "8.7", "2012");
INSERT INTO "cars_data" VALUES ("2", "20", "8", "5.0", "300", "3700", "6.5", "2010");
INSERT INTO "cars_data" VALUES ("2", "18", "8", "5.0", "320", "3800", "6.3", "2011");
INSERT INTO "cars_data" VALUES ("2", "22", "6", "3.7", "280", "3500", "7.0", "2012");
INSERT INTO "cars_data" VALUES ("3", "35", "4", "1.5", "130", "2600", "9.0", "2010");
INSERT INTO "cars_data" VALUES ("3", "33", "4", "1.5", "125", "2550", "9.2", "2011");
INSERT INTO "cars_data" VALUES ("4", "25", "6", "3.6", "280", "3400", "7.5", "2010");
INSERT INTO "cars_data" VALUES ("4", "24", "6", "3.6", "290", "3450", "7.4", "2011");
INSERT INTO "cars_data" VALUES ("5", "27", "6", "3.0", "255", "3300", "7.8", "2010");
INSERT INTO "cars_data" VALUES ("5", "26", "6", "3.0", "260", "3350", "7.7", "2011");
INSERT INTO "cars_data" VALUES ("5", "28", "6", "3.0", "270", "3250", "7.6", "2012");
INSERT INTO "cars_data" VALUES ("5", "29", "6", "3.0", "275", "3200", "7.5", "2013");
INSERT INTO "countries" VALUES ("1", "Japan");
INSERT INTO "countries" VALUES ("2", "USA");
INSERT INTO "countries" VALUES ("3", "Germany");