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



INSERT INTO "circuits" VALUES ("1", "Circuit de Barcelona-Catalunya", "Spain");
INSERT INTO "circuits" VALUES ("2", "Circuit de Monaco", "Monaco");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "United Kingdom");
INSERT INTO "circuits" VALUES ("4", "Circuit Ricardo Tormo", "Spain");
INSERT INTO "circuits" VALUES ("5", "Autodromo Nazionale Monza", "Italy");
INSERT INTO "circuits" VALUES ("6", "Circuit Paul Ricard", "France");
INSERT INTO "races" VALUES ("101", "2022", "1", "Spanish Grand Prix", "2022-05-22");
INSERT INTO "races" VALUES ("102", "2021", "1", "Spanish Grand Prix", "2021-05-09");
INSERT INTO "races" VALUES ("103", "2020", "2", "Monaco Grand Prix", "2020-05-24");
INSERT INTO "races" VALUES ("104", "2022", "3", "British Grand Prix", "2022-07-03");
INSERT INTO "races" VALUES ("105", "2021", "4", "Valencia E-Prix", "2021-06-05");
INSERT INTO "races" VALUES ("106", "2020", "4", "Valencia E-Prix", "2020-06-07");
INSERT INTO "races" VALUES ("107", "2019", "5", "Italian Grand Prix", "2019-09-08");
INSERT INTO "races" VALUES ("108", "2018", "6", "French Grand Prix", "2018-06-24");
INSERT INTO "races" VALUES ("109", "2019", "1", "Spanish Grand Prix", "2019-05-12");
INSERT INTO "races" VALUES ("110", "2017", "4", "Valencia E-Prix", "2017-06-03");