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 "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
"dob" DATE,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

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

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"position" INT,
"time" TEXT,
"milliseconds" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton", "1985-01-07", "British");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen", "1997-09-30", "Dutch");
INSERT INTO "drivers" VALUES ("3", "Fernando", "Alonso", "1981-07-29", "Spanish");
INSERT INTO "drivers" VALUES ("4", "Sebastian", "Vettel", "1987-07-03", "German");
INSERT INTO "drivers" VALUES ("5", "Kimi", "Raikkonen", "1979-10-17", "Finnish");
INSERT INTO "drivers" VALUES ("6", "Daniel", "Ricciardo", "1989-07-01", "Australian");
INSERT INTO "drivers" VALUES ("7", "Valtteri", "Bottas", "1989-08-28", "Finnish");
INSERT INTO "drivers" VALUES ("8", "Sergio", "Perez", "1990-01-26", "Mexican");
INSERT INTO "drivers" VALUES ("9", "Charles", "Leclerc", "1997-10-16", "Monegasque");
INSERT INTO "drivers" VALUES ("10", "Lando", "Norris", "1999-11-13", "British");
INSERT INTO "races" VALUES ("590");
INSERT INTO "races" VALUES ("591");
INSERT INTO "races" VALUES ("592");
INSERT INTO "races" VALUES ("593");
INSERT INTO "races" VALUES ("594");
INSERT INTO "results" VALUES ("1", "592", "1", "1", "1:30:00.000", "5400000");
INSERT INTO "results" VALUES ("2", "592", "2", "2", "1:30:05.000", "5405000");
INSERT INTO "results" VALUES ("3", "592", "3", "3", "1:30:10.000", "5410000");
INSERT INTO "results" VALUES ("4", "592", "4", "4", "1:30:15.000", "5415000");
INSERT INTO "results" VALUES ("5", "592", "5", "5", "1:30:20.000", "5420000");
INSERT INTO "results" VALUES ("6", "592", "6", "6", "1:30:25.000", "5425000");
INSERT INTO "results" VALUES ("7", "592", "7", "7", "1:30:30.000", "5430000");
INSERT INTO "results" VALUES ("8", "592", "8", "8", "1:30:35.000", "5435000");
INSERT INTO "results" VALUES ("9", "592", "9", "9", "NULL", "NULL");
INSERT INTO "results" VALUES ("10", "592", "10", "10", "NULL", "NULL");
INSERT INTO "results" VALUES ("11", "591", "1", "1", "1:25:00.000", "5100000");
INSERT INTO "results" VALUES ("12", "593", "2", "1", "1:28:00.000", "5280000");
INSERT INTO "results" VALUES ("13", "592", "1", "1", "1:30:00.000", "5400000");
INSERT INTO "results" VALUES ("14", "592", "2", "2", "1:30:05.000", "5405000");
INSERT INTO "results" VALUES ("15", "592", "3", "3", "1:30:10.000", "5410000");
INSERT INTO "results" VALUES ("16", "592", "4", "4", "1:30:15.000", "5415000");
INSERT INTO "results" VALUES ("17", "592", "5", "5", "1:30:20.000", "5420000");
INSERT INTO "results" VALUES ("18", "592", "6", "6", "1:30:25.000", "5425000");
INSERT INTO "results" VALUES ("19", "592", "7", "7", "1:30:30.000", "5430000");
INSERT INTO "results" VALUES ("20", "592", "8", "8", "1:30:35.000", "5435000");
INSERT INTO "results" VALUES ("21", "592", "9", "9", "NULL", "NULL");
INSERT INTO "results" VALUES ("22", "592", "10", "10", "NULL", "NULL");
INSERT INTO "results" VALUES ("23", "591", "1", "1", "1:25:00.000", "5100000");
INSERT INTO "results" VALUES ("24", "593", "2", "1", "1:28:00.000", "5280000");