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

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"points" FLOAT,
"fastestLapTime" 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", "130.0");
INSERT INTO "driverStandings" VALUES ("4", "110.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 "races" VALUES ("1", "2024-03-17");
INSERT INTO "races" VALUES ("2", "2024-04-07");
INSERT INTO "races" VALUES ("3", "2024-04-21");
INSERT INTO "results" VALUES ("1", "1", "1", "25.0", "1:30.456");
INSERT INTO "results" VALUES ("2", "1", "2", "18.0", "1:30.123");
INSERT INTO "results" VALUES ("3", "1", "3", "15.0", "1:31.000");
INSERT INTO "results" VALUES ("4", "2", "1", "18.0", "1:29.999");
INSERT INTO "results" VALUES ("5", "2", "2", "25.0", "1:30.500");
INSERT INTO "results" VALUES ("6", "2", "4", "15.0", "1:29.998");
INSERT INTO "results" VALUES ("7", "3", "3", "25.0", "1:30.200");
INSERT INTO "results" VALUES ("8", "3", "4", "18.0", "1:30.300");
INSERT INTO "results" VALUES ("9", "3", "1", "15.0", "1:30.400");