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,
"location" TEXT,
"country" 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", "Melbourne", "Australia");
INSERT INTO "circuits" VALUES ("2", "Sepang", "Malaysia");
INSERT INTO "circuits" VALUES ("3", "Sakhir", "Bahrain");
INSERT INTO "circuits" VALUES ("4", "Shanghai", "China");
INSERT INTO "circuits" VALUES ("5", "Barcelona", "Spain");
INSERT INTO "circuits" VALUES ("6", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("7", "Montreal", "Canada");
INSERT INTO "circuits" VALUES ("8", "Spielberg", "Austria");
INSERT INTO "circuits" VALUES ("9", "Silverstone", "UK");
INSERT INTO "circuits" VALUES ("10", "Hockenheim", "Germany");
INSERT INTO "races" VALUES ("1", "2023", "1", "Australian Grand Prix", "2023-03-05", "15:00:00");
INSERT INTO "races" VALUES ("2", "2023", "3", "Bahrain Grand Prix", "2023-03-19", "18:00:00");
INSERT INTO "races" VALUES ("3", "2023", "4", "Chinese Grand Prix", "2023-04-02", "14:00:00");
INSERT INTO "races" VALUES ("4", "2022", "1", "Australian Grand Prix", "2022-04-10", "15:00:00");
INSERT INTO "races" VALUES ("5", "2022", "5", "Spanish Grand Prix", "2022-05-22", "15:00:00");
INSERT INTO "races" VALUES ("6", "2023", "9", "British Grand Prix", "2023-07-09", "15:00:00");
INSERT INTO "races" VALUES ("7", "2023", "7", "Canadian Grand Prix", "2023-06-18", "14:00:00");
INSERT INTO "races" VALUES ("8", "2023", "8", "Austrian Grand Prix", "2023-07-02", "15:00:00");
INSERT INTO "races" VALUES ("9", "2023", "5", "Spanish Grand Prix", "2023-06-04", "15:00:00");
INSERT INTO "races" VALUES ("10", "2023", "6", "Monaco Grand Prix", "2023-05-28", "15:00:00");