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

CREATE TABLE "cars_data" (
"Id" INT,
"MPG" TEXT,
"Cylinders" INT,
"Year" 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", "ford", "Ford Motor Company");
INSERT INTO "car_makers" VALUES ("2", "chevrolet", "Chevrolet");
INSERT INTO "car_makers" VALUES ("3", "plymouth", "Plymouth");
INSERT INTO "car_makers" VALUES ("4", "amc", "American Motors Corporation");
INSERT INTO "car_makers" VALUES ("5", "dodge", "Dodge");
INSERT INTO "car_makers" VALUES ("6", "toyota", "Toyota");
INSERT INTO "car_makers" VALUES ("7", "volkswagen", "Volkswagen");
INSERT INTO "car_makers" VALUES ("8", "mercedes-benz", "Mercedes-Benz");
INSERT INTO "car_makers" VALUES ("9", "bmw", "BMW");
INSERT INTO "car_makers" VALUES ("10", "honda", "Honda");
INSERT INTO "model_list" VALUES ("1", "1", "ford torino");
INSERT INTO "model_list" VALUES ("2", "1", "ford galaxie 500");
INSERT INTO "model_list" VALUES ("3", "2", "chevrolet chevelle malibu");
INSERT INTO "model_list" VALUES ("4", "3", "plymouth satellite");
INSERT INTO "model_list" VALUES ("5", "4", "amc rebel sst");
INSERT INTO "model_list" VALUES ("6", "5", "dodge challenger se");
INSERT INTO "model_list" VALUES ("7", "6", "toyota corolla");
INSERT INTO "model_list" VALUES ("8", "7", "volkswagen type 3");
INSERT INTO "model_list" VALUES ("9", "8", "mercedes-benz 280s");
INSERT INTO "model_list" VALUES ("10", "9", "bmw 2002");
INSERT INTO "model_list" VALUES ("11", "10", "honda civic");
INSERT INTO "model_list" VALUES ("12", "1", "ford pinto");
INSERT INTO "model_list" VALUES ("13", "2", "chevrolet vega");
INSERT INTO "model_list" VALUES ("14", "3", "plymouth duster");
INSERT INTO "model_list" VALUES ("15", "4", "amc gremlin");
INSERT INTO "model_list" VALUES ("16", "1", "ford country squire sw");
INSERT INTO "model_list" VALUES ("17", "2", "chevrolet impala");
INSERT INTO "model_list" VALUES ("18", "3", "plymouth fury iii");
INSERT INTO "model_list" VALUES ("19", "4", "amc hornet sportabout sw");
INSERT INTO "model_list" VALUES ("20", "5", "dodge dart custom");
INSERT INTO "car_names" VALUES ("1", "ford torino");
INSERT INTO "car_names" VALUES ("2", "ford galaxie 500");
INSERT INTO "car_names" VALUES ("3", "chevrolet chevelle malibu");
INSERT INTO "car_names" VALUES ("4", "plymouth satellite");
INSERT INTO "car_names" VALUES ("5", "amc rebel sst");
INSERT INTO "car_names" VALUES ("6", "dodge challenger se");
INSERT INTO "car_names" VALUES ("7", "toyota corolla");
INSERT INTO "car_names" VALUES ("8", "volkswagen type 3");
INSERT INTO "car_names" VALUES ("9", "mercedes-benz 280s");
INSERT INTO "car_names" VALUES ("10", "bmw 2002");
INSERT INTO "car_names" VALUES ("11", "honda civic");
INSERT INTO "car_names" VALUES ("12", "ford pinto");
INSERT INTO "car_names" VALUES ("13", "chevrolet vega");
INSERT INTO "car_names" VALUES ("14", "plymouth duster");
INSERT INTO "car_names" VALUES ("15", "amc gremlin");
INSERT INTO "car_names" VALUES ("16", "ford country squire sw");
INSERT INTO "car_names" VALUES ("17", "chevrolet impala");
INSERT INTO "car_names" VALUES ("18", "plymouth fury iii");
INSERT INTO "car_names" VALUES ("19", "amc hornet sportabout sw");
INSERT INTO "car_names" VALUES ("20", "dodge dart custom");
INSERT INTO "cars_data" VALUES ("1", "18.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("2", "15.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("3", "18.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("4", "16.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("5", "17.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("6", "15.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("7", "24.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("8", "27.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("9", "25.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("10", "26.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("11", "30.0", "4", "1972");
INSERT INTO "cars_data" VALUES ("12", "21.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("13", "22.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("14", "23.0", "6", "1972");
INSERT INTO "cars_data" VALUES ("15", "20.0", "6", "1972");
INSERT INTO "cars_data" VALUES ("16", "14.0", "8", "1972");
INSERT INTO "cars_data" VALUES ("17", "13.0", "8", "1972");
INSERT INTO "cars_data" VALUES ("18", "15.0", "8", "1972");
INSERT INTO "cars_data" VALUES ("19", "16.0", "6", "1972");
INSERT INTO "cars_data" VALUES ("20", "18.0", "6", "1972");