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,
"name" TEXT,
"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", "Circuit de Monaco", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("3", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("4", "Circuit of the Americas", "Austin", "USA");
INSERT INTO "circuits" VALUES ("5", "Autodromo Nazionale Monza", "Monza", "Italy");
INSERT INTO "races" VALUES ("101", "2022", "1", "British Grand Prix", "2022-07-03");
INSERT INTO "races" VALUES ("102", "2022", "2", "Monaco Grand Prix", "2022-05-29");
INSERT INTO "races" VALUES ("103", "2022", "3", "Japanese Grand Prix", "2022-10-09");
INSERT INTO "races" VALUES ("104", "2022", "4", "United States Grand Prix", "2022-10-23");
INSERT INTO "races" VALUES ("105", "2022", "5", "Italian Grand Prix", "2022-09-11");
INSERT INTO "races" VALUES ("106", "2023", "1", "British Grand Prix", "2023-07-09");
INSERT INTO "races" VALUES ("107", "2023", "2", "Monaco Grand Prix", "2023-05-28");
INSERT INTO "races" VALUES ("108", "2023", "3", "Japanese Grand Prix", "2023-10-08");
INSERT INTO "races" VALUES ("109", "2023", "4", "United States Grand Prix", "2023-10-22");
INSERT INTO "races" VALUES ("110", "2023", "5", "Italian Grand Prix", "2023-09-10");
INSERT INTO "races" VALUES ("111", "2024", "1", "British Grand Prix", "2024-07-07");
INSERT INTO "races" VALUES ("112", "2024", "2", "Monaco Grand Prix", "2024-05-26");
INSERT INTO "races" VALUES ("113", "2024", "3", "Japanese Grand Prix", "2024-10-13");
INSERT INTO "races" VALUES ("114", "2024", "4", "United States Grand Prix", "2024-10-27");
INSERT INTO "races" VALUES ("115", "2024", "5", "Italian Grand Prix", "2024-09-08");