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



INSERT INTO "circuits" VALUES ("1", "Abu Dhabi Circuit", "Abu Dhabi");
INSERT INTO "circuits" VALUES ("2", "Silverstone Circuit", "Silverstone");
INSERT INTO "circuits" VALUES ("3", "Monaco Circuit", "Monaco");
INSERT INTO "circuits" VALUES ("4", "Spa-Francorchamps", "Belgium");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit", "Japan");
INSERT INTO "races" VALUES ("101", "2010", "1", "Abu Dhabi Grand Prix", "2010-11-14", "14:00:00");
INSERT INTO "races" VALUES ("102", "2011", "1", "Abu Dhabi Grand Prix", "2011-11-13", "14:30:00");
INSERT INTO "races" VALUES ("103", "2012", "1", "Abu Dhabi Grand Prix", "2012-11-04", "13:45:00");
INSERT INTO "races" VALUES ("104", "2013", "1", "Abu Dhabi Grand Prix", "2013-11-03", "14:00:00");
INSERT INTO "races" VALUES ("105", "2014", "1", "Abu Dhabi Grand Prix", "2014-11-23", "14:00:00");
INSERT INTO "races" VALUES ("106", "2015", "1", "Abu Dhabi Grand Prix", "2015-11-29", "14:00:00");
INSERT INTO "races" VALUES ("107", "2016", "1", "Abu Dhabi Grand Prix", "2016-11-27", "14:00:00");
INSERT INTO "races" VALUES ("108", "2017", "1", "Abu Dhabi Grand Prix", "2017-11-26", "14:00:00");
INSERT INTO "races" VALUES ("109", "2018", "1", "Abu Dhabi Grand Prix", "2018-11-25", "14:00:00");
INSERT INTO "races" VALUES ("110", "2019", "1", "Abu Dhabi Grand Prix", "2019-12-01", "14:10:00");
INSERT INTO "races" VALUES ("201", "2010", "2", "British Grand Prix", "2010-07-11", "13:00:00");
INSERT INTO "races" VALUES ("202", "2011", "3", "Monaco Grand Prix", "2011-05-29", "14:00:00");
INSERT INTO "races" VALUES ("203", "2012", "4", "Belgian Grand Prix", "2012-09-02", "14:00:00");
INSERT INTO "races" VALUES ("204", "2013", "5", "Japanese Grand Prix", "2013-10-13", "14:00:00");