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

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



INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton", "http://en.wikipedia.org/wiki/Lewis_Hamilton");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen", "http://en.wikipedia.org/wiki/Max_Verstappen");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc", "http://en.wikipedia.org/wiki/Charles_Leclerc");
INSERT INTO "drivers" VALUES ("4", "Sergio", "Pérez", "http://en.wikipedia.org/wiki/Sergio_P%C3%A9rez");
INSERT INTO "drivers" VALUES ("5", "George", "Russell", "http://en.wikipedia.org/wiki/George_Russell");
INSERT INTO "drivers" VALUES ("6", "Carlos", "Sainz Jr.", "http://en.wikipedia.org/wiki/Carlos_Sainz_Jr.");
INSERT INTO "drivers" VALUES ("7", "Fernando", "Alonso", "http://en.wikipedia.org/wiki/Fernando_Alonso");
INSERT INTO "drivers" VALUES ("8", "Lando", "Norris", "http://en.wikipedia.org/wiki/Lando_Norris");
INSERT INTO "drivers" VALUES ("9", "Daniel", "Ricciardo", "http://en.wikipedia.org/wiki/Daniel_Ricciardo");
INSERT INTO "drivers" VALUES ("10", "Sebastian", "Vettel", "http://en.wikipedia.org/wiki/Sebastian_Vettel");
INSERT INTO "races" VALUES ("161");
INSERT INTO "races" VALUES ("162");
INSERT INTO "races" VALUES ("163");
INSERT INTO "races" VALUES ("164");
INSERT INTO "races" VALUES ("165");
INSERT INTO "lapTimes" VALUES ("161", "1", "1", "0:01:28.123");
INSERT INTO "lapTimes" VALUES ("161", "1", "2", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("161", "2", "1", "0:01:27.500");
INSERT INTO "lapTimes" VALUES ("161", "2", "2", "0:01:28.000");
INSERT INTO "lapTimes" VALUES ("161", "3", "1", "0:01:29.000");
INSERT INTO "lapTimes" VALUES ("161", "3", "2", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("162", "1", "1", "0:01:26.500");
INSERT INTO "lapTimes" VALUES ("162", "2", "1", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("163", "4", "1", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("164", "5", "1", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("165", "6", "1", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("161", "7", "1", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("161", "8", "1", "0:01:27.001");
INSERT INTO "lapTimes" VALUES ("161", "9", "1", "0:01:27.000");
INSERT INTO "lapTimes" VALUES ("161", "10", "1", "0:01:27.000");