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 "driverStandings" (
"driverStandingsId" INT,
"points" FLOAT,
PRIMARY KEY ("driverStandingsId")
);

CREATE TABLE "lapTimes" (
"raceId" INT,
"driverId" INT,
"lap" INT,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "lap")
);

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"number" INT,
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,
PRIMARY KEY ("resultId")
);



INSERT INTO "driverStandings" VALUES ("1", "25.0");
INSERT INTO "driverStandings" VALUES ("2", "18.0");
INSERT INTO "driverStandings" VALUES ("3", "15.0");
INSERT INTO "driverStandings" VALUES ("4", "12.0");
INSERT INTO "driverStandings" VALUES ("5", "10.0");
INSERT INTO "lapTimes" VALUES ("1", "1", "1", "90000");
INSERT INTO "lapTimes" VALUES ("1", "2", "1", "91000");
INSERT INTO "lapTimes" VALUES ("2", "1", "1", "89000");
INSERT INTO "lapTimes" VALUES ("2", "3", "1", "92000");
INSERT INTO "lapTimes" VALUES ("903", "4", "1", "114000");
INSERT INTO "lapTimes" VALUES ("903", "5", "1", "115000");
INSERT INTO "drivers" VALUES ("1", "44");
INSERT INTO "drivers" VALUES ("2", "77");
INSERT INTO "drivers" VALUES ("3", "16");
INSERT INTO "drivers" VALUES ("4", "33");
INSERT INTO "drivers" VALUES ("5", "11");
INSERT INTO "drivers" VALUES ("6", "5");
INSERT INTO "qualifying" VALUES ("1", "1", "1", "1:25.000");
INSERT INTO "qualifying" VALUES ("2", "1", "2", "1:25.500");
INSERT INTO "qualifying" VALUES ("3", "2", "3", "1:26.000");
INSERT INTO "qualifying" VALUES ("4", "903", "4", "1:54.000");
INSERT INTO "qualifying" VALUES ("5", "903", "5", "1:54.500");
INSERT INTO "qualifying" VALUES ("6", "903", "6", "1:55.000");
INSERT INTO "races" VALUES ("1");
INSERT INTO "races" VALUES ("2");
INSERT INTO "races" VALUES ("903");
INSERT INTO "races" VALUES ("904");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "1");
INSERT INTO "results" VALUES ("5", "2");