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,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

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

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



INSERT INTO "driverStandings" VALUES ("1", "150.5");
INSERT INTO "driverStandings" VALUES ("2", "120.0");
INSERT INTO "driverStandings" VALUES ("3", "98.0");
INSERT INTO "driverStandings" VALUES ("4", "75.0");
INSERT INTO "drivers" VALUES ("101", "Germany");
INSERT INTO "drivers" VALUES ("102", "United Kingdom");
INSERT INTO "drivers" VALUES ("103", "Brazil");
INSERT INTO "drivers" VALUES ("104", "Italy");
INSERT INTO "qualifying" VALUES ("201", "1");
INSERT INTO "qualifying" VALUES ("202", "2");
INSERT INTO "qualifying" VALUES ("203", "3");
INSERT INTO "qualifying" VALUES ("204", "4");
INSERT INTO "results" VALUES ("301", "933", "101", "210.5");
INSERT INTO "results" VALUES ("302", "933", "102", "212.3");
INSERT INTO "results" VALUES ("303", "933", "103", "209.8");
INSERT INTO "results" VALUES ("304", "933", "104", "211.0");
INSERT INTO "lapTimes" VALUES ("933", "101", "1", "90000");
INSERT INTO "lapTimes" VALUES ("933", "101", "2", "89500");
INSERT INTO "lapTimes" VALUES ("933", "102", "1", "89000");
INSERT INTO "lapTimes" VALUES ("933", "102", "2", "88500");
INSERT INTO "lapTimes" VALUES ("933", "103", "1", "91000");
INSERT INTO "lapTimes" VALUES ("933", "103", "2", "90500");
INSERT INTO "lapTimes" VALUES ("933", "104", "1", "89500");
INSERT INTO "lapTimes" VALUES ("933", "104", "2", "89000");