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



INSERT INTO "circuits" VALUES ("1", "Silverstone Circuit", "Silverstone", "United Kingdom");
INSERT INTO "circuits" VALUES ("2", "Monza Circuit", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("3", "Circuit de Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("4", "Barcelona-Catalunya", "Montmeló", "Spain");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("6", "Circuit Gilles Villeneuve", "Montreal", "Canada");
INSERT INTO "races" VALUES ("101", "2018", "4", "2018-05-13");
INSERT INTO "races" VALUES ("102", "2019", "4", "2019-05-12");
INSERT INTO "races" VALUES ("103", "2020", "4", "2020-08-16");
INSERT INTO "races" VALUES ("104", "2021", "4", "2021-05-09");
INSERT INTO "races" VALUES ("105", "2022", "4", "2022-05-22");
INSERT INTO "races" VALUES ("106", "2023", "4", "2023-06-04");
INSERT INTO "races" VALUES ("201", "2018", "1", "2018-07-08");
INSERT INTO "races" VALUES ("202", "2019", "1", "2019-07-14");
INSERT INTO "races" VALUES ("203", "2020", "1", "2020-08-02");
INSERT INTO "races" VALUES ("204", "2021", "1", "2021-07-18");
INSERT INTO "races" VALUES ("301", "2018", "2", "2018-09-02");
INSERT INTO "races" VALUES ("302", "2019", "2", "2019-09-08");
INSERT INTO "races" VALUES ("401", "2018", "3", "2018-09-02");
INSERT INTO "races" VALUES ("402", "2019", "3", "2019-08-01");
INSERT INTO "races" VALUES ("501", "2018", "5", "2018-09-16");
INSERT INTO "races" VALUES ("502", "2019", "5", "2019-09-29");
INSERT INTO "races" VALUES ("601", "2018", "6", "2018-06-10");
INSERT INTO "races" VALUES ("602", "2019", "6", "2019-06-09");