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,
"round" INT,
"circuitId" INT,
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", "Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("4", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco", "Monaco", "Monaco");
INSERT INTO "circuits" VALUES ("6", "Circuit of the Americas", "Austin", "USA");
INSERT INTO "circuits" VALUES ("7", "Silverstone Circuit", "Silverstone", "United Kingdom");
INSERT INTO "races" VALUES ("101", "2018", "10", "1");
INSERT INTO "races" VALUES ("102", "2019", "10", "1");
INSERT INTO "races" VALUES ("103", "2020", "7", "1");
INSERT INTO "races" VALUES ("104", "2021", "11", "1");
INSERT INTO "races" VALUES ("105", "2022", "10", "1");
INSERT INTO "races" VALUES ("106", "2017", "10", "7");
INSERT INTO "races" VALUES ("107", "2016", "12", "2");
INSERT INTO "races" VALUES ("108", "2015", "11", "3");
INSERT INTO "races" VALUES ("109", "2014", "13", "4");
INSERT INTO "races" VALUES ("110", "2013", "12", "5");
INSERT INTO "races" VALUES ("111", "2012", "15", "6");
INSERT INTO "races" VALUES ("112", "2011", "10", "1");
INSERT INTO "races" VALUES ("113", "2010", "9", "1");
INSERT INTO "races" VALUES ("114", "2009", "8", "1");
INSERT INTO "races" VALUES ("115", "2008", "7", "1");
INSERT INTO "races" VALUES ("116", "2007", "6", "1");
INSERT INTO "races" VALUES ("117", "2006", "5", "1");
INSERT INTO "races" VALUES ("118", "2005", "4", "1");
INSERT INTO "races" VALUES ("119", "2004", "3", "1");
INSERT INTO "races" VALUES ("120", "2003", "2", "1");
INSERT INTO "races" VALUES ("121", "2002", "1", "1");