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 "lapTimes" (
"raceId" INT,
"driverId" INT,
"lap" INT,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "lap")
);

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

CREATE TABLE "results" (
"resultId" INT,
"driverId" INT,
"position" INT,
"fastestLapSpeed" TEXT,
PRIMARY KEY ("resultId"),
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.7");
INSERT INTO "driverStandings" VALUES ("4", "75.3");
INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "German");
INSERT INTO "drivers" VALUES ("3", "Brazilian");
INSERT INTO "drivers" VALUES ("4", "Finnish");
INSERT INTO "results" VALUES ("1", "1", "1", "210.345");
INSERT INTO "results" VALUES ("2", "2", "2", "209.876");
INSERT INTO "results" VALUES ("3", "3", "3", "210.345");
INSERT INTO "results" VALUES ("4", "4", "4", "208.500");
INSERT INTO "lapTimes" VALUES ("101", "1", "1", "90000");
INSERT INTO "lapTimes" VALUES ("101", "1", "2", "89500");
INSERT INTO "lapTimes" VALUES ("101", "2", "1", "91000");
INSERT INTO "lapTimes" VALUES ("101", "2", "2", "90500");
INSERT INTO "lapTimes" VALUES ("101", "3", "1", "90000");
INSERT INTO "lapTimes" VALUES ("101", "3", "2", "89500");
INSERT INTO "lapTimes" VALUES ("101", "4", "1", "92000");
INSERT INTO "lapTimes" VALUES ("101", "4", "2", "91500");