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", "Sepang International Circuit", "Malaysia");
INSERT INTO "circuits" VALUES ("2", "Silverstone Circuit", "United Kingdom");
INSERT INTO "circuits" VALUES ("3", "Monza Circuit", "Italy");
INSERT INTO "circuits" VALUES ("4", "Suzuka Circuit", "Japan");
INSERT INTO "circuits" VALUES ("5", "Circuit of the Americas", "USA");
INSERT INTO "races" VALUES ("101", "2018", "1", "2018-09-16", "14:00:00");
INSERT INTO "races" VALUES ("102", "2019", "1", "2019-09-15", "13:30:00");
INSERT INTO "races" VALUES ("103", "2020", "1", "2020-09-13", "15:00:00");
INSERT INTO "races" VALUES ("104", "2021", "1", "2021-09-12", "14:30:00");
INSERT INTO "races" VALUES ("105", "2022", "1", "2022-09-18", "14:00:00");
INSERT INTO "races" VALUES ("106", "2023", "1", "2023-09-17", "14:00:00");
INSERT INTO "races" VALUES ("107", "2023", "1", "2023-09-17", "16:00:00");
INSERT INTO "races" VALUES ("201", "2018", "2", "2018-07-08", "15:10:00");
INSERT INTO "races" VALUES ("202", "2019", "2", "2019-07-14", "15:00:00");
INSERT INTO "races" VALUES ("203", "2020", "2", "2020-08-02", "15:00:00");
INSERT INTO "races" VALUES ("301", "2018", "3", "2018-09-02", "14:00:00");
INSERT INTO "races" VALUES ("302", "2019", "3", "2019-09-01", "14:30:00");
INSERT INTO "races" VALUES ("401", "2018", "4", "2018-10-07", "13:00:00");
INSERT INTO "races" VALUES ("402", "2019", "4", "2019-10-13", "13:30:00");
INSERT INTO "races" VALUES ("501", "2018", "5", "2018-03-25", "14:00:00");
INSERT INTO "races" VALUES ("502", "2019", "5", "2019-03-24", "14:00:00");