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 "driverStandings" (
"driverStandingsId" INT,
"points" FLOAT,
PRIMARY KEY ("driverStandingsId")
);

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

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"year" INT,
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 "driverStandings" VALUES ("1", "150.5");
INSERT INTO "driverStandings" VALUES ("2", "120.0");
INSERT INTO "driverStandings" VALUES ("3", "98.0");
INSERT INTO "driverStandings" VALUES ("4", "75.5");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("3", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("4", "Charles", "Leclerc");
INSERT INTO "races" VALUES ("1", "2023");
INSERT INTO "races" VALUES ("2", "2022");
INSERT INTO "races" VALUES ("3", "2021");
INSERT INTO "results" VALUES ("1", "1", "1", "1", "215.3");
INSERT INTO "results" VALUES ("2", "1", "2", "2", "217.8");
INSERT INTO "results" VALUES ("3", "1", "3", "3", "213.5");
INSERT INTO "results" VALUES ("4", "2", "2", "1", "214.0");
INSERT INTO "results" VALUES ("5", "2", "4", "2", "216.5");
INSERT INTO "results" VALUES ("6", "3", "3", "1", "212.0");
INSERT INTO "results" VALUES ("7", "3", "1", "2", "211.5");
INSERT INTO "results" VALUES ("8", "3", "4", "3", "210.0");