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", "Sepang International Circuit", "Malaysia", "2.76083", "101.738");
INSERT INTO "circuits" VALUES ("2", "Silverstone Circuit", "United Kingdom", "52.0786", "-1.01694");
INSERT INTO "circuits" VALUES ("3", "Monza Circuit", "Italy", "45.6156", "9.28111");
INSERT INTO "circuits" VALUES ("4", "Suzuka Circuit", "Japan", "34.8431", "136.541");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco", "Monaco", "43.7347", "7.42056");
INSERT INTO "races" VALUES ("101", "2018", "1", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("102", "2019", "1", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("103", "2020", "2", "British Grand Prix");
INSERT INTO "races" VALUES ("104", "2021", "3", "Italian Grand Prix");
INSERT INTO "races" VALUES ("105", "2022", "4", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("106", "2023", "5", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("107", "2017", "1", "Malaysian Grand Prix");