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

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"position" INT,
"milliseconds" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId")
);



INSERT INTO "races" VALUES ("1", "2023", "1", "Bahrain Grand Prix", "2023-03-05");
INSERT INTO "races" VALUES ("2", "2023", "2", "Saudi Arabian Grand Prix", "2023-03-19");
INSERT INTO "races" VALUES ("3", "2023", "3", "Australian Grand Prix", "2023-04-02");
INSERT INTO "races" VALUES ("4", "2022", "1", "Bahrain Grand Prix", "2022-03-20");
INSERT INTO "races" VALUES ("5", "2022", "4", "Monaco Grand Prix", "2022-05-29");
INSERT INTO "races" VALUES ("6", "2021", "5", "Italian Grand Prix", "2021-09-12");
INSERT INTO "races" VALUES ("7", "2021", "6", "Abu Dhabi Grand Prix", "2021-12-12");
INSERT INTO "races" VALUES ("8", "2020", "7", "Austrian Grand Prix", "2020-07-05");
INSERT INTO "races" VALUES ("9", "2020", "8", "British Grand Prix", "2020-08-02");
INSERT INTO "races" VALUES ("10", "2019", "9", "Singapore Grand Prix", "2019-09-22");
INSERT INTO "results" VALUES ("1", "1", "1", "5400000");
INSERT INTO "results" VALUES ("2", "1", "2", "5401000");
INSERT INTO "results" VALUES ("3", "2", "1", "5500000");
INSERT INTO "results" VALUES ("4", "2", "2", "5502000");
INSERT INTO "results" VALUES ("5", "3", "1", "5300000");
INSERT INTO "results" VALUES ("6", "3", "2", "5300500");
INSERT INTO "results" VALUES ("7", "4", "1", "5450000");
INSERT INTO "results" VALUES ("8", "4", "2", "5451000");
INSERT INTO "results" VALUES ("9", "5", "1", "6000000");
INSERT INTO "results" VALUES ("10", "5", "2", "6005000");
INSERT INTO "results" VALUES ("11", "6", "1", "4800000");
INSERT INTO "results" VALUES ("12", "6", "2", "4800100");
INSERT INTO "results" VALUES ("13", "7", "1", "5600000");
INSERT INTO "results" VALUES ("14", "7", "2", "5600200");
INSERT INTO "results" VALUES ("15", "8", "1", "5000000");
INSERT INTO "results" VALUES ("16", "8", "2", "5000300");
INSERT INTO "results" VALUES ("17", "9", "1", "5100000");
INSERT INTO "results" VALUES ("18", "9", "2", "5100400");
INSERT INTO "results" VALUES ("19", "10", "1", "5800000");
INSERT INTO "results" VALUES ("20", "10", "2", "5800600");
INSERT INTO "results" VALUES ("21", "1", "3", "null");
INSERT INTO "results" VALUES ("22", "3", "3", "null");
INSERT INTO "results" VALUES ("23", "6", "3", "null");