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,
PRIMARY KEY ("circuitId")
);

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

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



INSERT INTO "circuits" VALUES ("1", "Brands Hatch", "Fawkham", "UK");
INSERT INTO "circuits" VALUES ("2", "Silverstone Circuit", "Silverstone", "UK");
INSERT INTO "circuits" VALUES ("3", "Monza", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("5", "Nürburgring", "Nürburg", "Germany");
INSERT INTO "circuits" VALUES ("6", "Circuit de Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("7", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("8", "Interlagos", "São Paulo", "Brazil");
INSERT INTO "circuits" VALUES ("9", "Circuit Gilles Villeneuve", "Montreal", "Canada");
INSERT INTO "circuits" VALUES ("10", "Hungaroring", "Mogyoród", "Hungary");
INSERT INTO "constructors" VALUES ("1", "Ferrari");
INSERT INTO "constructors" VALUES ("2", "McLaren");
INSERT INTO "constructors" VALUES ("3", "Mercedes");
INSERT INTO "constructors" VALUES ("4", "Red Bull");
INSERT INTO "constructors" VALUES ("5", "Williams");
INSERT INTO "constructors" VALUES ("6", "Lotus");
INSERT INTO "constructors" VALUES ("7", "Tyrrell");
INSERT INTO "constructors" VALUES ("8", "Brabham");
INSERT INTO "constructors" VALUES ("9", "Benetton");
INSERT INTO "constructors" VALUES ("10", "Renault");
INSERT INTO "races" VALUES ("1", "1986", "1", "British Grand Prix", "1986-07-13");
INSERT INTO "races" VALUES ("2", "1985", "1", "British Grand Prix", "1985-07-21");
INSERT INTO "races" VALUES ("3", "1984", "2", "British Grand Prix", "1984-07-22");
INSERT INTO "races" VALUES ("4", "1983", "2", "British Grand Prix", "1983-07-16");
INSERT INTO "races" VALUES ("5", "1982", "1", "British Grand Prix", "1982-07-18");
INSERT INTO "races" VALUES ("6", "1981", "2", "British Grand Prix", "1981-07-18");
INSERT INTO "races" VALUES ("7", "1980", "1", "British Grand Prix", "1980-07-13");
INSERT INTO "races" VALUES ("8", "1979", "2", "British Grand Prix", "1979-07-14");
INSERT INTO "races" VALUES ("9", "1978", "1", "British Grand Prix", "1978-07-16");
INSERT INTO "races" VALUES ("10", "1977", "2", "British Grand Prix", "1977-07-16");
INSERT INTO "races" VALUES ("11", "1990", "2", "British Grand Prix", "1990-07-15");
INSERT INTO "races" VALUES ("12", "2023", "2", "British Grand Prix", "2023-07-09");
INSERT INTO "races" VALUES ("13", "1986", "3", "Italian Grand Prix", "1986-09-07");
INSERT INTO "races" VALUES ("14", "1986", "4", "Monaco Grand Prix", "1986-05-11");
INSERT INTO "races" VALUES ("15", "1985", "5", "German Grand Prix", "1985-08-04");