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

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

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



INSERT INTO "drivers" VALUES ("1", "French");
INSERT INTO "drivers" VALUES ("2", "French");
INSERT INTO "drivers" VALUES ("3", "German");
INSERT INTO "drivers" VALUES ("4", "French");
INSERT INTO "drivers" VALUES ("5", "Italian");
INSERT INTO "drivers" VALUES ("6", "French");
INSERT INTO "drivers" VALUES ("7", "Spanish");
INSERT INTO "lapTimes" VALUES ("101", "1", "1", "01:59.500", "119500");
INSERT INTO "lapTimes" VALUES ("101", "1", "2", "02:01.000", "121000");
INSERT INTO "lapTimes" VALUES ("101", "2", "1", "01:58.999", "118999");
INSERT INTO "lapTimes" VALUES ("101", "2", "2", "02:00.001", "120001");
INSERT INTO "lapTimes" VALUES ("101", "3", "1", "01:59.999", "119999");
INSERT INTO "lapTimes" VALUES ("101", "4", "1", "02:05.000", "125000");
INSERT INTO "lapTimes" VALUES ("101", "4", "2", "01:59.000", "119000");
INSERT INTO "lapTimes" VALUES ("101", "5", "1", "01:57.000", "117000");
INSERT INTO "lapTimes" VALUES ("101", "6", "1", "02:00.000", "120000");
INSERT INTO "lapTimes" VALUES ("101", "6", "2", "01:59.999", "119999");
INSERT INTO "lapTimes" VALUES ("101", "7", "1", "01:55.000", "115000");
INSERT INTO "results" VALUES ("201", "1", "01:58.000", "118000");
INSERT INTO "results" VALUES ("202", "2", "02:01.000", "121000");
INSERT INTO "results" VALUES ("203", "3", "01:59.000", "119000");
INSERT INTO "results" VALUES ("204", "4", "02:05.000", "125000");
INSERT INTO "results" VALUES ("205", "5", "01:57.000", "117000");