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", "Albert Park Grand Prix Circuit", "Australia", "-37.8497", "144.968");
INSERT INTO "circuits" VALUES ("2", "Sepang International Circuit", "Malaysia", "2.76083", "101.738");
INSERT INTO "circuits" VALUES ("3", "Bahrain International Circuit", "Bahrain", "26.0325", "50.5106");
INSERT INTO "circuits" VALUES ("4", "Circuit de Catalunya", "Spain", "41.57", "2.26111");
INSERT INTO "circuits" VALUES ("5", "Istanbul Park", "Turkey", "40.9517", "29.405");
INSERT INTO "circuits" VALUES ("6", "Circuit Gilles Villeneuve", "Canada", "45.5228", "-73.5258");
INSERT INTO "circuits" VALUES ("7", "Silverstone Circuit", "UK", "52.0786", "-1.01694");
INSERT INTO "circuits" VALUES ("8", "Hockenheimring", "Germany", "49.3278", "8.56583");
INSERT INTO "circuits" VALUES ("9", "Hungaroring", "Hungary", "47.5789", "19.2511");
INSERT INTO "circuits" VALUES ("10", "Circuit de Spa-Francorchamps", "Belgium", "50.4394", "5.97139");
INSERT INTO "circuits" VALUES ("11", "Autodromo Nazionale di Monza", "Italy", "45.6156", "9.28111");
INSERT INTO "circuits" VALUES ("12", "Circuit de Nevers Magny-Cours", "France", "46.8642", "3.16361");
INSERT INTO "circuits" VALUES ("13", "Suzuka Circuit", "Japan", "34.8431", "136.538");
INSERT INTO "circuits" VALUES ("14", "Shanghai International Circuit", "China", "31.3389", "121.22");
INSERT INTO "circuits" VALUES ("15", "Autódromo José Carlos Pace", "Brazil", "-23.7036", "-46.6997");
INSERT INTO "circuits" VALUES ("16", "Yas Marina Circuit", "UAE", "24.4672", "54.6031");
INSERT INTO "circuits" VALUES ("17", "Circuit of the Americas", "USA", "30.1328", "-97.6411");
INSERT INTO "circuits" VALUES ("18", "Sochi Autodrom", "Russia", "43.4057", "39.9578");
INSERT INTO "circuits" VALUES ("19", "Baku City Circuit", "Azerbaijan", "40.3725", "49.8533");
INSERT INTO "circuits" VALUES ("20", "Jeddah Corniche Circuit", "Saudi Arabia", "21.6319", "39.1036");
INSERT INTO "races" VALUES ("1", "2023", "1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2023", "3", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("3", "2023", "14", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("4", "2023", "19", "Azerbaijan Grand Prix");
INSERT INTO "races" VALUES ("5", "2023", "4", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("6", "2023", "6", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("7", "2023", "7", "British Grand Prix");
INSERT INTO "races" VALUES ("8", "2023", "9", "Hungarian Grand Prix");
INSERT INTO "races" VALUES ("9", "2023", "10", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("10", "2023", "11", "Italian Grand Prix");
INSERT INTO "races" VALUES ("11", "2023", "16", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("12", "2022", "1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("13", "2022", "2", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("14", "2022", "15", "Brazilian Grand Prix");
INSERT INTO "races" VALUES ("15", "2021", "1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("16", "2021", "20", "Saudi Arabian Grand Prix");
INSERT INTO "races" VALUES ("17", "2020", "1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("18", "2019", "1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("19", "2019", "13", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("20", "2018", "1", "Australian Grand Prix");