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 ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

CREATE TABLE "constructors" (
"constructorId" INT,
"name" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
"dob" DATE,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

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

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



INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Aston Martin");
INSERT INTO "drivers" VALUES ("1", "Sebastian", "Vettel", "1987-07-03", "German");
INSERT INTO "drivers" VALUES ("2", "Nico", "Rosberg", "1985-06-27", "German");
INSERT INTO "drivers" VALUES ("3", "Michael", "Schumacher", "1969-01-03", "German");
INSERT INTO "drivers" VALUES ("4", "Lewis", "Hamilton", "1985-01-07", "British");
INSERT INTO "drivers" VALUES ("5", "Max", "Verstappen", "1997-09-30", "Dutch");
INSERT INTO "drivers" VALUES ("6", "Mick", "Schumacher", "1999-03-22", "German");
INSERT INTO "drivers" VALUES ("7", "Ralf", "Schumacher", "1975-06-30", "German");
INSERT INTO "drivers" VALUES ("8", "Nick", "Heidfeld", "1977-05-10", "German");
INSERT INTO "drivers" VALUES ("9", "Adrian", "Sutil", "1983-01-11", "German");
INSERT INTO "drivers" VALUES ("10", "Pascal", "Wehrlein", "1994-10-18", "German");
INSERT INTO "races" VALUES ("1", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("2", "British Grand Prix");
INSERT INTO "races" VALUES ("3", "German Grand Prix");
INSERT INTO "races" VALUES ("4", "Italian Grand Prix");
INSERT INTO "races" VALUES ("5", "Japanese Grand Prix");
INSERT INTO "lapTimes" VALUES ("1", "1", "1", "0:01:15.234", "75234");
INSERT INTO "lapTimes" VALUES ("1", "1", "2", "0:01:14.987", "74987");
INSERT INTO "lapTimes" VALUES ("1", "2", "1", "0:01:15.100", "75100");
INSERT INTO "lapTimes" VALUES ("1", "2", "2", "0:01:14.800", "74800");
INSERT INTO "lapTimes" VALUES ("1", "3", "1", "0:01:16.500", "76500");
INSERT INTO "lapTimes" VALUES ("1", "4", "1", "0:01:14.500", "74500");
INSERT INTO "lapTimes" VALUES ("1", "5", "1", "0:01:14.700", "74700");
INSERT INTO "lapTimes" VALUES ("2", "1", "1", "0:01:20.123", "80123");
INSERT INTO "lapTimes" VALUES ("2", "2", "1", "0:01:20.000", "80000");
INSERT INTO "lapTimes" VALUES ("2", "9", "1", "0:01:21.000", "81000");
INSERT INTO "lapTimes" VALUES ("3", "1", "1", "0:01:18.500", "78500");
INSERT INTO "lapTimes" VALUES ("3", "2", "1", "0:01:18.200", "78200");
INSERT INTO "lapTimes" VALUES ("3", "8", "1", "0:01:19.000", "79000");
INSERT INTO "lapTimes" VALUES ("4", "1", "1", "0:01:25.000", "85000");
INSERT INTO "lapTimes" VALUES ("4", "2", "1", "0:01:24.800", "84800");
INSERT INTO "lapTimes" VALUES ("4", "9", "1", "0:01:25.500", "85500");
INSERT INTO "lapTimes" VALUES ("5", "1", "1", "0:01:30.000", "90000");
INSERT INTO "lapTimes" VALUES ("5", "2", "1", "0:01:29.500", "89500");
INSERT INTO "lapTimes" VALUES ("5", "8", "1", "0:01:30.500", "90500");
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");