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

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



INSERT INTO "circuits" VALUES ("1", "Nürburgring", "Germany");
INSERT INTO "circuits" VALUES ("2", "Hockenheimring", "Germany");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "United Kingdom");
INSERT INTO "circuits" VALUES ("4", "Circuit de Spa-Francorchamps", "Belgium");
INSERT INTO "circuits" VALUES ("5", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("6", "Circuit de Barcelona-Catalunya", "Spain");
INSERT INTO "circuits" VALUES ("7", "Red Bull Ring", "Austria");
INSERT INTO "circuits" VALUES ("8", "Circuit Paul Ricard", "France");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Ferrari");
INSERT INTO "constructors" VALUES ("3", "Red Bull Racing");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "races" VALUES ("101", "2018", "1", "European Grand Prix");
INSERT INTO "races" VALUES ("102", "2019", "2", "European Grand Prix");
INSERT INTO "races" VALUES ("103", "2020", "3", "European Grand Prix");
INSERT INTO "races" VALUES ("104", "2021", "4", "European Grand Prix");
INSERT INTO "races" VALUES ("105", "2022", "5", "European Grand Prix");
INSERT INTO "races" VALUES ("106", "2023", "6", "European Grand Prix");
INSERT INTO "races" VALUES ("107", "2017", "7", "European Grand Prix");
INSERT INTO "races" VALUES ("108", "2016", "8", "European Grand Prix");
INSERT INTO "races" VALUES ("109", "2018", "1", "German Grand Prix");
INSERT INTO "races" VALUES ("110", "2019", "3", "British Grand Prix");
INSERT INTO "races" VALUES ("111", "2020", "4", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("112", "2021", "5", "Italian Grand Prix");