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,
"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", "Red Bull Ring", "Spielberg", "Austria", "47.2197", "14.7647");
INSERT INTO "circuits" VALUES ("2", "Silverstone Circuit", "Silverstone", "United Kingdom", "52.0786", "-1.0169");
INSERT INTO "circuits" VALUES ("3", "Monza Circuit", "Monza", "Italy", "45.6156", "9.2811");
INSERT INTO "circuits" VALUES ("4", "Hockenheimring", "Hockenheim", "Germany", "49.3278", "8.5656");
INSERT INTO "circuits" VALUES ("5", "Red Bull Ring Old", "Zeltweg", "Austria", "47.2200", "14.7600");
INSERT INTO "races" VALUES ("101", "2018", "1", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("102", "2019", "1", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("103", "2020", "1", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("104", "2021", "1", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("105", "2022", "1", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("106", "1970", "5", "Austrian Grand Prix Old");
INSERT INTO "races" VALUES ("107", "1971", "5", "Austrian Grand Prix Old");
INSERT INTO "races" VALUES ("108", "1972", "5", "Austrian Grand Prix Old");
INSERT INTO "races" VALUES ("109", "2018", "2", "British Grand Prix");
INSERT INTO "races" VALUES ("110", "2019", "3", "Italian Grand Prix");
INSERT INTO "races" VALUES ("111", "2020", "4", "German Grand Prix");