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

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

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



INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "German");
INSERT INTO "drivers" VALUES ("3", "Spanish");
INSERT INTO "drivers" VALUES ("4", "Finnish");
INSERT INTO "drivers" VALUES ("5", "Brazilian");
INSERT INTO "drivers" VALUES ("6", "Australian");
INSERT INTO "drivers" VALUES ("7", "French");
INSERT INTO "drivers" VALUES ("8", "Italian");
INSERT INTO "drivers" VALUES ("9", "Dutch");
INSERT INTO "drivers" VALUES ("10", "Mexican");
INSERT INTO "races" VALUES ("17", "2022");
INSERT INTO "races" VALUES ("18", "2023");
INSERT INTO "races" VALUES ("19", "2023");
INSERT INTO "results" VALUES ("101", "18", "1", "11");
INSERT INTO "results" VALUES ("102", "18", "2", "12");
INSERT INTO "results" VALUES ("103", "18", "3", "13");
INSERT INTO "results" VALUES ("104", "18", "4", "14");
INSERT INTO "results" VALUES ("105", "18", "5", "15");
INSERT INTO "results" VALUES ("106", "18", "6", "11");
INSERT INTO "results" VALUES ("107", "18", "7", "12");
INSERT INTO "results" VALUES ("108", "18", "8", "13");
INSERT INTO "results" VALUES ("109", "18", "9", "14");
INSERT INTO "results" VALUES ("110", "18", "10", "15");
INSERT INTO "results" VALUES ("111", "17", "1", "11");
INSERT INTO "results" VALUES ("112", "17", "2", "12");
INSERT INTO "results" VALUES ("113", "19", "3", "13");
INSERT INTO "results" VALUES ("114", "19", "4", "14");