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,
"location" TEXT,
"country" TEXT,
PRIMARY KEY ("circuitId")
);

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

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



INSERT INTO "circuits" VALUES ("1", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("2", "Imola", "Italy");
INSERT INTO "circuits" VALUES ("3", "Silverstone", "United Kingdom");
INSERT INTO "circuits" VALUES ("4", "Spa-Francorchamps", "Belgium");
INSERT INTO "circuits" VALUES ("5", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("6", "Marina Bay", "Singapore");
INSERT INTO "circuits" VALUES ("7", "Mugello", "Italy");
INSERT INTO "circuits" VALUES ("8", "Hockenheim", "Germany");
INSERT INTO "constructors" VALUES ("1", "Italian");
INSERT INTO "constructors" VALUES ("2", "British");
INSERT INTO "constructors" VALUES ("3", "German");
INSERT INTO "constructors" VALUES ("4", "Japanese");
INSERT INTO "races" VALUES ("101", "2018", "1");
INSERT INTO "races" VALUES ("102", "2019", "1");
INSERT INTO "races" VALUES ("103", "2020", "1");
INSERT INTO "races" VALUES ("104", "2021", "1");
INSERT INTO "races" VALUES ("105", "2018", "2");
INSERT INTO "races" VALUES ("106", "2019", "2");
INSERT INTO "races" VALUES ("107", "2020", "3");
INSERT INTO "races" VALUES ("108", "2021", "4");
INSERT INTO "races" VALUES ("109", "2019", "5");
INSERT INTO "races" VALUES ("110", "2020", "6");
INSERT INTO "races" VALUES ("111", "2021", "7");
INSERT INTO "races" VALUES ("112", "2022", "7");
INSERT INTO "races" VALUES ("113", "2022", "8");
INSERT INTO "races" VALUES ("114", "2023", "1");
INSERT INTO "races" VALUES ("115", "2023", "2");