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 "races" (
"raceId" INT UNIQUE,
"year" INT,
"name" TEXT,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"position" INT,
"points" FLOAT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



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 "drivers" VALUES ("44", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("33", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("5", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("7", "Kimi", "Raikkonen");
INSERT INTO "races" VALUES ("101", "2007", "Australian Grand Prix");
INSERT INTO "races" VALUES ("102", "2007", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("103", "2008", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("104", "2009", "Australian Grand Prix");
INSERT INTO "results" VALUES ("1001", "101", "44", "3", "15.0");
INSERT INTO "results" VALUES ("1002", "102", "44", "1", "25.0");
INSERT INTO "results" VALUES ("1003", "101", "33", "1", "25.0");
INSERT INTO "results" VALUES ("1004", "101", "5", "2", "18.0");
INSERT INTO "results" VALUES ("1005", "101", "7", "4", "12.0");
INSERT INTO "results" VALUES ("1006", "103", "44", "2", "18.0");
INSERT INTO "results" VALUES ("1007", "104", "44", "5", "10.0");