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 "pitStops" (
"raceId" INT,
"driverId" INT,
"stop" INT,
"duration" TEXT,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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

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

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



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", "Nick", "Heidfeld", "1977-05-10", "German");
INSERT INTO "drivers" VALUES ("5", "Adrian", "Sutil", "1983-01-11", "German");
INSERT INTO "drivers" VALUES ("6", "Ralf", "Schumacher", "1975-06-30", "German");
INSERT INTO "drivers" VALUES ("7", "Lewis", "Hamilton", "1985-01-07", "British");
INSERT INTO "drivers" VALUES ("8", "Fernando", "Alonso", "1981-07-29", "Spanish");
INSERT INTO "drivers" VALUES ("9", "Kimi", "Raikkonen", "1979-10-17", "Finnish");
INSERT INTO "drivers" VALUES ("10", "Max", "Verstappen", "1997-09-30", "Dutch");
INSERT INTO "drivers" VALUES ("11", "Pascal", "Wehrlein", "1994-10-18", "German");
INSERT INTO "drivers" VALUES ("12", "Nico", "Hulkenberg", "1987-08-19", "German");
INSERT INTO "races" VALUES ("1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("3", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("4", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("5", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("6", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("7", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("8", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("9", "British Grand Prix");
INSERT INTO "races" VALUES ("10", "Hungarian Grand Prix");
INSERT INTO "pitStops" VALUES ("1", "1", "1", "23.500", "23500");
INSERT INTO "pitStops" VALUES ("1", "2", "1", "22.800", "22800");
INSERT INTO "pitStops" VALUES ("1", "5", "1", "24.100", "24100");
INSERT INTO "pitStops" VALUES ("2", "1", "1", "22.900", "22900");
INSERT INTO "pitStops" VALUES ("2", "2", "1", "23.100", "23100");
INSERT INTO "pitStops" VALUES ("2", "5", "1", "23.800", "23800");
INSERT INTO "pitStops" VALUES ("3", "1", "1", "23.000", "23000");
INSERT INTO "pitStops" VALUES ("3", "2", "1", "22.900", "22900");
INSERT INTO "pitStops" VALUES ("3", "5", "1", "23.500", "23500");
INSERT INTO "pitStops" VALUES ("4", "1", "1", "23.200", "23200");
INSERT INTO "pitStops" VALUES ("4", "2", "1", "22.700", "22700");
INSERT INTO "pitStops" VALUES ("4", "5", "1", "23.900", "23900");
INSERT INTO "pitStops" VALUES ("5", "1", "1", "23.100", "23100");
INSERT INTO "pitStops" VALUES ("5", "2", "1", "22.600", "22600");
INSERT INTO "pitStops" VALUES ("5", "5", "1", "23.700", "23700");
INSERT INTO "pitStops" VALUES ("1", "7", "1", "22.500", "22500");
INSERT INTO "pitStops" VALUES ("1", "8", "1", "23.000", "23000");
INSERT INTO "pitStops" VALUES ("1", "9", "1", "23.300", "23300");
INSERT INTO "pitStops" VALUES ("2", "7", "1", "22.600", "22600");
INSERT INTO "pitStops" VALUES ("2", "8", "1", "22.900", "22900");
INSERT INTO "pitStops" VALUES ("2", "9", "1", "23.200", "23200");
INSERT INTO "pitStops" VALUES ("3", "7", "1", "22.700", "22700");
INSERT INTO "pitStops" VALUES ("3", "8", "1", "22.800", "22800");
INSERT INTO "pitStops" VALUES ("3", "9", "1", "23.100", "23100");
INSERT INTO "pitStops" VALUES ("4", "7", "1", "22.800", "22800");
INSERT INTO "pitStops" VALUES ("4", "8", "1", "22.700", "22700");
INSERT INTO "pitStops" VALUES ("4", "9", "1", "23.000", "23000");
INSERT INTO "pitStops" VALUES ("5", "7", "1", "22.900", "22900");
INSERT INTO "pitStops" VALUES ("5", "8", "1", "22.600", "22600");
INSERT INTO "pitStops" VALUES ("5", "9", "1", "22.900", "22900");
INSERT INTO "pitStops" VALUES ("1", "11", "1", "24.000", "24000");
INSERT INTO "pitStops" VALUES ("1", "12", "1", "23.500", "23500");
INSERT INTO "pitStops" VALUES ("2", "11", "1", "24.100", "24100");
INSERT INTO "pitStops" VALUES ("2", "12", "1", "23.600", "23600");
INSERT INTO "results" VALUES ("1", "1:30:00", "5400000");
INSERT INTO "results" VALUES ("2", "1:31:00", "5460000");
INSERT INTO "results" VALUES ("3", "1:32:00", "5520000");
INSERT INTO "results" VALUES ("4", "1:33:00", "5580000");
INSERT INTO "results" VALUES ("5", "1:34:00", "5640000");