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 "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
PRIMARY KEY ("driverId")
);

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

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



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", "Sergio", "Perez");
INSERT INTO "drivers" VALUES ("5", "George", "Russell");
INSERT INTO "drivers" VALUES ("6", "Carlos", "Sainz");
INSERT INTO "drivers" VALUES ("7", "Lando", "Norris");
INSERT INTO "drivers" VALUES ("8", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("9", "Valtteri", "Bottas");
INSERT INTO "drivers" VALUES ("10", "Daniel", "Ricciardo");
INSERT INTO "races" VALUES ("1001", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1002", "Saudi Arabian Grand Prix");
INSERT INTO "races" VALUES ("1003", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1004", "Emilia Romagna Grand Prix");
INSERT INTO "races" VALUES ("1005", "Miami Grand Prix");
INSERT INTO "results" VALUES ("1", "1001", "1", "3", "1:34.567", "205.123");
INSERT INTO "results" VALUES ("2", "1001", "2", "1", "1:33.987", "206.543");
INSERT INTO "results" VALUES ("3", "1001", "3", "2", "1:34.123", "206.210");
INSERT INTO "results" VALUES ("4", "1001", "4", "4", "1:34.800", "204.800");
INSERT INTO "results" VALUES ("5", "1002", "2", "1", "1:31.234", "250.123");
INSERT INTO "results" VALUES ("6", "1002", "1", "10", "1:32.000", "248.000");
INSERT INTO "results" VALUES ("7", "1002", "3", "2", "1:31.500", "249.500");
INSERT INTO "results" VALUES ("8", "1003", "5", "3", "1:20.100", "230.100");
INSERT INTO "results" VALUES ("9", "1003", "6", "4", "1:20.500", "229.500");
INSERT INTO "results" VALUES ("10", "1004", "7", "5", "1:18.999", "240.000");
INSERT INTO "results" VALUES ("11", "1004", "8", "6", "1:19.001", "239.990");
INSERT INTO "results" VALUES ("12", "1005", "9", "7", "1:30.000", "210.000");
INSERT INTO "results" VALUES ("13", "1005", "10", "8", "1:30.500", "209.500");
INSERT INTO "results" VALUES ("14", "1001", "5", "5", "1:35.000", "204.500");
INSERT INTO "results" VALUES ("15", "1002", "4", "3", "1:31.300", "250.000");