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



INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton", "British");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen", "Dutch");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc", "Monegasque");
INSERT INTO "drivers" VALUES ("4", "Sergio", "Perez", "Mexican");
INSERT INTO "drivers" VALUES ("5", "Fernando", "Alonso", "Spanish");
INSERT INTO "drivers" VALUES ("6", "George", "Russell", "British");
INSERT INTO "drivers" VALUES ("7", "Carlos", "Sainz", "Spanish");
INSERT INTO "drivers" VALUES ("8", "Lando", "Norris", "British");
INSERT INTO "drivers" VALUES ("9", "Valtteri", "Bottas", "Finnish");
INSERT INTO "drivers" VALUES ("10", "Daniel", "Ricciardo", "Australian");
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", "200.500");
INSERT INTO "results" VALUES ("2", "1001", "2", "1", "201.250");
INSERT INTO "results" VALUES ("3", "1001", "3", "2", "200.900");
INSERT INTO "results" VALUES ("4", "1001", "4", "4", "199.800");
INSERT INTO "results" VALUES ("5", "1002", "2", "1", "205.100");
INSERT INTO "results" VALUES ("6", "1002", "1", "5", "204.950");
INSERT INTO "results" VALUES ("7", "1002", "3", "2", "204.800");
INSERT INTO "results" VALUES ("8", "1002", "5", "3", "204.700");
INSERT INTO "results" VALUES ("9", "1003", "3", "1", "202.300");
INSERT INTO "results" VALUES ("10", "1003", "6", "2", "202.100");
INSERT INTO "results" VALUES ("11", "1003", "7", "3", "201.900");
INSERT INTO "results" VALUES ("12", "1004", "2", "1", "206.000");
INSERT INTO "results" VALUES ("13", "1004", "4", "2", "205.800");
INSERT INTO "results" VALUES ("14", "1004", "8", "3", "205.500");
INSERT INTO "results" VALUES ("15", "1005", "1", "1", "203.700");
INSERT INTO "results" VALUES ("16", "1005", "2", "2", "203.500");
INSERT INTO "results" VALUES ("17", "1005", "9", "4", "203.000");
INSERT INTO "results" VALUES ("18", "1005", "10", "5", "202.800");