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,
"nationality" 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", "British");
INSERT INTO "drivers" VALUES ("2", "Sebastian", "Vettel", "German");
INSERT INTO "drivers" VALUES ("3", "Max", "Verstappen", "Dutch");
INSERT INTO "drivers" VALUES ("4", "Valtteri", "Bottas", "Finnish");
INSERT INTO "drivers" VALUES ("5", "Charles", "Leclerc", "Monegasque");
INSERT INTO "races" VALUES ("101", "2018", "Turkish Grand Prix");
INSERT INTO "races" VALUES ("102", "2019", "Turkish Grand Prix");
INSERT INTO "races" VALUES ("103", "2020", "Turkish Grand Prix");
INSERT INTO "races" VALUES ("104", "2021", "Turkish Grand Prix");
INSERT INTO "races" VALUES ("105", "2019", "British Grand Prix");
INSERT INTO "races" VALUES ("106", "2020", "Monaco Grand Prix");
INSERT INTO "results" VALUES ("1001", "101", "1", "1", "25.0");
INSERT INTO "results" VALUES ("1002", "101", "2", "2", "18.0");
INSERT INTO "results" VALUES ("1003", "101", "3", "3", "15.0");
INSERT INTO "results" VALUES ("1004", "102", "1", "2", "18.0");
INSERT INTO "results" VALUES ("1005", "102", "4", "1", "25.0");
INSERT INTO "results" VALUES ("1006", "102", "3", "3", "15.0");
INSERT INTO "results" VALUES ("1007", "103", "1", "5", "10.0");
INSERT INTO "results" VALUES ("1008", "103", "5", "1", "25.0");
INSERT INTO "results" VALUES ("1009", "103", "3", "2", "18.0");
INSERT INTO "results" VALUES ("1010", "104", "1", "3", "15.0");
INSERT INTO "results" VALUES ("1011", "104", "2", "1", "25.0");
INSERT INTO "results" VALUES ("1012", "104", "4", "2", "18.0");
INSERT INTO "results" VALUES ("1013", "105", "1", "1", "25.0");
INSERT INTO "results" VALUES ("1014", "105", "3", "2", "18.0");
INSERT INTO "results" VALUES ("1015", "106", "2", "1", "25.0");
INSERT INTO "results" VALUES ("1016", "106", "5", "2", "18.0");