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,
"driverId" INT,
"position" INT,
PRIMARY KEY ("driverStandingsId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

CREATE TABLE "lapTimes" (
"raceId" INT,
"driverId" INT,
"lap" INT,
PRIMARY KEY ("raceId", "driverId", "lap"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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



INSERT INTO "drivers" VALUES ("1", "Hamilton", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "vettel", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("3", "verstappen", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("4", "bottas", "Valtteri", "Bottas");
INSERT INTO "drivers" VALUES ("5", "ricciardo", "Daniel", "Ricciardo");
INSERT INTO "driverStandings" VALUES ("101", "1", "1");
INSERT INTO "driverStandings" VALUES ("102", "2", "2");
INSERT INTO "driverStandings" VALUES ("103", "3", "3");
INSERT INTO "driverStandings" VALUES ("104", "4", "4");
INSERT INTO "driverStandings" VALUES ("105", "5", "5");
INSERT INTO "lapTimes" VALUES ("201", "1", "1");
INSERT INTO "lapTimes" VALUES ("201", "1", "2");
INSERT INTO "lapTimes" VALUES ("201", "2", "1");
INSERT INTO "lapTimes" VALUES ("201", "3", "1");
INSERT INTO "lapTimes" VALUES ("201", "4", "1");
INSERT INTO "lapTimes" VALUES ("201", "5", "1");
INSERT INTO "lapTimes" VALUES ("202", "1", "1");
INSERT INTO "lapTimes" VALUES ("202", "2", "1");
INSERT INTO "lapTimes" VALUES ("202", "3", "1");
INSERT INTO "lapTimes" VALUES ("202", "4", "1");
INSERT INTO "lapTimes" VALUES ("202", "5", "1");