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

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", "Hockenheimring", "Hockenheim", "Germany");
INSERT INTO "circuits" VALUES ("2", "Nürburgring", "Nürburg", "Germany");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "Silverstone", "United Kingdom");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("5", "Circuit Gilles Villeneuve", "Montreal", "Canada");
INSERT INTO "circuits" VALUES ("6", "Autodromo Nazionale Monza", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("7", "Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("8", "Red Bull Ring", "Spielberg", "Austria");
INSERT INTO "races" VALUES ("101", "2020", "1", "German Grand Prix");
INSERT INTO "races" VALUES ("102", "2021", "2", "Eifel Grand Prix");
INSERT INTO "races" VALUES ("103", "2020", "3", "British Grand Prix");
INSERT INTO "races" VALUES ("104", "2021", "4", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("105", "2020", "5", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("106", "2021", "6", "Italian Grand Prix");
INSERT INTO "races" VALUES ("107", "2020", "7", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("108", "2021", "8", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("109", "2019", "1", "German Grand Prix");
INSERT INTO "races" VALUES ("110", "2019", "2", "Eifel Grand Prix");