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

CREATE TABLE "qualifying" (
"qualifyId" INT,
"raceId" INT,
"driverId" INT,
"position" INT,
"q1" TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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



INSERT INTO "drivers" VALUES ("1", "hamilton");
INSERT INTO "drivers" VALUES ("2", "verstappen");
INSERT INTO "drivers" VALUES ("3", "bottas");
INSERT INTO "drivers" VALUES ("4", "perez");
INSERT INTO "drivers" VALUES ("5", "norris");
INSERT INTO "drivers" VALUES ("6", "ricciardo");
INSERT INTO "drivers" VALUES ("7", "leclerc");
INSERT INTO "drivers" VALUES ("8", "sainz");
INSERT INTO "drivers" VALUES ("9", "alonso");
INSERT INTO "drivers" VALUES ("10", "ocon");
INSERT INTO "drivers" VALUES ("11", "vettel");
INSERT INTO "drivers" VALUES ("12", "gasly");
INSERT INTO "drivers" VALUES ("13", "tsunoda");
INSERT INTO "drivers" VALUES ("14", "latifi");
INSERT INTO "drivers" VALUES ("15", "schumacher");
INSERT INTO "drivers" VALUES ("16", "mickelson");
INSERT INTO "qualifying" VALUES ("101", "20", "1", "1", "1:12.345");
INSERT INTO "qualifying" VALUES ("102", "20", "2", "2", "1:12.400");
INSERT INTO "qualifying" VALUES ("103", "20", "3", "3", "1:12.500");
INSERT INTO "qualifying" VALUES ("104", "20", "4", "4", "1:12.600");
INSERT INTO "qualifying" VALUES ("105", "20", "5", "5", "1:12.700");
INSERT INTO "qualifying" VALUES ("106", "20", "6", "6", "1:12.800");
INSERT INTO "qualifying" VALUES ("107", "20", "7", "7", "1:12.900");
INSERT INTO "qualifying" VALUES ("108", "20", "8", "8", "1:13.000");
INSERT INTO "qualifying" VALUES ("109", "20", "9", "9", "1:13.100");
INSERT INTO "qualifying" VALUES ("110", "20", "10", "10", "1:13.200");
INSERT INTO "qualifying" VALUES ("111", "20", "11", "NULL", "1:14.500");
INSERT INTO "qualifying" VALUES ("112", "20", "12", "NULL", "1:14.500");
INSERT INTO "qualifying" VALUES ("113", "20", "13", "NULL", "1:14.600");
INSERT INTO "qualifying" VALUES ("114", "20", "14", "NULL", "NULL");
INSERT INTO "qualifying" VALUES ("115", "20", "15", "NULL", "1:14.700");
INSERT INTO "qualifying" VALUES ("116", "20", "16", "NULL", "1:14.700");
INSERT INTO "qualifying" VALUES ("201", "19", "1", "1", "1:11.000");
INSERT INTO "qualifying" VALUES ("202", "19", "2", "2", "1:11.100");
INSERT INTO "qualifying" VALUES ("203", "19", "3", "3", "1:11.200");
INSERT INTO "results" VALUES ("1", "1", "25.0");
INSERT INTO "results" VALUES ("2", "2", "18.0");
INSERT INTO "results" VALUES ("3", "3", "15.0");
INSERT INTO "results" VALUES ("4", "4", "12.0");
INSERT INTO "results" VALUES ("5", "5", "10.0");
INSERT INTO "results" VALUES ("6", "6", "8.0");
INSERT INTO "results" VALUES ("7", "7", "6.0");
INSERT INTO "results" VALUES ("8", "8", "4.0");
INSERT INTO "results" VALUES ("9", "9", "2.0");
INSERT INTO "results" VALUES ("10", "10", "1.0");
INSERT INTO "lapTimes" VALUES ("20", "1", "1", "72000");
INSERT INTO "lapTimes" VALUES ("20", "2", "1", "72100");
INSERT INTO "lapTimes" VALUES ("20", "3", "1", "72200");
INSERT INTO "lapTimes" VALUES ("20", "11", "1", "74000");
INSERT INTO "lapTimes" VALUES ("20", "14", "1", "75000");