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

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



INSERT INTO "races" VALUES ("1", "Australian Grand Prix", "2023-03-19");
INSERT INTO "races" VALUES ("2", "Bahrain Grand Prix", "2023-03-26");
INSERT INTO "races" VALUES ("3", "Monaco Grand Prix", "2023-05-28");
INSERT INTO "races" VALUES ("4", "British Grand Prix", "2023-07-09");
INSERT INTO "races" VALUES ("5", "Italian Grand Prix", "2023-09-03");
INSERT INTO "results" VALUES ("101", "1", "44", "1", "1:20.345", "220.5");
INSERT INTO "results" VALUES ("102", "1", "33", "2", "1:20.123", "221.0");
INSERT INTO "results" VALUES ("103", "2", "44", "1", "1:29.876", "215.2");
INSERT INTO "results" VALUES ("104", "2", "16", "2", "1:29.654", "215.8");
INSERT INTO "results" VALUES ("105", "3", "55", "1", "1:10.234", "230.1");
INSERT INTO "results" VALUES ("106", "3", "11", "2", "1:10.567", "229.5");
INSERT INTO "results" VALUES ("107", "4", "44", "1", "1:25.789", "218.3");
INSERT INTO "results" VALUES ("108", "4", "33", "2", "1:26.001", "217.9");
INSERT INTO "results" VALUES ("109", "5", "16", "1", "1:21.456", "219.7");
INSERT INTO "results" VALUES ("110", "5", "55", "2", "1:21.789", "219.2");