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,
"alt" INT,
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,
"url" TEXT,
PRIMARY KEY ("year")
);



INSERT INTO "circuits" VALUES ("1", "Silverstone Circuit", "Silverstone", "United Kingdom", "150");
INSERT INTO "circuits" VALUES ("2", "Brands Hatch", "Kent", "United Kingdom", "100");
INSERT INTO "circuits" VALUES ("3", "Monza", "Monza", "Italy", "200");
INSERT INTO "circuits" VALUES ("4", "Spa-Francorchamps", "Stavelot", "Belgium", "250");
INSERT INTO "circuits" VALUES ("5", "Silverstone Old", "Silverstone", "United Kingdom", "140");
INSERT INTO "seasons" VALUES ("2015", "http://example.com/2015");
INSERT INTO "seasons" VALUES ("2016", "http://example.com/2016");
INSERT INTO "seasons" VALUES ("2017", "http://example.com/2017");
INSERT INTO "seasons" VALUES ("2018", "http://example.com/2018");
INSERT INTO "seasons" VALUES ("2019", "http://example.com/2019");
INSERT INTO "seasons" VALUES ("2020", "http://example.com/2020");
INSERT INTO "seasons" VALUES ("2021", "http://example.com/2021");
INSERT INTO "seasons" VALUES ("2022", "http://example.com/2022");
INSERT INTO "races" VALUES ("101", "2015", "1", "British Grand Prix", "2015-07-05");
INSERT INTO "races" VALUES ("102", "2016", "1", "British Grand Prix", "2016-07-10");
INSERT INTO "races" VALUES ("103", "2017", "1", "British Grand Prix", "2017-07-16");
INSERT INTO "races" VALUES ("104", "2018", "1", "British Grand Prix", "2018-07-08");
INSERT INTO "races" VALUES ("105", "2019", "1", "British Grand Prix", "2019-07-14");
INSERT INTO "races" VALUES ("106", "2020", "1", "British Grand Prix", "2020-08-02");
INSERT INTO "races" VALUES ("107", "2021", "1", "British Grand Prix", "2021-07-18");
INSERT INTO "races" VALUES ("108", "2022", "1", "British Grand Prix", "2022-07-03");
INSERT INTO "races" VALUES ("109", "2015", "2", "British Grand Prix", "2015-08-02");
INSERT INTO "races" VALUES ("110", "2016", "2", "British Grand Prix", "2016-08-07");
INSERT INTO "races" VALUES ("111", "2017", "1", "Silverstone 500", "2017-09-10");
INSERT INTO "races" VALUES ("112", "2018", "1", "Silverstone GP", "2018-09-15");
INSERT INTO "races" VALUES ("113", "2019", "3", "British Grand Prix", "2019-09-01");
INSERT INTO "races" VALUES ("114", "2020", "4", "British Grand Prix", "2020-09-05");