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

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

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



INSERT INTO "circuits" VALUES ("1", "Bahrain International Circuit");
INSERT INTO "circuits" VALUES ("2", "Melbourne Grand Prix Circuit");
INSERT INTO "circuits" VALUES ("3", "Shanghai International Circuit");
INSERT INTO "circuits" VALUES ("4", "Circuit de Catalunya");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco");
INSERT INTO "circuits" VALUES ("6", "Istanbul Park");
INSERT INTO "circuits" VALUES ("7", "Silverstone Circuit");
INSERT INTO "circuits" VALUES ("8", "Nürburgring");
INSERT INTO "circuits" VALUES ("9", "Hungaroring");
INSERT INTO "circuits" VALUES ("10", "Circuit de Spa-Francorchamps");
INSERT INTO "seasons" VALUES ("2008");
INSERT INTO "seasons" VALUES ("2009");
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 "races" VALUES ("1", "2009", "Australian Grand Prix", "2009-03-29");
INSERT INTO "races" VALUES ("2", "2009", "Malaysian Grand Prix", "2009-04-05");
INSERT INTO "races" VALUES ("3", "2009", "Chinese Grand Prix", "2009-04-19");
INSERT INTO "races" VALUES ("4", "2008", "Bahrain Grand Prix", "2008-04-06");
INSERT INTO "races" VALUES ("5", "2010", "Spanish Grand Prix", "2010-05-09");
INSERT INTO "races" VALUES ("6", "2009", "Monaco Grand Prix", "2009-05-24");
INSERT INTO "races" VALUES ("7", "2011", "Turkish Grand Prix", "2011-05-08");
INSERT INTO "races" VALUES ("8", "2009", "British Grand Prix", "2009-06-21");
INSERT INTO "races" VALUES ("9", "2012", "German Grand Prix", "2012-07-22");
INSERT INTO "races" VALUES ("10", "2009", "Hungarian Grand Prix", "2009-07-26");
INSERT INTO "races" VALUES ("11", "2013", "Belgian Grand Prix", "2013-08-25");
INSERT INTO "races" VALUES ("12", "2009", "Italian Grand Prix", "2009-09-13");
INSERT INTO "races" VALUES ("13", "2009", "Singapore Grand Prix", "2009-09-27");
INSERT INTO "races" VALUES ("14", "2009", "Japanese Grand Prix", "2009-10-04");
INSERT INTO "races" VALUES ("15", "2009", "Brazilian Grand Prix", "2009-10-18");
INSERT INTO "races" VALUES ("16", "2009", "Abu Dhabi Grand Prix", "2009-11-01");
INSERT INTO "races" VALUES ("17", "2014", "United States Grand Prix", "2014-11-02");
INSERT INTO "races" VALUES ("18", "2015", "Mexican Grand Prix", "2015-11-01");
INSERT INTO "races" VALUES ("19", "2016", "European Grand Prix", "2016-06-19");
INSERT INTO "races" VALUES ("20", "2017", "Azerbaijan Grand Prix", "2017-06-25");