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,
"dob" DATE,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

CREATE TABLE "results" (
"resultId" INT,
"position" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "driverStandings" VALUES ("1", "150.5");
INSERT INTO "driverStandings" VALUES ("2", "120.0");
INSERT INTO "driverStandings" VALUES ("3", "180.75");
INSERT INTO "driverStandings" VALUES ("4", "95.25");
INSERT INTO "driverStandings" VALUES ("5", "110.0");
INSERT INTO "drivers" VALUES ("1", "1985-04-12", "Germany");
INSERT INTO "drivers" VALUES ("2", "1990-11-23", "Brazil");
INSERT INTO "drivers" VALUES ("3", "1978-07-30", "United Kingdom");
INSERT INTO "drivers" VALUES ("4", "1988-01-15", "Italy");
INSERT INTO "drivers" VALUES ("5", "1978-07-30", "Spain");
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", "3", "1", "88000");
INSERT INTO "lapTimes" VALUES ("101", "4", "1", "90500");
INSERT INTO "lapTimes" VALUES ("101", "5", "1", "88500");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "4");
INSERT INTO "results" VALUES ("5", "5");