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



INSERT INTO "circuits" VALUES ("1", "Circuit de Barcelona-Catalunya", "Montmeló", "Spain");
INSERT INTO "circuits" VALUES ("2", "Monza", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "Silverstone", "UK");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("5", "Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("6", "Hungaroring", "Mogyoród", "Hungary");
INSERT INTO "circuits" VALUES ("7", "Red Bull Ring", "Spielberg", "Austria");
INSERT INTO "circuits" VALUES ("8", "Autódromo José Carlos Pace", "São Paulo", "Brazil");
INSERT INTO "circuits" VALUES ("9", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("10", "Yas Marina Circuit", "Abu Dhabi", "UAE");
INSERT INTO "races" VALUES ("1", "1", "Spanish Grand Prix", "2023-06-04");
INSERT INTO "races" VALUES ("2", "2", "Italian Grand Prix", "2023-09-03");
INSERT INTO "races" VALUES ("3", "1", "Spanish Grand Prix", "2022-05-22");
INSERT INTO "races" VALUES ("4", "3", "British Grand Prix", "2023-07-09");
INSERT INTO "races" VALUES ("5", "1", "Spanish Grand Prix", "2021-05-09");
INSERT INTO "races" VALUES ("6", "4", "Monaco Grand Prix", "2023-05-28");
INSERT INTO "races" VALUES ("7", "1", "Spanish Grand Prix", "2020-08-16");
INSERT INTO "races" VALUES ("8", "5", "Belgian Grand Prix", "2023-07-30");
INSERT INTO "races" VALUES ("9", "1", "Spanish Grand Prix", "2019-05-12");
INSERT INTO "races" VALUES ("10", "6", "Hungarian Grand Prix", "2023-07-23");
INSERT INTO "races" VALUES ("11", "1", "Spanish Grand Prix", "2018-05-13");
INSERT INTO "races" VALUES ("12", "1", "Catalunya Test", "2023-02-23");
INSERT INTO "races" VALUES ("13", "1", "Spanish Grand Prix", "2017-05-14");
INSERT INTO "races" VALUES ("14", "7", "Austrian Grand Prix", "2023-07-02");
INSERT INTO "races" VALUES ("15", "8", "Brazilian Grand Prix", "2023-11-05");
INSERT INTO "races" VALUES ("16", "9", "Japanese Grand Prix", "2023-09-24");
INSERT INTO "races" VALUES ("17", "10", "Abu Dhabi Grand Prix", "2023-11-26");