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,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY ("Country") REFERENCES "countries"("CountryId")
);

CREATE TABLE "car_names" (
"MakeId" INT,
"Make" TEXT,
PRIMARY KEY ("MakeId")
);

CREATE TABLE "continents" (
"ContId" INT UNIQUE,
"Continent" TEXT,
PRIMARY KEY ("ContId")
);

CREATE TABLE "countries" (
"CountryId" INT UNIQUE,
"CountryName" TEXT,
"Continent" INT,
PRIMARY KEY ("CountryId"),
FOREIGN KEY ("Continent") REFERENCES "continents"("ContId")
);

CREATE TABLE "model_list" (
"ModelId" INT,
"Maker" INT,
PRIMARY KEY ("ModelId"),
FOREIGN KEY ("Maker") REFERENCES "car_makers"("Id")
);





INSERT INTO "continents" VALUES ("1", "Asia");
INSERT INTO "continents" VALUES ("2", "Europe");
INSERT INTO "continents" VALUES ("3", "Africa");
INSERT INTO "continents" VALUES ("4", "North America");
INSERT INTO "continents" VALUES ("5", "South America");
INSERT INTO "continents" VALUES ("6", "Oceania");
INSERT INTO "continents" VALUES ("7", "Antarctica");
INSERT INTO "countries" VALUES ("101", "China", "1");
INSERT INTO "countries" VALUES ("102", "India", "1");
INSERT INTO "countries" VALUES ("103", "Japan", "1");
INSERT INTO "countries" VALUES ("104", "South Korea", "1");
INSERT INTO "countries" VALUES ("201", "Germany", "2");
INSERT INTO "countries" VALUES ("202", "France", "2");
INSERT INTO "countries" VALUES ("203", "Italy", "2");
INSERT INTO "countries" VALUES ("204", "Norway", "2");
INSERT INTO "countries" VALUES ("205", "Iceland", "2");
INSERT INTO "countries" VALUES ("301", "Nigeria", "3");
INSERT INTO "countries" VALUES ("302", "Egypt", "3");
INSERT INTO "countries" VALUES ("303", "South Africa", "3");
INSERT INTO "countries" VALUES ("401", "United States", "4");
INSERT INTO "countries" VALUES ("402", "Canada", "4");
INSERT INTO "countries" VALUES ("403", "Mexico", "4");
INSERT INTO "countries" VALUES ("501", "Brazil", "5");
INSERT INTO "countries" VALUES ("502", "Argentina", "5");
INSERT INTO "countries" VALUES ("601", "Australia", "6");
INSERT INTO "car_makers" VALUES ("1", "101");
INSERT INTO "car_makers" VALUES ("2", "102");
INSERT INTO "car_makers" VALUES ("3", "201");
INSERT INTO "car_makers" VALUES ("4", "202");
INSERT INTO "car_makers" VALUES ("5", "401");
INSERT INTO "car_makers" VALUES ("6", "601");
INSERT INTO "car_names" VALUES ("1", "Toyota");
INSERT INTO "car_names" VALUES ("2", "Tata");
INSERT INTO "car_names" VALUES ("3", "Volkswagen");
INSERT INTO "car_names" VALUES ("4", "Renault");
INSERT INTO "car_names" VALUES ("5", "Ford");
INSERT INTO "car_names" VALUES ("6", "Holden");
INSERT INTO "model_list" VALUES ("1001", "1");
INSERT INTO "model_list" VALUES ("1002", "1");
INSERT INTO "model_list" VALUES ("1003", "2");
INSERT INTO "model_list" VALUES ("1004", "3");
INSERT INTO "model_list" VALUES ("1005", "4");
INSERT INTO "model_list" VALUES ("1006", "5");
INSERT INTO "model_list" VALUES ("1007", "6");