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.500", "80500");
INSERT INTO "lapTimes" VALUES ("101", "1", "2", "1:19.800", "79800");
INSERT INTO "lapTimes" VALUES ("101", "1", "3", "1:20.200", "80200");
INSERT INTO "lapTimes" VALUES ("101", "2", "1", "1:20.700", "80700");
INSERT INTO "lapTimes" VALUES ("101", "2", "2", "1:20.000", "80000");
INSERT INTO "lapTimes" VALUES ("101", "2", "3", "1:19.900", "79900");
INSERT INTO "lapTimes" VALUES ("101", "3", "1", "1:21.000", "81000");
INSERT INTO "lapTimes" VALUES ("101", "3", "2", "1:20.500", "80500");
INSERT INTO "lapTimes" VALUES ("101", "3", "3", "1:20.300", "80300");
INSERT INTO "lapTimes" VALUES ("102", "1", "1", "1:18.900", "78900");
INSERT INTO "lapTimes" VALUES ("102", "1", "2", "1:19.100", "79100");
INSERT INTO "lapTimes" VALUES ("102", "2", "1", "1:18.900", "78900");
INSERT INTO "lapTimes" VALUES ("102", "2", "2", "1:19.000", "79000");
INSERT INTO "lapTimes" VALUES ("102", "4", "1", "1:19.500", "79500");
INSERT INTO "lapTimes" VALUES ("102", "4", "2", "1:19.200", "79200");
INSERT INTO "lapTimes" VALUES ("103", "1", "1", "1:18.500", "78500");
INSERT INTO "lapTimes" VALUES ("103", "1", "2", "1:18.700", "78700");
INSERT INTO "lapTimes" VALUES ("103", "5", "1", "1:19.000", "79000");
INSERT INTO "lapTimes" VALUES ("103", "5", "2", "1:18.900", "78900");
INSERT INTO "lapTimes" VALUES ("103", "3", "1", "1:19.200", "79200");
INSERT INTO "lapTimes" VALUES ("104", "2", "1", "1:20.300", "80300");
INSERT INTO "lapTimes" VALUES ("104", "2", "2", "1:20.100", "80100");
INSERT INTO "lapTimes" VALUES ("104", "1", "1", "1:20.400", "80400");
INSERT INTO "lapTimes" VALUES ("104", "1", "2", "1:20.200", "80200");
INSERT INTO "pitStops" VALUES ("101", "1", "1");
INSERT INTO "pitStops" VALUES ("101", "2", "1");
INSERT INTO "pitStops" VALUES ("102", "1", "1");
INSERT INTO "pitStops" VALUES ("102", "2", "1");
INSERT INTO "pitStops" VALUES ("103", "1", "1");
INSERT INTO "pitStops" VALUES ("103", "5", "1");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");