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 "constructorResults" (
"constructorResultsId" INT,
"constructorId" INT,
PRIMARY KEY ("constructorResultsId")
);

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"code" TEXT,
PRIMARY KEY ("driverId")
);

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

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

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



INSERT INTO "constructorResults" VALUES ("1", "1");
INSERT INTO "constructorResults" VALUES ("2", "2");
INSERT INTO "constructorResults" VALUES ("3", "3");
INSERT INTO "constructorResults" VALUES ("4", "4");
INSERT INTO "constructorResults" VALUES ("5", "5");
INSERT INTO "drivers" VALUES ("1", "HAM");
INSERT INTO "drivers" VALUES ("2", "BOT");
INSERT INTO "drivers" VALUES ("3", "VET");
INSERT INTO "drivers" VALUES ("4", "LEC");
INSERT INTO "drivers" VALUES ("5", "VER");
INSERT INTO "drivers" VALUES ("6", "RIC");
INSERT INTO "drivers" VALUES ("7", "NOR");
INSERT INTO "drivers" VALUES ("8", "SAI");
INSERT INTO "drivers" VALUES ("9", "PER");
INSERT INTO "drivers" VALUES ("10", "GAS");
INSERT INTO "qualifying" VALUES ("1", "45", "1", "0:01:33.123");
INSERT INTO "qualifying" VALUES ("2", "45", "2", "0:01:34.567");
INSERT INTO "qualifying" VALUES ("3", "46", "3", "0:01:33.890");
INSERT INTO "qualifying" VALUES ("4", "45", "4", "0:01:33.000");
INSERT INTO "qualifying" VALUES ("5", "47", "5", "0:01:35.111");
INSERT INTO "qualifying" VALUES ("6", "45", "6", "0:01:33.999");
INSERT INTO "qualifying" VALUES ("7", "45", "7", "0:01:36.000");
INSERT INTO "qualifying" VALUES ("8", "48", "8", "0:01:33.456");
INSERT INTO "qualifying" VALUES ("9", "45", "9", "0:01:33.789");
INSERT INTO "qualifying" VALUES ("10", "45", "10", "0:01:33.222");
INSERT INTO "races" VALUES ("45");
INSERT INTO "races" VALUES ("46");
INSERT INTO "races" VALUES ("47");
INSERT INTO "races" VALUES ("48");
INSERT INTO "races" VALUES ("49");
INSERT INTO "results" VALUES ("1", "1", "1:30:00.000");
INSERT INTO "results" VALUES ("2", "2", "1:30:05.000");
INSERT INTO "results" VALUES ("3", "3", "1:30:10.000");
INSERT INTO "results" VALUES ("4", "4", "1:30:15.000");
INSERT INTO "results" VALUES ("5", "5", "1:30:20.000");