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

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"position" INT,
"fastestLapTime" 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.0");
INSERT INTO "driverStandings" VALUES ("4", "75.0");
INSERT INTO "driverStandings" VALUES ("5", "60.0");
INSERT INTO "driverStandings" VALUES ("6", "45.0");
INSERT INTO "driverStandings" VALUES ("7", "30.0");
INSERT INTO "driverStandings" VALUES ("8", "15.0");
INSERT INTO "drivers" VALUES ("101", "HAM", "1971-05-15");
INSERT INTO "drivers" VALUES ("102", "VET", "1971-11-20");
INSERT INTO "drivers" VALUES ("103", "ALO", "1971-07-29");
INSERT INTO "drivers" VALUES ("104", "RAI", "1970-12-13");
INSERT INTO "drivers" VALUES ("105", "SCH", "1971-03-02");
INSERT INTO "drivers" VALUES ("106", "BOT", "1989-01-06");
INSERT INTO "drivers" VALUES ("107", "VER", "1994-09-30");
INSERT INTO "drivers" VALUES ("108", "GAS", "1996-09-14");
INSERT INTO "results" VALUES ("201", "301", "101", "1", "1:20.345");
INSERT INTO "results" VALUES ("202", "301", "102", "2", "1:20.345");
INSERT INTO "results" VALUES ("203", "301", "103", "3", "NULL");
INSERT INTO "results" VALUES ("204", "302", "105", "1", "1:19.999");
INSERT INTO "results" VALUES ("205", "302", "104", "2", "NULL");
INSERT INTO "results" VALUES ("206", "303", "106", "1", "1:21.000");
INSERT INTO "results" VALUES ("207", "303", "107", "2", "NULL");
INSERT INTO "results" VALUES ("208", "304", "108", "1", "NULL");
INSERT INTO "results" VALUES ("209", "304", "101", "2", "NULL");
INSERT INTO "results" VALUES ("210", "305", "102", "1", "1:18.500");
INSERT INTO "results" VALUES ("211", "305", "103", "2", "NULL");
INSERT INTO "results" VALUES ("212", "305", "105", "3", "NULL");
INSERT INTO "lapTimes" VALUES ("301", "101", "1", "80450");
INSERT INTO "lapTimes" VALUES ("301", "101", "2", "80345");
INSERT INTO "lapTimes" VALUES ("301", "102", "1", "80450");
INSERT INTO "lapTimes" VALUES ("301", "102", "2", "80345");
INSERT INTO "lapTimes" VALUES ("301", "103", "1", "81000");
INSERT INTO "lapTimes" VALUES ("302", "105", "1", "79999");
INSERT INTO "lapTimes" VALUES ("302", "104", "1", "80500");
INSERT INTO "lapTimes" VALUES ("303", "106", "1", "81000");
INSERT INTO "lapTimes" VALUES ("303", "107", "1", "81500");
INSERT INTO "lapTimes" VALUES ("304", "108", "1", "82000");
INSERT INTO "lapTimes" VALUES ("304", "101", "1", "82500");
INSERT INTO "lapTimes" VALUES ("305", "102", "1", "78500");
INSERT INTO "lapTimes" VALUES ("305", "103", "1", "79000");
INSERT INTO "lapTimes" VALUES ("305", "105", "1", "79500");