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")
);

CREATE TABLE "circuits" (
"circuitId" INT UNIQUE,
"name" TEXT,
PRIMARY KEY ("circuitId")
);

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

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"circuitId" INT,
"name" TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);

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



INSERT INTO "circuits" VALUES ("1", "Bahrain International Circuit");
INSERT INTO "circuits" VALUES ("2", "Circuit de Barcelona-Catalunya");
INSERT INTO "circuits" VALUES ("3", "Monaco Grand Prix");
INSERT INTO "circuits" VALUES ("4", "Silverstone Circuit");
INSERT INTO "circuits" VALUES ("5", "Autodromo Nazionale Monza");
INSERT INTO "circuits" VALUES ("6", "Circuit de Spa-Francorchamps");
INSERT INTO "circuits" VALUES ("7", "Suzuka International Racing Course");
INSERT INTO "circuits" VALUES ("8", "Circuit of the Americas");
INSERT INTO "circuits" VALUES ("9", "Yas Marina Circuit");
INSERT INTO "circuits" VALUES ("10", "Albert Park Circuit");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull Racing");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Aston Martin");
INSERT INTO "races" VALUES ("1001", "1", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1002", "2", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("1003", "3", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("1004", "4", "British Grand Prix");
INSERT INTO "races" VALUES ("1005", "5", "Italian Grand Prix");
INSERT INTO "races" VALUES ("1006", "6", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("1007", "7", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("1008", "8", "United States Grand Prix");
INSERT INTO "races" VALUES ("1009", "9", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("1010", "10", "Australian Grand Prix");
INSERT INTO "lapTimes" VALUES ("1001", "1", "10", "1:32.000", "92000");
INSERT INTO "lapTimes" VALUES ("1001", "2", "15", "1:32.500", "92500");
INSERT INTO "lapTimes" VALUES ("1002", "1", "5", "1:18.000", "78000");
INSERT INTO "lapTimes" VALUES ("1002", "3", "8", "1:17.900", "77900");
INSERT INTO "lapTimes" VALUES ("1003", "4", "20", "1:14.000", "74000");
INSERT INTO "lapTimes" VALUES ("1003", "5", "22", "1:14.100", "74100");
INSERT INTO "lapTimes" VALUES ("1004", "1", "12", "1:27.000", "87000");
INSERT INTO "lapTimes" VALUES ("1004", "2", "18", "1:26.800", "86800");
INSERT INTO "lapTimes" VALUES ("1005", "3", "7", "1:21.000", "81000");
INSERT INTO "lapTimes" VALUES ("1005", "4", "9", "1:20.900", "80900");
INSERT INTO "lapTimes" VALUES ("1006", "5", "11", "1:46.000", "106000");
INSERT INTO "lapTimes" VALUES ("1006", "1", "14", "1:45.900", "105900");
INSERT INTO "lapTimes" VALUES ("1007", "2", "6", "1:30.000", "90000");
INSERT INTO "lapTimes" VALUES ("1007", "3", "10", "1:29.800", "89800");
INSERT INTO "lapTimes" VALUES ("1008", "4", "13", "1:35.000", "95000");
INSERT INTO "lapTimes" VALUES ("1008", "5", "16", "1:34.900", "94900");
INSERT INTO "lapTimes" VALUES ("1009", "1", "19", "1:26.000", "86000");
INSERT INTO "lapTimes" VALUES ("1009", "2", "21", "1:25.900", "85900");
INSERT INTO "lapTimes" VALUES ("1010", "3", "4", "1:23.000", "83000");
INSERT INTO "lapTimes" VALUES ("1010", "4", "6", "1:22.800", "82800");
INSERT INTO "results" VALUES ("1", "1", "5400000");
INSERT INTO "results" VALUES ("2", "2", "5401000");
INSERT INTO "results" VALUES ("3", "1", "4800000");
INSERT INTO "results" VALUES ("4", "2", "4800500");
INSERT INTO "results" VALUES ("5", "1", "4500000");
INSERT INTO "results" VALUES ("6", "2", "4500200");
INSERT INTO "results" VALUES ("7", "1", "5200000");
INSERT INTO "results" VALUES ("8", "2", "5200300");
INSERT INTO "results" VALUES ("9", "1", "4900000");
INSERT INTO "results" VALUES ("10", "2", "4900100");