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,
"Make" 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 "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");
INSERT INTO "car_makers" VALUES ("2", "toyota", "Toyota Motor Corporation");
INSERT INTO "car_makers" VALUES ("3", "ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("4", "bmw", "Bayerische Motoren Werke AG");
INSERT INTO "car_makers" VALUES ("5", "audi", "Audi AG");
INSERT INTO "model_list" VALUES ("101", "1", "XC90");
INSERT INTO "model_list" VALUES ("102", "1", "S60");
INSERT INTO "model_list" VALUES ("103", "1", "V60");
INSERT INTO "model_list" VALUES ("201", "2", "Corolla");
INSERT INTO "model_list" VALUES ("202", "2", "Camry");
INSERT INTO "model_list" VALUES ("301", "3", "Mustang");
INSERT INTO "model_list" VALUES ("302", "3", "F-150");
INSERT INTO "model_list" VALUES ("401", "4", "X5");
INSERT INTO "model_list" VALUES ("402", "4", "M3");
INSERT INTO "model_list" VALUES ("501", "5", "A4");
INSERT INTO "model_list" VALUES ("502", "5", "Q7");
INSERT INTO "car_names" VALUES ("101", "XC90", "volvo");
INSERT INTO "car_names" VALUES ("102", "S60", "volvo");
INSERT INTO "car_names" VALUES ("103", "V60", "volvo");
INSERT INTO "car_names" VALUES ("201", "Corolla", "toyota");
INSERT INTO "car_names" VALUES ("202", "Camry", "toyota");
INSERT INTO "car_names" VALUES ("301", "Mustang", "ford");
INSERT INTO "car_names" VALUES ("302", "F-150", "ford");
INSERT INTO "car_names" VALUES ("401", "X5", "bmw");
INSERT INTO "car_names" VALUES ("402", "M3", "bmw");
INSERT INTO "car_names" VALUES ("501", "A4", "audi");
INSERT INTO "car_names" VALUES ("502", "Q7", "audi");
INSERT INTO "cars_data" VALUES ("101", "6", "316", "7.2");
INSERT INTO "cars_data" VALUES ("102", "4", "250", "6.5");
INSERT INTO "cars_data" VALUES ("103", "4", "250", "6.5");
INSERT INTO "cars_data" VALUES ("201", "4", "132", "10.5");
INSERT INTO "cars_data" VALUES ("202", "4", "203", "8.2");
INSERT INTO "cars_data" VALUES ("301", "8", "450", "4.3");
INSERT INTO "cars_data" VALUES ("302", "6", "290", "7.1");
INSERT INTO "cars_data" VALUES ("401", "6", "335", "5.3");
INSERT INTO "cars_data" VALUES ("402", "6", "425", "4.1");
INSERT INTO "cars_data" VALUES ("501", "4", "188", "6.5");
INSERT INTO "cars_data" VALUES ("502", "6", "333", "6.8");