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

CREATE TABLE "cars_data" (
"Id" INT,
"MPG" TEXT,
"Horsepower" TEXT,
"Weight" INT,
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", "AMC", "American Motors Corporation", "USA");
INSERT INTO "car_makers" VALUES ("2", "Ford", "Ford Motor Company", "USA");
INSERT INTO "car_makers" VALUES ("3", "GM", "General Motors", "USA");
INSERT INTO "car_makers" VALUES ("4", "Toyota", "Toyota Motor Corporation", "Japan");
INSERT INTO "car_makers" VALUES ("5", "Honda", "Honda Motor Co.", "Japan");
INSERT INTO "car_makers" VALUES ("6", "VW", "Volkswagen", "Germany");
INSERT INTO "car_makers" VALUES ("7", "BMW", "Bayerische Motoren Werke AG", "Germany");
INSERT INTO "car_makers" VALUES ("8", "Fiat", "Fiat S.p.A.", "Italy");
INSERT INTO "car_makers" VALUES ("9", "Nissan", "Nissan Motor Corporation", "Japan");
INSERT INTO "car_makers" VALUES ("10", "Volvo", "Volvo Cars", "Sweden");
INSERT INTO "model_list" VALUES ("1", "1", "Gremlin");
INSERT INTO "model_list" VALUES ("2", "1", "Hornet");
INSERT INTO "model_list" VALUES ("3", "2", "Pinto");
INSERT INTO "model_list" VALUES ("4", "2", "Maverick");
INSERT INTO "model_list" VALUES ("5", "3", "Vega");
INSERT INTO "model_list" VALUES ("6", "3", "Nova");
INSERT INTO "model_list" VALUES ("7", "4", "Corolla");
INSERT INTO "model_list" VALUES ("8", "4", "Celica");
INSERT INTO "model_list" VALUES ("9", "5", "Civic");
INSERT INTO "model_list" VALUES ("10", "6", "Beetle");
INSERT INTO "model_list" VALUES ("11", "7", "320i");
INSERT INTO "model_list" VALUES ("12", "8", "124 Spider");
INSERT INTO "model_list" VALUES ("13", "9", "Datsun 510");
INSERT INTO "model_list" VALUES ("14", "10", "240GL");
INSERT INTO "model_list" VALUES ("15", "2", "Mustang");
INSERT INTO "model_list" VALUES ("16", "3", "Camaro");
INSERT INTO "model_list" VALUES ("17", "4", "Camry");
INSERT INTO "model_list" VALUES ("18", "5", "Accord");
INSERT INTO "model_list" VALUES ("19", "6", "Golf");
INSERT INTO "model_list" VALUES ("20", "1", "Pacer");
INSERT INTO "car_names" VALUES ("1", "Gremlin");
INSERT INTO "car_names" VALUES ("2", "Hornet");
INSERT INTO "car_names" VALUES ("3", "Pinto");
INSERT INTO "car_names" VALUES ("4", "Maverick");
INSERT INTO "car_names" VALUES ("5", "Vega");
INSERT INTO "car_names" VALUES ("6", "Nova");
INSERT INTO "car_names" VALUES ("7", "Corolla");
INSERT INTO "car_names" VALUES ("8", "Celica");
INSERT INTO "car_names" VALUES ("9", "Civic");
INSERT INTO "car_names" VALUES ("10", "Beetle");
INSERT INTO "car_names" VALUES ("11", "320i");
INSERT INTO "car_names" VALUES ("12", "124 Spider");
INSERT INTO "car_names" VALUES ("13", "Datsun 510");
INSERT INTO "car_names" VALUES ("14", "240GL");
INSERT INTO "car_names" VALUES ("15", "Mustang");
INSERT INTO "car_names" VALUES ("16", "Camaro");
INSERT INTO "car_names" VALUES ("17", "Camry");
INSERT INTO "car_names" VALUES ("18", "Accord");
INSERT INTO "car_names" VALUES ("19", "Golf");
INSERT INTO "car_names" VALUES ("20", "Pacer");
INSERT INTO "cars_data" VALUES ("1", "18.0", "130", "3500");
INSERT INTO "cars_data" VALUES ("2", "20.0", "90", "2900");
INSERT INTO "cars_data" VALUES ("3", "21.0", "75", "2600");
INSERT INTO "cars_data" VALUES ("4", "19.0", "88", "3000");
INSERT INTO "cars_data" VALUES ("5", "22.0", "80", "2500");
INSERT INTO "cars_data" VALUES ("6", "17.0", "110", "3800");
INSERT INTO "cars_data" VALUES ("7", "30.0", "70", "2100");
INSERT INTO "cars_data" VALUES ("8", "28.0", "95", "2300");
INSERT INTO "cars_data" VALUES ("9", "33.0", "60", "1900");
INSERT INTO "cars_data" VALUES ("10", "25.0", "70", "2200");
INSERT INTO "cars_data" VALUES ("11", "26.0", "100", "2800");
INSERT INTO "cars_data" VALUES ("12", "27.0", "85", "2000");
INSERT INTO "cars_data" VALUES ("13", "31.0", "78", "2400");
INSERT INTO "cars_data" VALUES ("14", "24.0", "105", "3200");
INSERT INTO "cars_data" VALUES ("15", "16.0", "140", "3900");
INSERT INTO "cars_data" VALUES ("16", "15.0", "150", "4000");
INSERT INTO "cars_data" VALUES ("17", "29.0", "90", "2700");
INSERT INTO "cars_data" VALUES ("18", "32.0", "75", "2200");
INSERT INTO "cars_data" VALUES ("19", "34.0", "65", "2000");
INSERT INTO "cars_data" VALUES ("20", "23.0", "90", "3600");