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

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"code" TEXT,
"dob" DATE,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

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

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"fastestLapTime" TEXT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "drivers" VALUES ("1", "MSC", "1969-01-03", "German");
INSERT INTO "drivers" VALUES ("2", "ALO", "1981-07-29", "Spanish");
INSERT INTO "drivers" VALUES ("3", "RAI", "1979-10-17", "Finnish");
INSERT INTO "drivers" VALUES ("4", "VET", "1987-07-03", "German");
INSERT INTO "drivers" VALUES ("5", "HAM", "1985-01-07", "British");
INSERT INTO "drivers" VALUES ("6", "WEB", "1976-08-27", "Australian");
INSERT INTO "drivers" VALUES ("7", "BUT", "1980-01-19", "British");
INSERT INTO "drivers" VALUES ("8", "MAS", "1981-04-27", "Brazilian");
INSERT INTO "drivers" VALUES ("9", "KUB", "1984-12-07", "Polish");
INSERT INTO "drivers" VALUES ("10", "HEI", "1971-11-03", "German");
INSERT INTO "drivers" VALUES ("11", "TRU", "1971-10-10", "Italian");
INSERT INTO "drivers" VALUES ("12", "BAR", "1972-05-23", "Brazilian");
INSERT INTO "drivers" VALUES ("13", "FIS", "1973-01-14", "Italian");
INSERT INTO "drivers" VALUES ("14", "COU", "1971-03-27", "British");
INSERT INTO "drivers" VALUES ("15", "ROS", "1985-06-27", "German");
INSERT INTO "drivers" VALUES ("16", "PER", "1990-01-26", "Mexican");
INSERT INTO "drivers" VALUES ("17", "RIC", "1989-07-01", "Australian");
INSERT INTO "drivers" VALUES ("18", "VER", "1997-09-30", "Dutch");
INSERT INTO "drivers" VALUES ("19", "SAI", "1994-09-01", "Spanish");
INSERT INTO "drivers" VALUES ("20", "NOR", "1999-11-13", "British");
INSERT INTO "races" VALUES ("1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("3", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("4", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("5", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("6", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("7", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("8", "British Grand Prix");
INSERT INTO "races" VALUES ("9", "German Grand Prix");
INSERT INTO "races" VALUES ("10", "Hungarian Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "1:25.000");
INSERT INTO "results" VALUES ("2", "1", "2", "1:26.123");
INSERT INTO "results" VALUES ("3", "1", "10", "1:24.900");
INSERT INTO "results" VALUES ("4", "1", "11", "1:25.500");
INSERT INTO "results" VALUES ("5", "1", "14", "1:25.050");
INSERT INTO "results" VALUES ("6", "2", "3", "1:30.000");
INSERT INTO "results" VALUES ("7", "2", "4", "1:31.500");
INSERT INTO "results" VALUES ("8", "2", "10", "1:29.800");
INSERT INTO "results" VALUES ("9", "2", "11", "1:30.100");
INSERT INTO "results" VALUES ("10", "2", "14", "NULL");
INSERT INTO "results" VALUES ("11", "3", "5", "1:35.000");
INSERT INTO "results" VALUES ("12", "3", "6", "1:36.000");
INSERT INTO "results" VALUES ("13", "3", "10", "1:34.500");
INSERT INTO "results" VALUES ("14", "3", "11", "1:34.800");
INSERT INTO "results" VALUES ("15", "3", "14", "1:35.200");
INSERT INTO "results" VALUES ("16", "4", "7", "1:40.000");
INSERT INTO "results" VALUES ("17", "4", "8", "1:41.000");
INSERT INTO "results" VALUES ("18", "4", "10", "NULL");
INSERT INTO "results" VALUES ("19", "4", "11", "1:40.500");
INSERT INTO "results" VALUES ("20", "4", "14", "1:39.900");
INSERT INTO "results" VALUES ("21", "5", "9", "1:20.000");
INSERT INTO "results" VALUES ("22", "5", "1", "1:21.000");
INSERT INTO "results" VALUES ("23", "5", "10", "1:19.800");
INSERT INTO "results" VALUES ("24", "5", "11", "1:20.200");
INSERT INTO "results" VALUES ("25", "5", "14", "1:20.100");
INSERT INTO "results" VALUES ("26", "6", "2", "1:15.000");
INSERT INTO "results" VALUES ("27", "6", "3", "1:16.000");
INSERT INTO "results" VALUES ("28", "6", "10", "1:14.900");
INSERT INTO "results" VALUES ("29", "6", "11", "NULL");
INSERT INTO "results" VALUES ("30", "6", "14", "1:15.100");
INSERT INTO "results" VALUES ("31", "7", "4", "1:28.000");
INSERT INTO "results" VALUES ("32", "7", "5", "1:29.000");
INSERT INTO "results" VALUES ("33", "7", "10", "1:27.500");
INSERT INTO "results" VALUES ("34", "7", "11", "1:27.800");
INSERT INTO "results" VALUES ("35", "7", "14", "1:27.600");
INSERT INTO "results" VALUES ("36", "8", "6", "1:22.000");
INSERT INTO "results" VALUES ("37", "8", "7", "1:23.000");
INSERT INTO "results" VALUES ("38", "8", "10", "1:21.900");
INSERT INTO "results" VALUES ("39", "8", "11", "1:22.500");
INSERT INTO "results" VALUES ("40", "8", "14", "NULL");
INSERT INTO "results" VALUES ("41", "9", "8", "1:33.000");
INSERT INTO "results" VALUES ("42", "9", "9", "1:34.000");
INSERT INTO "results" VALUES ("43", "9", "10", "1:32.800");
INSERT INTO "results" VALUES ("44", "9", "11", "1:33.200");
INSERT INTO "results" VALUES ("45", "9", "14", "1:33.100");
INSERT INTO "results" VALUES ("46", "10", "1", "1:26.000");
INSERT INTO "results" VALUES ("47", "10", "2", "1:27.000");
INSERT INTO "results" VALUES ("48", "10", "10", "1:25.900");
INSERT INTO "results" VALUES ("49", "10", "11", "1:26.500");
INSERT INTO "results" VALUES ("50", "10", "14", "1:26.100");
INSERT INTO "lapTimes" VALUES ("1", "1", "1", "85000");
INSERT INTO "lapTimes" VALUES ("1", "2", "1", "86123");
INSERT INTO "lapTimes" VALUES ("1", "10", "1", "84900");
INSERT INTO "lapTimes" VALUES ("1", "11", "1", "85500");
INSERT INTO "lapTimes" VALUES ("1", "14", "1", "85050");
INSERT INTO "lapTimes" VALUES ("2", "3", "1", "90000");
INSERT INTO "lapTimes" VALUES ("2", "4", "1", "91500");
INSERT INTO "lapTimes" VALUES ("2", "10", "1", "89800");
INSERT INTO "lapTimes" VALUES ("2", "11", "1", "90100");
INSERT INTO "lapTimes" VALUES ("3", "5", "1", "95000");
INSERT INTO "lapTimes" VALUES ("3", "6", "1", "96000");
INSERT INTO "lapTimes" VALUES ("3", "10", "1", "94500");
INSERT INTO "lapTimes" VALUES ("3", "11", "1", "94800");
INSERT INTO "lapTimes" VALUES ("3", "14", "1", "95200");
INSERT INTO "lapTimes" VALUES ("4", "7", "1", "100000");
INSERT INTO "lapTimes" VALUES ("4", "8", "1", "101000");
INSERT INTO "lapTimes" VALUES ("4", "11", "1", "100500");
INSERT INTO "lapTimes" VALUES ("4", "14", "1", "99900");
INSERT INTO "lapTimes" VALUES ("5", "9", "1", "80000");
INSERT INTO "lapTimes" VALUES ("5", "1", "1", "81000");
INSERT INTO "lapTimes" VALUES ("5", "10", "1", "79800");
INSERT INTO "lapTimes" VALUES ("5", "11", "1", "80200");
INSERT INTO "lapTimes" VALUES ("5", "14", "1", "80100");
INSERT INTO "lapTimes" VALUES ("6", "2", "1", "75000");
INSERT INTO "lapTimes" VALUES ("6", "3", "1", "76000");
INSERT INTO "lapTimes" VALUES ("6", "10", "1", "74900");
INSERT INTO "lapTimes" VALUES ("6", "14", "1", "75100");
INSERT INTO "lapTimes" VALUES ("7", "4", "1", "88000");
INSERT INTO "lapTimes" VALUES ("7", "5", "1", "89000");
INSERT INTO "lapTimes" VALUES ("7", "10", "1", "87500");
INSERT INTO "lapTimes" VALUES ("7", "11", "1", "87800");
INSERT INTO "lapTimes" VALUES ("7", "14", "1", "87600");
INSERT INTO "lapTimes" VALUES ("8", "6", "1", "82000");
INSERT INTO "lapTimes" VALUES ("8", "7", "1", "83000");
INSERT INTO "lapTimes" VALUES ("8", "10", "1", "81900");
INSERT INTO "lapTimes" VALUES ("8", "11", "1", "82500");
INSERT INTO "lapTimes" VALUES ("9", "8", "1", "93000");
INSERT INTO "lapTimes" VALUES ("9", "9", "1", "94000");
INSERT INTO "lapTimes" VALUES ("9", "10", "1", "92800");
INSERT INTO "lapTimes" VALUES ("9", "11", "1", "93200");
INSERT INTO "lapTimes" VALUES ("9", "14", "1", "93100");
INSERT INTO "lapTimes" VALUES ("10", "1", "1", "86000");
INSERT INTO "lapTimes" VALUES ("10", "2", "1", "87000");
INSERT INTO "lapTimes" VALUES ("10", "10", "1", "85900");
INSERT INTO "lapTimes" VALUES ("10", "11", "1", "86500");
INSERT INTO "lapTimes" VALUES ("10", "14", "1", "86100");