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 "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 "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("3", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("4", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("5", "Kimi", "Raikkonen");
INSERT INTO "races" VALUES ("101", "2009", "Australian Grand Prix");
INSERT INTO "races" VALUES ("102", "2010", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("103", "2011", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("104", "2012", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("105", "2013", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("106", "2014", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("107", "2015", "British Grand Prix");
INSERT INTO "races" VALUES ("108", "2016", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("109", "2017", "Italian Grand Prix");
INSERT INTO "races" VALUES ("110", "2018", "Singapore Grand Prix");
INSERT INTO "races" VALUES ("111", "2019", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("112", "2020", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("113", "2021", "Monza Grand Prix");
INSERT INTO "results" VALUES ("1", "102", "1", "1", "25.0");
INSERT INTO "results" VALUES ("2", "103", "1", "2", "18.0");
INSERT INTO "results" VALUES ("3", "104", "1", "1", "25.0");
INSERT INTO "results" VALUES ("4", "105", "1", "3", "15.0");
INSERT INTO "results" VALUES ("5", "106", "1", "1", "25.0");
INSERT INTO "results" VALUES ("6", "107", "1", "4", "12.0");
INSERT INTO "results" VALUES ("7", "108", "1", "1", "25.0");
INSERT INTO "results" VALUES ("8", "109", "1", "5", "10.0");
INSERT INTO "results" VALUES ("9", "110", "1", "1", "25.0");
INSERT INTO "results" VALUES ("10", "111", "1", "2", "18.0");
INSERT INTO "results" VALUES ("11", "112", "1", "1", "25.0");
INSERT INTO "results" VALUES ("12", "113", "1", "3", "15.0");
INSERT INTO "results" VALUES ("13", "102", "2", "2", "18.0");
INSERT INTO "results" VALUES ("14", "103", "2", "1", "25.0");
INSERT INTO "results" VALUES ("15", "104", "3", "2", "18.0");
INSERT INTO "results" VALUES ("16", "105", "3", "1", "25.0");
INSERT INTO "results" VALUES ("17", "106", "4", "3", "15.0");
INSERT INTO "results" VALUES ("18", "107", "4", "1", "25.0");
INSERT INTO "results" VALUES ("19", "108", "5", "2", "18.0");
INSERT INTO "results" VALUES ("20", "109", "5", "1", "25.0");
INSERT INTO "results" VALUES ("21", "110", "2", "3", "15.0");
INSERT INTO "results" VALUES ("22", "111", "3", "1", "25.0");
INSERT INTO "results" VALUES ("23", "112", "4", "2", "18.0");
INSERT INTO "results" VALUES ("24", "113", "5", "1", "25.0");