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,
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", "Shanghai International Circuit", "Shanghai");
INSERT INTO "circuits" VALUES ("2", "Monza", "Monza");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "Silverstone");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco", "Monte Carlo");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit", "Suzuka");
INSERT INTO "circuits" VALUES ("6", "Circuit de Spa-Francorchamps", "Stavelot");
INSERT INTO "circuits" VALUES ("7", "Circuit Gilles Villeneuve", "Montreal");
INSERT INTO "circuits" VALUES ("8", "Hungaroring", "Mogyoród");
INSERT INTO "circuits" VALUES ("9", "Yas Marina Circuit", "Abu Dhabi");
INSERT INTO "circuits" VALUES ("10", "Circuit of the Americas", "Austin");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull Racing");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Aston Martin");
INSERT INTO "races" VALUES ("1", "2019", "1", "Chinese Grand Prix", "2019-04-14");
INSERT INTO "races" VALUES ("2", "2020", "2", "Italian Grand Prix", "2020-09-06");
INSERT INTO "races" VALUES ("3", "2018", "1", "Chinese Grand Prix", "2018-04-15");
INSERT INTO "races" VALUES ("4", "2021", "3", "British Grand Prix", "2021-07-18");
INSERT INTO "races" VALUES ("5", "2017", "1", "Chinese Grand Prix", "2017-04-09");
INSERT INTO "races" VALUES ("6", "2022", "4", "Monaco Grand Prix", "2022-05-29");
INSERT INTO "races" VALUES ("7", "2016", "5", "Japanese Grand Prix", "2016-10-09");
INSERT INTO "races" VALUES ("8", "2015", "1", "Chinese Grand Prix", "2015-04-12");
INSERT INTO "races" VALUES ("9", "2023", "6", "Belgian Grand Prix", "2023-07-30");
INSERT INTO "races" VALUES ("10", "2014", "7", "Canadian Grand Prix", "2014-06-08");
INSERT INTO "races" VALUES ("11", "2013", "1", "Chinese Grand Prix", "2013-04-14");
INSERT INTO "races" VALUES ("12", "2012", "8", "Hungarian Grand Prix", "2012-07-29");
INSERT INTO "races" VALUES ("13", "2011", "9", "Abu Dhabi Grand Prix", "2011-11-13");
INSERT INTO "races" VALUES ("14", "2010", "10", "United States Grand Prix", "2010-11-07");