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,
"country" TEXT,
"lat" FLOAT,
"lng" FLOAT,
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", "Circuit de Barcelona-Catalunya", "Spain", "41.57", "2.26");
INSERT INTO "circuits" VALUES ("2", "Circuit de Monaco", "Monaco", "43.73", "7.42");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "UK", "52.07", "-1.01");
INSERT INTO "circuits" VALUES ("4", "Autodromo Nazionale Monza", "Italy", "45.61", "9.28");
INSERT INTO "circuits" VALUES ("5", "Circuit de Spa-Francorchamps", "Belgium", "50.43", "5.97");
INSERT INTO "circuits" VALUES ("6", "Jerez Circuit", "Spain", "36.70", "-6.04");
INSERT INTO "circuits" VALUES ("7", "Red Bull Ring", "Austria", "47.22", "14.76");
INSERT INTO "circuits" VALUES ("8", "Hungaroring", "Hungary", "47.57", "19.25");
INSERT INTO "circuits" VALUES ("9", "Suzuka International Racing Course", "Japan", "34.84", "136.54");
INSERT INTO "circuits" VALUES ("10", "Yas Marina Circuit", "UAE", "24.46", "54.60");
INSERT INTO "races" VALUES ("1", "2023", "1", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("2", "2023", "2", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("3", "2023", "3", "British Grand Prix");
INSERT INTO "races" VALUES ("4", "2023", "4", "Italian Grand Prix");
INSERT INTO "races" VALUES ("5", "2023", "5", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("6", "2022", "1", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("7", "2022", "6", "Jerez Grand Prix");
INSERT INTO "races" VALUES ("8", "2022", "7", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("9", "2021", "1", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("10", "2021", "8", "Hungarian Grand Prix");
INSERT INTO "races" VALUES ("11", "2020", "9", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("12", "2020", "10", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("13", "2019", "1", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("14", "2019", "6", "Jerez Grand Prix");