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 Motor Corporation");
INSERT INTO "car_makers" VALUES ("7", "volkswagen", "Volkswagen");
INSERT INTO "car_makers" VALUES ("8", "buick", "Buick");
INSERT INTO "car_makers" VALUES ("9", "pontiac", "Pontiac");
INSERT INTO "car_makers" VALUES ("10", "mercedes-benz", "Mercedes-Benz");
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", "2", "chevrolet impala");
INSERT INTO "model_list" VALUES ("5", "3", "plymouth fury iii");
INSERT INTO "model_list" VALUES ("6", "3", "plymouth satellite");
INSERT INTO "model_list" VALUES ("7", "4", "amc rebel sst");
INSERT INTO "model_list" VALUES ("8", "5", "dodge challenger se");
INSERT INTO "model_list" VALUES ("9", "6", "toyota corona mark ii");
INSERT INTO "model_list" VALUES ("10", "7", "volkswagen 1131 deluxe sedan");
INSERT INTO "model_list" VALUES ("11", "8", "buick skylark 320");
INSERT INTO "model_list" VALUES ("12", "9", "pontiac grand prix");
INSERT INTO "model_list" VALUES ("13", "1", "ford pinto");
INSERT INTO "model_list" VALUES ("14", "2", "chevrolet vega 2300");
INSERT INTO "model_list" VALUES ("15", "10", "mercedes-benz 220d");
INSERT INTO "model_list" VALUES ("16", "1", "ford country squire sw");
INSERT INTO "model_list" VALUES ("17", "2", "chevrolet caprice classic");
INSERT INTO "model_list" VALUES ("18", "3", "plymouth custom suburb");
INSERT INTO "model_list" VALUES ("19", "4", "amc gremlin");
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", "chevrolet impala");
INSERT INTO "car_names" VALUES ("5", "plymouth fury iii");
INSERT INTO "car_names" VALUES ("6", "plymouth satellite");
INSERT INTO "car_names" VALUES ("7", "amc rebel sst");
INSERT INTO "car_names" VALUES ("8", "dodge challenger se");
INSERT INTO "car_names" VALUES ("9", "toyota corona mark ii");
INSERT INTO "car_names" VALUES ("10", "volkswagen 1131 deluxe sedan");
INSERT INTO "car_names" VALUES ("11", "buick skylark 320");
INSERT INTO "car_names" VALUES ("12", "pontiac grand prix");
INSERT INTO "car_names" VALUES ("13", "ford pinto");
INSERT INTO "car_names" VALUES ("14", "chevrolet vega 2300");
INSERT INTO "car_names" VALUES ("15", "mercedes-benz 220d");
INSERT INTO "car_names" VALUES ("16", "ford country squire sw");
INSERT INTO "car_names" VALUES ("17", "chevrolet caprice classic");
INSERT INTO "car_names" VALUES ("18", "plymouth custom suburb");
INSERT INTO "car_names" VALUES ("19", "amc gremlin");
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", "14.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("7", "14.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("8", "14.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("9", "24.0", "4", "1970");
INSERT INTO "cars_data" VALUES ("10", "25.0", "4", "1970");
INSERT INTO "cars_data" VALUES ("11", "15.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("12", "16.0", "8", "1970");
INSERT INTO "cars_data" VALUES ("13", "25.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("14", "28.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("15", "25.0", "4", "1971");
INSERT INTO "cars_data" VALUES ("16", "13.0", "8", "1971");
INSERT INTO "cars_data" VALUES ("17", "13.0", "8", "1971");
INSERT INTO "cars_data" VALUES ("18", "14.0", "8", "1971");
INSERT INTO "cars_data" VALUES ("19", "20.0", "6", "1971");
INSERT INTO "cars_data" VALUES ("20", "18.0", "6", "1971");