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 "races" (
"raceId" INT,
"year" INT,
"circuitId" INT,
"name" TEXT,
"date" DATE,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("year") REFERENCES "seasons"("year"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);

CREATE TABLE "seasons" (
"year" INT UNIQUE,
PRIMARY KEY ("year")
);



INSERT INTO "circuits" VALUES ("1", "Silverstone Circuit", "Silverstone", "UK");
INSERT INTO "circuits" VALUES ("2", "Monza", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("3", "Circuit de Monaco", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("4", "Circuit de Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("6", "Circuit Gilles Villeneuve", "Montreal", "Canada");
INSERT INTO "circuits" VALUES ("7", "Hungaroring", "Mogyoród", "Hungary");
INSERT INTO "circuits" VALUES ("8", "Red Bull Ring", "Spielberg", "Austria");
INSERT INTO "circuits" VALUES ("9", "Circuit de Barcelona-Catalunya", "Montmeló", "Spain");
INSERT INTO "circuits" VALUES ("10", "Yas Marina Circuit", "Abu Dhabi", "UAE");
INSERT INTO "seasons" VALUES ("2010");
INSERT INTO "seasons" VALUES ("2011");
INSERT INTO "seasons" VALUES ("2012");
INSERT INTO "seasons" VALUES ("2013");
INSERT INTO "seasons" VALUES ("2014");
INSERT INTO "seasons" VALUES ("2015");
INSERT INTO "seasons" VALUES ("2016");
INSERT INTO "seasons" VALUES ("2017");
INSERT INTO "seasons" VALUES ("2018");
INSERT INTO "seasons" VALUES ("2019");
INSERT INTO "races" VALUES ("1", "2010", "1", "British Grand Prix", "2010-07-11");
INSERT INTO "races" VALUES ("2", "2011", "1", "British Grand Prix", "2011-07-10");
INSERT INTO "races" VALUES ("3", "2012", "1", "British Grand Prix", "2012-07-08");
INSERT INTO "races" VALUES ("4", "2013", "1", "British Grand Prix", "2013-06-30");
INSERT INTO "races" VALUES ("5", "2014", "1", "British Grand Prix", "2014-07-06");
INSERT INTO "races" VALUES ("6", "2015", "1", "British Grand Prix", "2015-07-05");
INSERT INTO "races" VALUES ("7", "2016", "1", "British Grand Prix", "2016-07-10");
INSERT INTO "races" VALUES ("8", "2017", "1", "British Grand Prix", "2017-07-16");
INSERT INTO "races" VALUES ("9", "2018", "1", "British Grand Prix", "2018-07-08");
INSERT INTO "races" VALUES ("10", "2019", "1", "British Grand Prix", "2019-07-14");
INSERT INTO "races" VALUES ("11", "2010", "2", "Italian Grand Prix", "2010-09-12");
INSERT INTO "races" VALUES ("12", "2011", "3", "Monaco Grand Prix", "2011-05-29");
INSERT INTO "races" VALUES ("13", "2012", "4", "Belgian Grand Prix", "2012-09-02");
INSERT INTO "races" VALUES ("14", "2013", "5", "Japanese Grand Prix", "2013-10-13");
INSERT INTO "races" VALUES ("15", "2014", "6", "Canadian Grand Prix", "2014-06-08");
INSERT INTO "races" VALUES ("16", "2015", "7", "Hungarian Grand Prix", "2015-07-26");
INSERT INTO "races" VALUES ("17", "2016", "8", "Austrian Grand Prix", "2016-07-03");
INSERT INTO "races" VALUES ("18", "2017", "9", "Spanish Grand Prix", "2017-05-14");
INSERT INTO "races" VALUES ("19", "2018", "10", "Abu Dhabi Grand Prix", "2018-11-25");
INSERT INTO "races" VALUES ("20", "2019", "1", "70th Anniversary Grand Prix", "2020-08-09");
INSERT INTO "races" VALUES ("21", "2010", "1", "European Grand Prix", "2010-06-27");
INSERT INTO "races" VALUES ("22", "2011", "2", "British Grand Prix", "2011-07-10");