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,
"date" DATE,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"position" INT,
"points" FLOAT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "driverStandings" VALUES ("1", "44.0");
INSERT INTO "driverStandings" VALUES ("2", "25.0");
INSERT INTO "driverStandings" VALUES ("3", "18.0");
INSERT INTO "driverStandings" VALUES ("4", "15.0");
INSERT INTO "driverStandings" VALUES ("5", "12.0");
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 "drivers" VALUES ("5", "Lando", "Norris");
INSERT INTO "races" VALUES ("1", "2024-03-17");
INSERT INTO "races" VALUES ("2", "2024-03-24");
INSERT INTO "races" VALUES ("3", "2024-04-07");
INSERT INTO "races" VALUES ("4", "2024-04-21");
INSERT INTO "races" VALUES ("5", "2024-05-05");
INSERT INTO "results" VALUES ("1", "1", "1", "1", "25.0");
INSERT INTO "results" VALUES ("2", "1", "2", "2", "18.0");
INSERT INTO "results" VALUES ("3", "1", "3", "3", "15.0");
INSERT INTO "results" VALUES ("4", "2", "1", "2", "18.0");
INSERT INTO "results" VALUES ("5", "2", "4", "1", "25.0");
INSERT INTO "results" VALUES ("6", "2", "5", "3", "15.0");
INSERT INTO "results" VALUES ("7", "3", "1", "1", "25.0");
INSERT INTO "results" VALUES ("8", "3", "2", "3", "15.0");
INSERT INTO "results" VALUES ("9", "3", "4", "2", "18.0");
INSERT INTO "results" VALUES ("10", "4", "1", "4", "12.0");
INSERT INTO "results" VALUES ("11", "4", "3", "1", "25.0");
INSERT INTO "results" VALUES ("12", "4", "5", "2", "18.0");
INSERT INTO "results" VALUES ("13", "5", "2", "1", "25.0");
INSERT INTO "results" VALUES ("14", "5", "1", "3", "15.0");
INSERT INTO "results" VALUES ("15", "5", "4", "2", "18.0");