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,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "stop")
);

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

CREATE TABLE "results" (
"resultId" INT,
"time" TEXT,
"milliseconds" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "drivers" VALUES ("1");
INSERT INTO "drivers" VALUES ("2");
INSERT INTO "drivers" VALUES ("3");
INSERT INTO "drivers" VALUES ("4");
INSERT INTO "drivers" VALUES ("5");
INSERT INTO "drivers" VALUES ("6");
INSERT INTO "drivers" VALUES ("7");
INSERT INTO "drivers" VALUES ("8");
INSERT INTO "drivers" VALUES ("9");
INSERT INTO "drivers" VALUES ("10");
INSERT INTO "lapTimes" VALUES ("1", "1", "1", "0:55.000", "55000");
INSERT INTO "lapTimes" VALUES ("1", "2", "1", "0:56.000", "56000");
INSERT INTO "lapTimes" VALUES ("1", "3", "1", "0:54.500", "54500");
INSERT INTO "lapTimes" VALUES ("1", "4", "1", "0:57.000", "57000");
INSERT INTO "lapTimes" VALUES ("1", "5", "1", "0:54.000", "54000");
INSERT INTO "lapTimes" VALUES ("1", "6", "1", "0:55.500", "55500");
INSERT INTO "lapTimes" VALUES ("1", "7", "1", "0:53.800", "53800");
INSERT INTO "lapTimes" VALUES ("1", "8", "1", "0:56.500", "56500");
INSERT INTO "lapTimes" VALUES ("1", "9", "1", "0:54.200", "54200");
INSERT INTO "lapTimes" VALUES ("1", "10", "1", "0:55.200", "55200");
INSERT INTO "lapTimes" VALUES ("2", "1", "1", "0:53.000", "53000");
INSERT INTO "lapTimes" VALUES ("2", "2", "1", "0:54.000", "54000");
INSERT INTO "lapTimes" VALUES ("2", "3", "1", "0:52.500", "52500");
INSERT INTO "lapTimes" VALUES ("2", "4", "1", "0:55.000", "55000");
INSERT INTO "lapTimes" VALUES ("2", "5", "1", "0:52.000", "52000");
INSERT INTO "lapTimes" VALUES ("2", "6", "1", "0:53.500", "53500");
INSERT INTO "lapTimes" VALUES ("2", "7", "1", "0:51.800", "51800");
INSERT INTO "lapTimes" VALUES ("2", "8", "1", "0:54.500", "54500");
INSERT INTO "lapTimes" VALUES ("2", "9", "1", "0:52.200", "52200");
INSERT INTO "lapTimes" VALUES ("2", "10", "1", "0:53.200", "53200");
INSERT INTO "lapTimes" VALUES ("1", "1", "2", "0:54.000", "54000");
INSERT INTO "lapTimes" VALUES ("1", "2", "2", "0:55.000", "55000");
INSERT INTO "lapTimes" VALUES ("1", "3", "2", "0:53.500", "53500");
INSERT INTO "pitStops" VALUES ("1", "1", "1", "25000");
INSERT INTO "pitStops" VALUES ("1", "2", "1", "26000");
INSERT INTO "pitStops" VALUES ("2", "3", "1", "24000");
INSERT INTO "results" VALUES ("1", "1:30:00.000", "5400000");
INSERT INTO "results" VALUES ("2", "1:30:05.000", "5405000");
INSERT INTO "results" VALUES ("3", "1:30:10.000", "5410000");