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 "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
PRIMARY KEY ("driverId")
);

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

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

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"position" INT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "driverStandings" VALUES ("1", "120.5");
INSERT INTO "driverStandings" VALUES ("2", "98.0");
INSERT INTO "driverStandings" VALUES ("3", "75.3");
INSERT INTO "drivers" VALUES ("10", "Paul", "di Resta");
INSERT INTO "drivers" VALUES ("11", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("12", "Sebastian", "Vettel");
INSERT INTO "qualifying" VALUES ("100", "5");
INSERT INTO "qualifying" VALUES ("101", "1");
INSERT INTO "qualifying" VALUES ("102", "3");
INSERT INTO "races" VALUES ("853");
INSERT INTO "races" VALUES ("854");
INSERT INTO "races" VALUES ("855");
INSERT INTO "results" VALUES ("1000", "853", "10", "4", "1:25.345", "210.500", "1");
INSERT INTO "results" VALUES ("1001", "853", "11", "1", "1:24.900", "211.000", "1");
INSERT INTO "results" VALUES ("1002", "853", "12", "2", "1:25.100", "210.800", "1");
INSERT INTO "results" VALUES ("1003", "854", "10", "5", "1:26.000", "208.000", "1");
INSERT INTO "results" VALUES ("1004", "854", "11", "1", "1:24.500", "211.200", "1");
INSERT INTO "results" VALUES ("1005", "854", "12", "3", "1:25.500", "209.500", "1");
INSERT INTO "results" VALUES ("1006", "855", "10", "3", "1:25.000", "209.000", "1");
INSERT INTO "results" VALUES ("1007", "855", "11", "2", "1:24.700", "210.700", "1");
INSERT INTO "results" VALUES ("1008", "855", "12", "1", "1:24.300", "211.500", "1");