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

CREATE TABLE "races" (
"raceId" INT UNIQUE,
PRIMARY KEY ("raceId")
);

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



INSERT INTO "races" VALUES ("1");
INSERT INTO "races" VALUES ("2");
INSERT INTO "races" VALUES ("3");
INSERT INTO "lapTimes" VALUES ("1", "101", "1", "1", "75000");
INSERT INTO "lapTimes" VALUES ("1", "102", "1", "2", "75500");
INSERT INTO "lapTimes" VALUES ("1", "103", "1", "3", "76000");
INSERT INTO "lapTimes" VALUES ("1", "101", "2", "1", "74000");
INSERT INTO "lapTimes" VALUES ("1", "102", "2", "2", "74500");
INSERT INTO "lapTimes" VALUES ("2", "201", "1", "1", "74000");
INSERT INTO "lapTimes" VALUES ("2", "202", "1", "2", "74500");
INSERT INTO "lapTimes" VALUES ("2", "203", "1", "3", "75000");
INSERT INTO "lapTimes" VALUES ("2", "201", "2", "1", "73500");
INSERT INTO "lapTimes" VALUES ("2", "202", "2", "2", "74000");
INSERT INTO "lapTimes" VALUES ("3", "301", "1", "1", "76000");
INSERT INTO "lapTimes" VALUES ("3", "302", "1", "2", "76500");
INSERT INTO "lapTimes" VALUES ("3", "303", "1", "3", "77000");
INSERT INTO "results" VALUES ("1", "1", "7200000");
INSERT INTO "results" VALUES ("2", "2", "7220000");
INSERT INTO "results" VALUES ("3", "3", "7250000");