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,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" FLOAT,
"lng" FLOAT,
"url" TEXT,
PRIMARY KEY ("circuitId")
);

CREATE TABLE "constructors" (
"constructorId" INT,
"name" TEXT,
"nationality" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"year" INT,
"round" INT,
"circuitId" INT,
"name" TEXT,
"date" DATE,
"time" TEXT,
"url" TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);

CREATE TABLE "results" (
"resultId" INT,
"position" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "circuits" VALUES ("1", "silverstone", "Silverstone Circuit", "Silverstone", "United Kingdom", "52.0786", "-1.01694", "http://en.wikipedia.org/wiki/Silverstone_Circuit");
INSERT INTO "circuits" VALUES ("2", "monza", "Autodromo Nazionale Monza", "Monza", "Italy", "45.6156", "9.28111", "http://en.wikipedia.org/wiki/Autodromo_Nazionale_Monza");
INSERT INTO "circuits" VALUES ("3", "spa", "Circuit de Spa-Francorchamps", "Stavelot", "Belgium", "50.4372", "5.97139", "http://en.wikipedia.org/wiki/Circuit_de_Spa-Francorchamps");
INSERT INTO "constructors" VALUES ("1", "Mercedes", "German");
INSERT INTO "constructors" VALUES ("2", "Ferrari", "Italian");
INSERT INTO "constructors" VALUES ("3", "Red Bull Racing", "Austrian");
INSERT INTO "races" VALUES ("101", "2023", "10", "1", "British Grand Prix", "2023-07-09", "14:00:00", "http://en.wikipedia.org/wiki/2023_British_Grand_Prix");
INSERT INTO "races" VALUES ("102", "2022", "10", "1", "British Grand Prix", "2022-07-03", "14:00:00", "http://en.wikipedia.org/wiki/2022_British_Grand_Prix");
INSERT INTO "races" VALUES ("103", "2023", "11", "2", "Italian Grand Prix", "2023-09-03", "14:00:00", "http://en.wikipedia.org/wiki/2023_Italian_Grand_Prix");
INSERT INTO "races" VALUES ("104", "2023", "12", "3", "Belgian Grand Prix", "2023-08-27", "14:00:00", "http://en.wikipedia.org/wiki/2023_Belgian_Grand_Prix");
INSERT INTO "races" VALUES ("105", "2021", "10", "1", "British Grand Prix", "2021-08-01", "14:00:00", "http://en.wikipedia.org/wiki/2021_British_Grand_Prix");
INSERT INTO "results" VALUES ("1001", "1");
INSERT INTO "results" VALUES ("1002", "2");
INSERT INTO "results" VALUES ("1003", "3");
INSERT INTO "results" VALUES ("1004", "4");
INSERT INTO "results" VALUES ("1005", "5");