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,
"Country" 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,
"Cylinders" INT,
"Edispl" FLOAT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Id") REFERENCES "car_names"("MakeId")
);

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", "volvo", "Volvo Cars", "Sweden");
INSERT INTO "car_makers" VALUES ("2", "ford", "Ford Motor Company", "USA");
INSERT INTO "car_makers" VALUES ("3", "honda", "Honda Motor Co.", "Japan");
INSERT INTO "car_makers" VALUES ("4", "bmw", "Bayerische Motoren Werke AG", "Germany");
INSERT INTO "car_makers" VALUES ("5", "audi", "Audi AG", "Germany");
INSERT INTO "car_makers" VALUES ("6", "toyota", "Toyota Motor Corporation", "Japan");
INSERT INTO "model_list" VALUES ("101", "1", "S60");
INSERT INTO "model_list" VALUES ("102", "1", "XC90");
INSERT INTO "model_list" VALUES ("103", "1", "V40");
INSERT INTO "model_list" VALUES ("201", "2", "Focus");
INSERT INTO "model_list" VALUES ("202", "2", "Mustang");
INSERT INTO "model_list" VALUES ("301", "3", "Civic");
INSERT INTO "model_list" VALUES ("401", "4", "3 Series");
INSERT INTO "model_list" VALUES ("501", "5", "A4");
INSERT INTO "model_list" VALUES ("601", "6", "Camry");
INSERT INTO "model_list" VALUES ("104", "1", "S90");
INSERT INTO "model_list" VALUES ("105", "1", "XC60");
INSERT INTO "car_names" VALUES ("1", "S60", "Volvo");
INSERT INTO "car_names" VALUES ("2", "XC90", "Volvo");
INSERT INTO "car_names" VALUES ("3", "Focus", "Ford");
INSERT INTO "car_names" VALUES ("4", "Civic", "Honda");
INSERT INTO "car_names" VALUES ("5", "3 Series", "BMW");
INSERT INTO "car_names" VALUES ("6", "A4", "Audi");
INSERT INTO "car_names" VALUES ("7", "V40", "Volvo");
INSERT INTO "car_names" VALUES ("8", "Mustang", "Ford");
INSERT INTO "car_names" VALUES ("9", "Camry", "Toyota");
INSERT INTO "car_names" VALUES ("10", "S90", "Volvo");
INSERT INTO "car_names" VALUES ("11", "XC60", "Volvo");
INSERT INTO "cars_data" VALUES ("1", "4", "2.0");
INSERT INTO "cars_data" VALUES ("2", "6", "2.5");
INSERT INTO "cars_data" VALUES ("3", "4", "1.8");
INSERT INTO "cars_data" VALUES ("4", "4", "1.5");
INSERT INTO "cars_data" VALUES ("5", "6", "3.0");
INSERT INTO "cars_data" VALUES ("6", "4", "2.0");
INSERT INTO "cars_data" VALUES ("7", "4", "1.6");
INSERT INTO "cars_data" VALUES ("8", "8", "5.0");
INSERT INTO "cars_data" VALUES ("9", "4", "2.5");
INSERT INTO "cars_data" VALUES ("10", "4", "2.0");
INSERT INTO "cars_data" VALUES ("11", "5", "2.4");