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,
"q1" TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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

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



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 ("20", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("21", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("22", "European Grand Prix");
INSERT INTO "races" VALUES ("23", "British Grand Prix");
INSERT INTO "races" VALUES ("24", "German Grand Prix");
INSERT INTO "drivers" VALUES ("1", "hamilton");
INSERT INTO "drivers" VALUES ("2", "alonso");
INSERT INTO "drivers" VALUES ("3", "vettel");
INSERT INTO "drivers" VALUES ("4", "raikkonen");
INSERT INTO "drivers" VALUES ("5", "bottas");
INSERT INTO "drivers" VALUES ("6", "ricciardo");
INSERT INTO "drivers" VALUES ("7", "verstappen");
INSERT INTO "drivers" VALUES ("8", "perez");
INSERT INTO "drivers" VALUES ("9", "sainz");
INSERT INTO "drivers" VALUES ("10", "hulkenberg");
INSERT INTO "drivers" VALUES ("11", "gasly");
INSERT INTO "drivers" VALUES ("12", "ocon");
INSERT INTO "drivers" VALUES ("13", "stroll");
INSERT INTO "drivers" VALUES ("14", "magnussen");
INSERT INTO "drivers" VALUES ("15", "grosjean");
INSERT INTO "drivers" VALUES ("16", "leclerc");
INSERT INTO "drivers" VALUES ("17", "norris");
INSERT INTO "drivers" VALUES ("18", "russell");
INSERT INTO "drivers" VALUES ("19", "kubica");
INSERT INTO "drivers" VALUES ("20", "giovinazzi");
INSERT INTO "drivers" VALUES ("21", "kvyat");
INSERT INTO "drivers" VALUES ("22", "albon");
INSERT INTO "drivers" VALUES ("23", "latifi");
INSERT INTO "drivers" VALUES ("24", "mazepin");
INSERT INTO "drivers" VALUES ("25", "schumacher");
INSERT INTO "qualifying" VALUES ("1", "1", "1", "1:25.000");
INSERT INTO "qualifying" VALUES ("2", "1", "2", "1:25.100");
INSERT INTO "qualifying" VALUES ("3", "1", "3", "1:25.200");
INSERT INTO "qualifying" VALUES ("4", "1", "4", "1:25.300");
INSERT INTO "qualifying" VALUES ("5", "1", "5", "1:25.400");
INSERT INTO "qualifying" VALUES ("6", "1", "6", "1:25.500");
INSERT INTO "qualifying" VALUES ("7", "1", "7", "1:25.600");
INSERT INTO "qualifying" VALUES ("8", "1", "8", "1:25.700");
INSERT INTO "qualifying" VALUES ("9", "1", "9", "1:25.800");
INSERT INTO "qualifying" VALUES ("10", "1", "10", "1:25.900");
INSERT INTO "qualifying" VALUES ("11", "1", "11", "1:26.000");
INSERT INTO "qualifying" VALUES ("12", "1", "12", "1:26.100");
INSERT INTO "qualifying" VALUES ("13", "1", "13", "1:26.200");
INSERT INTO "qualifying" VALUES ("14", "1", "14", "1:26.300");
INSERT INTO "qualifying" VALUES ("15", "1", "15", "1:26.400");
INSERT INTO "qualifying" VALUES ("16", "1", "16", "1:26.500");
INSERT INTO "qualifying" VALUES ("17", "1", "17", "1:26.600");
INSERT INTO "qualifying" VALUES ("18", "1", "18", "1:26.700");
INSERT INTO "qualifying" VALUES ("19", "1", "19", "1:26.800");
INSERT INTO "qualifying" VALUES ("20", "1", "20", "1:26.900");
INSERT INTO "qualifying" VALUES ("21", "20", "1", "1:12.000");
INSERT INTO "qualifying" VALUES ("22", "20", "2", "1:12.100");
INSERT INTO "qualifying" VALUES ("23", "20", "3", "1:12.200");
INSERT INTO "qualifying" VALUES ("24", "20", "4", "1:12.300");
INSERT INTO "qualifying" VALUES ("25", "20", "5", "1:12.400");
INSERT INTO "qualifying" VALUES ("26", "20", "6", "1:12.500");
INSERT INTO "qualifying" VALUES ("27", "20", "7", "1:12.600");
INSERT INTO "qualifying" VALUES ("28", "20", "8", "1:12.700");
INSERT INTO "qualifying" VALUES ("29", "20", "9", "1:12.800");
INSERT INTO "qualifying" VALUES ("30", "20", "10", "1:12.900");
INSERT INTO "qualifying" VALUES ("31", "20", "11", "1:13.000");
INSERT INTO "qualifying" VALUES ("32", "20", "12", "1:13.100");
INSERT INTO "qualifying" VALUES ("33", "20", "13", "1:13.200");
INSERT INTO "qualifying" VALUES ("34", "20", "14", "1:13.300");
INSERT INTO "qualifying" VALUES ("35", "20", "15", "1:13.400");
INSERT INTO "qualifying" VALUES ("36", "20", "16", "1:13.500");
INSERT INTO "qualifying" VALUES ("37", "20", "17", "1:13.600");
INSERT INTO "qualifying" VALUES ("38", "20", "18", "1:13.700");
INSERT INTO "qualifying" VALUES ("39", "20", "19", "1:13.800");
INSERT INTO "qualifying" VALUES ("40", "20", "20", "1:13.900");
INSERT INTO "qualifying" VALUES ("41", "20", "21", "1:14.000");
INSERT INTO "qualifying" VALUES ("42", "20", "22", "1:14.100");
INSERT INTO "qualifying" VALUES ("43", "20", "23", "1:14.200");
INSERT INTO "qualifying" VALUES ("44", "20", "24", "1:14.300");
INSERT INTO "qualifying" VALUES ("45", "20", "25", "1:14.400");
INSERT INTO "lapTimes" VALUES ("1", "1", "1", "90000");
INSERT INTO "lapTimes" VALUES ("1", "1", "2", "89000");
INSERT INTO "lapTimes" VALUES ("20", "1", "1", "70000");
INSERT INTO "lapTimes" VALUES ("20", "25", "1", "75000");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "4");
INSERT INTO "results" VALUES ("5", "5");