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 "lapTimes" (
"raceId" INT,
"driverId" INT,
"lap" INT,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "lap")
);

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

CREATE TABLE "qualifying" (
"qualifyId" INT,
"raceId" INT,
"driverId" INT,
"q2" TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

CREATE TABLE "results" (
"resultId" INT,
"position" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc");
INSERT INTO "drivers" VALUES ("4", "Sergio", "Perez");
INSERT INTO "drivers" VALUES ("5", "George", "Russell");
INSERT INTO "drivers" VALUES ("6", "Carlos", "Sainz");
INSERT INTO "drivers" VALUES ("7", "Lando", "Norris");
INSERT INTO "drivers" VALUES ("8", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("9", "Valtteri", "Bottas");
INSERT INTO "drivers" VALUES ("10", "Daniel", "Ricciardo");
INSERT INTO "lapTimes" VALUES ("19", "1", "1", "80000");
INSERT INTO "lapTimes" VALUES ("19", "1", "2", "79500");
INSERT INTO "lapTimes" VALUES ("19", "2", "1", "80100");
INSERT INTO "lapTimes" VALUES ("19", "2", "2", "79600");
INSERT INTO "lapTimes" VALUES ("19", "3", "1", "80200");
INSERT INTO "lapTimes" VALUES ("19", "3", "2", "79700");
INSERT INTO "lapTimes" VALUES ("19", "4", "1", "80300");
INSERT INTO "lapTimes" VALUES ("19", "4", "2", "79800");
INSERT INTO "lapTimes" VALUES ("19", "5", "1", "80400");
INSERT INTO "lapTimes" VALUES ("19", "5", "2", "79900");
INSERT INTO "lapTimes" VALUES ("20", "1", "1", "78000");
INSERT INTO "lapTimes" VALUES ("20", "2", "1", "78100");
INSERT INTO "qualifying" VALUES ("1", "19", "1", "1:19.500");
INSERT INTO "qualifying" VALUES ("2", "19", "2", "1:19.600");
INSERT INTO "qualifying" VALUES ("3", "19", "3", "1:19.700");
INSERT INTO "qualifying" VALUES ("4", "19", "4", "1:19.800");
INSERT INTO "qualifying" VALUES ("5", "19", "5", "1:19.900");
INSERT INTO "qualifying" VALUES ("6", "20", "1", "1:18.000");
INSERT INTO "qualifying" VALUES ("7", "20", "2", "1:18.100");
INSERT INTO "qualifying" VALUES ("8", "19", "6", "1:20.000");
INSERT INTO "qualifying" VALUES ("9", "19", "7", "1:20.100");
INSERT INTO "qualifying" VALUES ("10", "19", "8", "1:20.200");
INSERT INTO "qualifying" VALUES ("11", "19", "9", "1:20.300");
INSERT INTO "qualifying" VALUES ("12", "19", "10", "1:20.400");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "4");
INSERT INTO "results" VALUES ("5", "5");