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,
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,
"name" TEXT,
PRIMARY KEY ("raceId")
);



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 "races" VALUES ("347", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("348", "British Grand Prix");
INSERT INTO "races" VALUES ("349", "Italian Grand Prix");
INSERT INTO "races" VALUES ("350", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("351", "Abu Dhabi Grand Prix");
INSERT INTO "lapTimes" VALUES ("348", "1", "1", "00:01:28.500");
INSERT INTO "lapTimes" VALUES ("348", "1", "2", "00:01:27.900");
INSERT INTO "lapTimes" VALUES ("348", "1", "3", "00:01:27.500");
INSERT INTO "lapTimes" VALUES ("348", "2", "1", "00:01:28.700");
INSERT INTO "lapTimes" VALUES ("348", "2", "2", "00:01:27.800");
INSERT INTO "lapTimes" VALUES ("348", "2", "3", "00:01:27.600");
INSERT INTO "lapTimes" VALUES ("348", "3", "1", "00:01:29.000");
INSERT INTO "lapTimes" VALUES ("348", "3", "2", "00:01:28.100");
INSERT INTO "lapTimes" VALUES ("348", "3", "3", "00:01:27.700");
INSERT INTO "lapTimes" VALUES ("348", "4", "1", "00:01:29.200");
INSERT INTO "lapTimes" VALUES ("348", "4", "2", "00:01:28.000");
INSERT INTO "lapTimes" VALUES ("348", "4", "3", "00:01:27.400");
INSERT INTO "lapTimes" VALUES ("348", "5", "1", "00:01:29.500");
INSERT INTO "lapTimes" VALUES ("348", "5", "2", "00:01:28.300");
INSERT INTO "lapTimes" VALUES ("348", "5", "3", "00:01:27.900");
INSERT INTO "lapTimes" VALUES ("347", "1", "1", "00:01:15.000");
INSERT INTO "lapTimes" VALUES ("349", "6", "1", "00:01:22.000");
INSERT INTO "lapTimes" VALUES ("348", "1", "4", "00:01:27.300");
INSERT INTO "lapTimes" VALUES ("348", "2", "4", "00:01:27.550");
INSERT INTO "lapTimes" VALUES ("348", "4", "4", "00:01:27.350");