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 "driverStandings" (
"driverStandingsId" INT,
"points" FLOAT,
PRIMARY KEY ("driverStandingsId")
);

CREATE TABLE "lapTimes" (
"raceId" INT,
"driverId" INT,
"lap" INT,
"time" TEXT,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "lap"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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

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

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



INSERT INTO "races" VALUES ("347");
INSERT INTO "races" VALUES ("348");
INSERT INTO "races" VALUES ("349");
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 ("348", "1", "1", "1:20.500", "80500");
INSERT INTO "lapTimes" VALUES ("348", "1", "2", "1:19.800", "79800");
INSERT INTO "lapTimes" VALUES ("348", "1", "3", "1:19.200", "79200");
INSERT INTO "lapTimes" VALUES ("348", "2", "1", "1:20.300", "80300");
INSERT INTO "lapTimes" VALUES ("348", "2", "2", "1:19.100", "79100");
INSERT INTO "lapTimes" VALUES ("348", "2", "3", "1:18.900", "78900");
INSERT INTO "lapTimes" VALUES ("348", "3", "1", "1:21.000", "81000");
INSERT INTO "lapTimes" VALUES ("348", "3", "2", "1:20.500", "80500");
INSERT INTO "lapTimes" VALUES ("348", "3", "3", "1:20.000", "80000");
INSERT INTO "lapTimes" VALUES ("348", "4", "1", "1:20.800", "80800");
INSERT INTO "lapTimes" VALUES ("348", "4", "2", "1:20.200", "80200");
INSERT INTO "lapTimes" VALUES ("348", "4", "3", "1:19.900", "79900");
INSERT INTO "lapTimes" VALUES ("348", "5", "1", "1:21.200", "81200");
INSERT INTO "lapTimes" VALUES ("348", "5", "2", "1:20.900", "80900");
INSERT INTO "lapTimes" VALUES ("348", "5", "3", "1:20.300", "80300");
INSERT INTO "driverStandings" VALUES ("1", "347.5");
INSERT INTO "driverStandings" VALUES ("2", "400.0");
INSERT INTO "driverStandings" VALUES ("3", "250.0");
INSERT INTO "driverStandings" VALUES ("4", "300.0");
INSERT INTO "driverStandings" VALUES ("5", "150.0");
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");