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

CREATE TABLE "races" (
"raceId" INT,
"year" INT,
"circuitId" INT,
"date" DATE,
"time" TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);



INSERT INTO "circuits" VALUES ("1", "Silverstone Circuit", "United Kingdom");
INSERT INTO "circuits" VALUES ("2", "Monza Circuit", "Italy");
INSERT INTO "circuits" VALUES ("3", "Sepang International Circuit", "Malaysia");
INSERT INTO "circuits" VALUES ("4", "Suzuka Circuit", "Japan");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco", "Monaco");
INSERT INTO "races" VALUES ("101", "2018", "3", "2018-10-01", "14:00:00");
INSERT INTO "races" VALUES ("102", "2019", "3", "2019-09-29", "15:10:00");
INSERT INTO "races" VALUES ("103", "2020", "3", "2020-10-04", "13:30:00");
INSERT INTO "races" VALUES ("104", "2021", "3", "2021-10-03", "14:15:00");
INSERT INTO "races" VALUES ("105", "2022", "3", "2022-10-02", "14:05:00");
INSERT INTO "races" VALUES ("201", "2018", "1", "2018-07-08", "15:00:00");
INSERT INTO "races" VALUES ("202", "2019", "2", "2019-09-08", "14:00:00");
INSERT INTO "races" VALUES ("203", "2020", "4", "2020-10-11", "13:45:00");
INSERT INTO "races" VALUES ("204", "2021", "5", "2021-05-23", "15:00:00");
INSERT INTO "races" VALUES ("205", "2022", "1", "2022-07-10", "14:50:00");