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 "circuits" (
"circuitId" INT UNIQUE,
"name" TEXT,
PRIMARY KEY ("circuitId")
);

CREATE TABLE "constructors" (
"constructorId" INT,
"name" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"year" INT,
"circuitId" INT,
"name" TEXT,
"url" TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);

CREATE TABLE "results" (
"resultId" INT,
"position" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "circuits" VALUES ("1", "Circuit de Barcelona-Catalunya");
INSERT INTO "circuits" VALUES ("2", "Monza");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco");
INSERT INTO "circuits" VALUES ("5", "Spa-Francorchamps");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Aston Martin");
INSERT INTO "races" VALUES ("100", "2023", "1", "Spanish Grand Prix", "https://en.wikipedia.org/wiki/2023_Spanish_Grand_Prix");
INSERT INTO "races" VALUES ("101", "2022", "1", "Spanish Grand Prix", "https://en.wikipedia.org/wiki/2022_Spanish_Grand_Prix");
INSERT INTO "races" VALUES ("102", "2023", "2", "Italian Grand Prix", "https://en.wikipedia.org/wiki/2023_Italian_Grand_Prix");
INSERT INTO "races" VALUES ("103", "2023", "3", "British Grand Prix", "https://en.wikipedia.org/wiki/2023_British_Grand_Prix");
INSERT INTO "races" VALUES ("104", "2021", "1", "Spanish Grand Prix", "https://en.wikipedia.org/wiki/2021_Spanish_Grand_Prix");
INSERT INTO "races" VALUES ("105", "2023", "4", "Monaco Grand Prix", "https://en.wikipedia.org/wiki/2023_Monaco_Grand_Prix");
INSERT INTO "races" VALUES ("106", "2020", "1", "Spanish Grand Prix", "https://en.wikipedia.org/wiki/2020_Spanish_Grand_Prix");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "1");
INSERT INTO "results" VALUES ("5", "2");