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 "constructorResults" (
"constructorResultsId" INT,
"status" TEXT,
PRIMARY KEY ("constructorResultsId")
);

CREATE TABLE "constructors" (
"constructorId" INT,
"nationality" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

CREATE TABLE "races" (
"raceId" INT,
"name" TEXT,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"driverId" INT,
"statusId" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId"),
FOREIGN KEY ("statusId") REFERENCES "status"("statusId")
);

CREATE TABLE "status" (
"statusId" INT UNIQUE,
"status" TEXT,
PRIMARY KEY ("statusId")
);



INSERT INTO "constructorResults" VALUES ("1", "Finished");
INSERT INTO "constructorResults" VALUES ("2", "Puncture");
INSERT INTO "constructorResults" VALUES ("3", "Engine failure");
INSERT INTO "constructorResults" VALUES ("4", "Accident");
INSERT INTO "constructorResults" VALUES ("5", "Finished");
INSERT INTO "constructorResults" VALUES ("6", "Puncture");
INSERT INTO "constructorResults" VALUES ("7", "Finished");
INSERT INTO "constructorResults" VALUES ("8", "Puncture");
INSERT INTO "constructorResults" VALUES ("9", "Finished");
INSERT INTO "constructorResults" VALUES ("10", "Finished");
INSERT INTO "constructors" VALUES ("1", "British");
INSERT INTO "constructors" VALUES ("2", "American");
INSERT INTO "constructors" VALUES ("3", "German");
INSERT INTO "constructors" VALUES ("4", "Italian");
INSERT INTO "constructors" VALUES ("5", "French");
INSERT INTO "constructors" VALUES ("6", "American");
INSERT INTO "constructors" VALUES ("7", "British");
INSERT INTO "constructors" VALUES ("8", "German");
INSERT INTO "constructors" VALUES ("9", "Italian");
INSERT INTO "constructors" VALUES ("10", "American");
INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "American");
INSERT INTO "drivers" VALUES ("3", "German");
INSERT INTO "drivers" VALUES ("4", "American");
INSERT INTO "drivers" VALUES ("5", "French");
INSERT INTO "drivers" VALUES ("6", "British");
INSERT INTO "drivers" VALUES ("7", "American");
INSERT INTO "drivers" VALUES ("8", "German");
INSERT INTO "drivers" VALUES ("9", "Italian");
INSERT INTO "drivers" VALUES ("10", "American");
INSERT INTO "races" VALUES ("1", "Grand Prix 1");
INSERT INTO "races" VALUES ("2", "Grand Prix 2");
INSERT INTO "races" VALUES ("3", "Grand Prix 3");
INSERT INTO "races" VALUES ("4", "Grand Prix 4");
INSERT INTO "races" VALUES ("5", "Grand Prix 5");
INSERT INTO "races" VALUES ("6", "Grand Prix 6");
INSERT INTO "races" VALUES ("7", "Grand Prix 7");
INSERT INTO "races" VALUES ("8", "Grand Prix 8");
INSERT INTO "races" VALUES ("9", "Grand Prix 9");
INSERT INTO "races" VALUES ("10", "Grand Prix 10");
INSERT INTO "results" VALUES ("1", "1", "1");
INSERT INTO "results" VALUES ("2", "2", "2");
INSERT INTO "results" VALUES ("3", "3", "3");
INSERT INTO "results" VALUES ("4", "4", "2");
INSERT INTO "results" VALUES ("5", "5", "1");
INSERT INTO "results" VALUES ("6", "6", "4");
INSERT INTO "results" VALUES ("7", "7", "2");
INSERT INTO "results" VALUES ("8", "8", "1");
INSERT INTO "results" VALUES ("9", "9", "3");
INSERT INTO "results" VALUES ("10", "10", "2");
INSERT INTO "results" VALUES ("11", "2", "1");
INSERT INTO "results" VALUES ("12", "4", "1");
INSERT INTO "results" VALUES ("13", "7", "1");
INSERT INTO "results" VALUES ("14", "10", "1");
INSERT INTO "results" VALUES ("15", "2", "2");
INSERT INTO "results" VALUES ("16", "4", "2");
INSERT INTO "status" VALUES ("1", "Finished");
INSERT INTO "status" VALUES ("2", "Puncture");
INSERT INTO "status" VALUES ("3", "Engine failure");
INSERT INTO "status" VALUES ("4", "Accident");
INSERT INTO "status" VALUES ("5", "Disqualified");
INSERT INTO "status" VALUES ("6", "Retired");
INSERT INTO "status" VALUES ("7", "Collision");
INSERT INTO "status" VALUES ("8", "Hydraulics");
INSERT INTO "status" VALUES ("9", "Gearbox");
INSERT INTO "status" VALUES ("10", "Brakes");