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")
);

CREATE TABLE "circuits" (
"circuitId" INT,
"name" TEXT,
PRIMARY KEY ("circuitId")
);

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

CREATE TABLE "qualifying" (
"qualifyId" INT,
"q3" TEXT,
PRIMARY KEY ("qualifyId")
);

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 "lapTimes" VALUES ("1", "1", "1", "01:20.123");
INSERT INTO "lapTimes" VALUES ("1", "1", "2", "01:19.500");
INSERT INTO "lapTimes" VALUES ("1", "2", "1", "01:21.000");
INSERT INTO "lapTimes" VALUES ("2", "1", "1", "01:22.345");
INSERT INTO "lapTimes" VALUES ("2", "1", "2", "01:21.800");
INSERT INTO "lapTimes" VALUES ("3", "3", "1", "01:25.000");
INSERT INTO "lapTimes" VALUES ("4", "1", "1", "01:18.900");
INSERT INTO "lapTimes" VALUES ("4", "1", "2", "01:18.500");
INSERT INTO "lapTimes" VALUES ("5", "2", "1", "01:20.000");
INSERT INTO "lapTimes" VALUES ("5", "1", "1", "01:19.000");
INSERT INTO "circuits" VALUES ("1", "Silverstone Circuit");
INSERT INTO "circuits" VALUES ("2", "Monza Circuit");
INSERT INTO "circuits" VALUES ("3", "Circuit de Monaco");
INSERT INTO "circuits" VALUES ("4", "Spa-Francorchamps");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc");
INSERT INTO "drivers" VALUES ("4", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("5", "George", "Russell");
INSERT INTO "qualifying" VALUES ("1", "01:25.000");
INSERT INTO "qualifying" VALUES ("2", "01:24.500");
INSERT INTO "qualifying" VALUES ("3", "01:26.100");
INSERT INTO "qualifying" VALUES ("4", "01:23.900");
INSERT INTO "qualifying" VALUES ("5", "01:25.500");
INSERT INTO "races" VALUES ("1", "British Grand Prix");
INSERT INTO "races" VALUES ("2", "Italian Grand Prix");
INSERT INTO "races" VALUES ("3", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("4", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("5", "Japanese Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "01:19.500");
INSERT INTO "results" VALUES ("2", "1", "2", "01:20.500");
INSERT INTO "results" VALUES ("3", "2", "1", "01:21.800");
INSERT INTO "results" VALUES ("4", "2", "3", "01:22.000");
INSERT INTO "results" VALUES ("5", "3", "1", "01:23.000");
INSERT INTO "results" VALUES ("6", "3", "2", "01:23.500");
INSERT INTO "results" VALUES ("7", "4", "1", "01:18.500");
INSERT INTO "results" VALUES ("8", "4", "4", "01:19.000");
INSERT INTO "results" VALUES ("9", "5", "1", "01:19.000");
INSERT INTO "results" VALUES ("10", "5", "5", "01:19.200");