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

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

CREATE TABLE "model_list" (
"ModelId" INT,
"Model" TEXT UNIQUE,
PRIMARY KEY ("ModelId")
);





INSERT INTO "car_makers" VALUES ("1", "volvo");
INSERT INTO "car_makers" VALUES ("2", "ford");
INSERT INTO "car_makers" VALUES ("3", "honda");
INSERT INTO "car_makers" VALUES ("4", "toyota");
INSERT INTO "car_makers" VALUES ("5", "bmw");
INSERT INTO "car_makers" VALUES ("6", "mercedes");
INSERT INTO "model_list" VALUES ("1", "volvo 240");
INSERT INTO "model_list" VALUES ("2", "volvo 740");
INSERT INTO "model_list" VALUES ("3", "ford focus");
INSERT INTO "model_list" VALUES ("4", "honda civic");
INSERT INTO "model_list" VALUES ("5", "toyota camry");
INSERT INTO "model_list" VALUES ("6", "bmw x5");
INSERT INTO "model_list" VALUES ("7", "mercedes c-class");
INSERT INTO "model_list" VALUES ("8", "volvo s60");
INSERT INTO "model_list" VALUES ("9", "volvo xc90");
INSERT INTO "car_names" VALUES ("1", "volvo 240", "volvo");
INSERT INTO "car_names" VALUES ("2", "volvo 740", "volvo");
INSERT INTO "car_names" VALUES ("3", "ford focus", "ford");
INSERT INTO "car_names" VALUES ("4", "honda civic", "honda");
INSERT INTO "car_names" VALUES ("5", "toyota camry", "toyota");
INSERT INTO "car_names" VALUES ("6", "bmw x5", "bmw");
INSERT INTO "car_names" VALUES ("7", "mercedes c-class", "mercedes");
INSERT INTO "car_names" VALUES ("8", "volvo s60", "volvo");
INSERT INTO "car_names" VALUES ("9", "volvo xc90", "volvo");
INSERT INTO "car_names" VALUES ("10", "volvo 240", "volvo");
INSERT INTO "car_names" VALUES ("11", "volvo 740", "volvo");
INSERT INTO "cars_data" VALUES ("1", "2.1", "100");
INSERT INTO "cars_data" VALUES ("2", "2.3", "115");
INSERT INTO "cars_data" VALUES ("3", "1.6", "110");
INSERT INTO "cars_data" VALUES ("4", "1.8", "140");
INSERT INTO "cars_data" VALUES ("5", "2.5", "180");
INSERT INTO "cars_data" VALUES ("6", "3.0", "250");
INSERT INTO "cars_data" VALUES ("7", "2.0", "190");
INSERT INTO "cars_data" VALUES ("8", "2.4", "170");
INSERT INTO "cars_data" VALUES ("9", "2.5", "200");
INSERT INTO "cars_data" VALUES ("10", "0.0", "90");
INSERT INTO "cars_data" VALUES ("11", "NULL", "120");