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,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "stop"),
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,
PRIMARY KEY ("driverId")
);

CREATE TABLE "qualifying" (
"qualifyId" INT,
"position" INT,
PRIMARY KEY ("qualifyId")
);

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



INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc");
INSERT INTO "drivers" VALUES ("4", "Sergio", "Perez");
INSERT INTO "drivers" VALUES ("5", "George", "Russell");
INSERT INTO "drivers" VALUES ("6", "Carlos", "Sainz");
INSERT INTO "pitStops" VALUES ("1", "1", "1", "25000");
INSERT INTO "pitStops" VALUES ("1", "1", "2", "23000");
INSERT INTO "pitStops" VALUES ("1", "2", "1", "22000");
INSERT INTO "pitStops" VALUES ("2", "1", "1", "24500");
INSERT INTO "pitStops" VALUES ("2", "1", "2", "26000");
INSERT INTO "pitStops" VALUES ("2", "3", "1", "23500");
INSERT INTO "pitStops" VALUES ("3", "1", "1", "23000");
INSERT INTO "pitStops" VALUES ("3", "4", "1", "24000");
INSERT INTO "pitStops" VALUES ("4", "1", "1", "25500");
INSERT INTO "pitStops" VALUES ("4", "1", "2", "24000");
INSERT INTO "pitStops" VALUES ("5", "2", "1", "22500");
INSERT INTO "pitStops" VALUES ("5", "1", "1", "23500");
INSERT INTO "pitStops" VALUES ("6", "1", "1", "24000");
INSERT INTO "pitStops" VALUES ("6", "1", "2", "25000");
INSERT INTO "pitStops" VALUES ("7", "1", "1", "23000");
INSERT INTO "pitStops" VALUES ("7", "1", "2", "24000");
INSERT INTO "pitStops" VALUES ("8", "1", "1", "25000");
INSERT INTO "pitStops" VALUES ("8", "1", "2", "23000");
INSERT INTO "pitStops" VALUES ("9", "1", "1", "24500");
INSERT INTO "pitStops" VALUES ("9", "1", "2", "26000");
INSERT INTO "pitStops" VALUES ("10", "1", "1", "23000");
INSERT INTO "pitStops" VALUES ("10", "1", "2", "24000");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull Racing");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "qualifying" VALUES ("1", "1");
INSERT INTO "qualifying" VALUES ("2", "2");
INSERT INTO "qualifying" VALUES ("3", "3");
INSERT INTO "results" VALUES ("1", "5400000");
INSERT INTO "results" VALUES ("2", "5405000");
INSERT INTO "results" VALUES ("3", "5410000");