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", "Yas Marina Circuit", "United Arab Emirates", "24.4672", "54.6031");
INSERT INTO "circuits" VALUES ("2", "Silverstone Circuit", "United Kingdom", "52.0786", "-1.0169");
INSERT INTO "circuits" VALUES ("3", "Monza Circuit", "Italy", "45.6156", "9.2811");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco", "Monaco", "43.7347", "7.4206");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit", "Japan", "34.8431", "136.5410");
INSERT INTO "races" VALUES ("101", "2022", "1", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("102", "2021", "1", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("103", "2022", "2", "British Grand Prix");
INSERT INTO "races" VALUES ("104", "2022", "3", "Italian Grand Prix");
INSERT INTO "races" VALUES ("105", "2022", "4", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("106", "2022", "5", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("107", "2020", "1", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("108", "2019", "1", "Abu Dhabi Grand Prix");