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

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



INSERT INTO "circuits" VALUES ("1", "Sepang International Circuit", "Sepang", "Malaysia");
INSERT INTO "circuits" VALUES ("2", "Silverstone Circuit", "Silverstone", "United Kingdom");
INSERT INTO "circuits" VALUES ("3", "Monza Circuit", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("4", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("5", "Circuit of the Americas", "Austin", "USA");
INSERT INTO "races" VALUES ("101", "2018", "1", "Malaysian Grand Prix", "2018-10-01", "14:00:00", "http://f1.com/races/2018/malaysia");
INSERT INTO "races" VALUES ("102", "2019", "1", "Malaysian Grand Prix", "2019-09-29", "14:00:00", "http://f1.com/races/2019/malaysia");
INSERT INTO "races" VALUES ("103", "2020", "1", "Malaysian Grand Prix", "2020-09-27", "14:00:00", "http://f1.com/races/2020/malaysia");
INSERT INTO "races" VALUES ("104", "2021", "1", "Malaysian Grand Prix", "2021-09-26", "14:00:00", "http://f1.com/races/2021/malaysia");
INSERT INTO "races" VALUES ("105", "2022", "1", "Malaysian Grand Prix", "2022-09-25", "14:00:00", "http://f1.com/races/2022/malaysia");
INSERT INTO "races" VALUES ("201", "2019", "2", "British Grand Prix", "2019-07-14", "15:00:00", "http://f1.com/races/2019/britain");
INSERT INTO "races" VALUES ("202", "2020", "3", "Italian Grand Prix", "2020-09-06", "15:00:00", "http://f1.com/races/2020/italy");
INSERT INTO "races" VALUES ("203", "2021", "4", "Japanese Grand Prix", "2021-10-10", "14:00:00", "http://f1.com/races/2021/japan");
INSERT INTO "races" VALUES ("204", "2022", "5", "United States Grand Prix", "2022-10-23", "15:00:00", "http://f1.com/races/2022/usa");