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,
"time" TEXT,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "lap"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

CREATE TABLE "pitStops" (
"raceId" INT,
"driverId" INT,
"stop" INT,
PRIMARY KEY ("raceId", "driverId", "stop")
);

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
PRIMARY KEY ("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", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("4", "Charles", "Leclerc");
INSERT INTO "drivers" VALUES ("5", "Lando", "Norris");
INSERT INTO "lapTimes" VALUES ("101", "1", "1", "1:20.345", "80345");
INSERT INTO "lapTimes" VALUES ("101", "1", "2", "1:19.876", "79876");
INSERT INTO "lapTimes" VALUES ("101", "1", "3", "1:19.500", "79500");
INSERT INTO "lapTimes" VALUES ("101", "2", "1", "1:20.100", "80100");
INSERT INTO "lapTimes" VALUES ("101", "2", "2", "1:20.000", "80000");
INSERT INTO "lapTimes" VALUES ("101", "2", "3", "1:19.700", "79700");
INSERT INTO "lapTimes" VALUES ("101", "3", "1", "1:21.000", "81000");
INSERT INTO "lapTimes" VALUES ("101", "3", "2", "1:20.800", "80800");
INSERT INTO "lapTimes" VALUES ("101", "3", "3", "1:20.500", "80500");
INSERT INTO "lapTimes" VALUES ("102", "1", "1", "1:21.000", "81000");
INSERT INTO "lapTimes" VALUES ("102", "1", "2", "1:20.900", "80900");
INSERT INTO "lapTimes" VALUES ("102", "1", "3", "1:20.800", "80800");
INSERT INTO "lapTimes" VALUES ("102", "4", "1", "1:21.500", "81500");
INSERT INTO "lapTimes" VALUES ("102", "4", "2", "1:21.200", "81200");
INSERT INTO "lapTimes" VALUES ("102", "4", "3", "1:21.000", "81000");
INSERT INTO "lapTimes" VALUES ("102", "5", "1", "1:22.000", "82000");
INSERT INTO "lapTimes" VALUES ("102", "5", "2", "1:21.800", "81800");
INSERT INTO "lapTimes" VALUES ("102", "5", "3", "1:21.600", "81600");
INSERT INTO "pitStops" VALUES ("101", "1", "1");
INSERT INTO "pitStops" VALUES ("101", "2", "1");
INSERT INTO "pitStops" VALUES ("101", "3", "1");
INSERT INTO "pitStops" VALUES ("102", "1", "1");
INSERT INTO "pitStops" VALUES ("102", "4", "1");
INSERT INTO "pitStops" VALUES ("102", "5", "1");
INSERT INTO "results" VALUES ("1001", "1");
INSERT INTO "results" VALUES ("1002", "2");
INSERT INTO "results" VALUES ("1003", "3");
INSERT INTO "results" VALUES ("1004", "4");
INSERT INTO "results" VALUES ("1005", "5");