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 "drivers" (
"driverId" INT UNIQUE,
"driverRef" TEXT,
"dob" DATE,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

CREATE TABLE "qualifying" (
"qualifyId" INT,
"raceId" INT,
"driverId" INT,
"q2" TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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



INSERT INTO "drivers" VALUES ("1", "hamilton", "1985-01-07", "British");
INSERT INTO "drivers" VALUES ("2", "vettel", "1987-07-03", "German");
INSERT INTO "drivers" VALUES ("3", "alonso", "1981-07-29", "Spanish");
INSERT INTO "drivers" VALUES ("4", "ricciardo", "1989-07-01", "Australian");
INSERT INTO "drivers" VALUES ("5", "verstappen", "1997-09-30", "Dutch");
INSERT INTO "drivers" VALUES ("6", "bottas", "1989-08-28", "Finnish");
INSERT INTO "drivers" VALUES ("7", "leclerc", "1997-10-16", "Monegasque");
INSERT INTO "drivers" VALUES ("8", "sainz", "1994-09-01", "Spanish");
INSERT INTO "drivers" VALUES ("9", "norris", "1999-11-13", "British");
INSERT INTO "drivers" VALUES ("10", "perez", "1990-01-26", "Mexican");
INSERT INTO "qualifying" VALUES ("1", "23", "1", "1:25.000");
INSERT INTO "qualifying" VALUES ("2", "23", "2", "1:25.100");
INSERT INTO "qualifying" VALUES ("3", "23", "3", "NULL");
INSERT INTO "qualifying" VALUES ("4", "23", "4", "1:25.200");
INSERT INTO "qualifying" VALUES ("5", "23", "5", "1:25.300");
INSERT INTO "qualifying" VALUES ("6", "23", "6", "NULL");
INSERT INTO "qualifying" VALUES ("7", "24", "1", "1:24.500");
INSERT INTO "qualifying" VALUES ("8", "24", "2", "1:24.600");
INSERT INTO "qualifying" VALUES ("9", "25", "7", "1:26.000");
INSERT INTO "qualifying" VALUES ("10", "25", "8", "NULL");
INSERT INTO "results" VALUES ("1", "1", "1:30:00.000", "5400000");
INSERT INTO "results" VALUES ("2", "2", "1:30:01.000", "5401000");
INSERT INTO "results" VALUES ("3", "3", "1:30:02.000", "5402000");
INSERT INTO "results" VALUES ("4", "4", "1:30:03.000", "5403000");
INSERT INTO "results" VALUES ("5", "5", "1:30:04.000", "5404000");
INSERT INTO "results" VALUES ("6", "6", "1:30:05.000", "5405000");
INSERT INTO "results" VALUES ("7", "7", "1:30:06.000", "5406000");
INSERT INTO "results" VALUES ("8", "8", "1:30:07.000", "5407000");
INSERT INTO "results" VALUES ("9", "9", "1:30:08.000", "5408000");
INSERT INTO "results" VALUES ("10", "10", "1:30:09.000", "5409000");