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

CREATE TABLE "constructors" (
"constructorId" INT,
"nationality" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "races" (
"raceId" INT,
"circuitId" INT,
"name" TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);



INSERT INTO "circuits" VALUES ("1", "marina_bay", "Marina Bay Street Circuit");
INSERT INTO "circuits" VALUES ("2", "silverstone", "Silverstone Circuit");
INSERT INTO "circuits" VALUES ("3", "monza", "Autodromo Nazionale Monza");
INSERT INTO "circuits" VALUES ("4", "spa", "Circuit de Spa-Francorchamps");
INSERT INTO "circuits" VALUES ("5", "monaco", "Circuit de Monaco");
INSERT INTO "constructors" VALUES ("1", "British");
INSERT INTO "constructors" VALUES ("2", "Italian");
INSERT INTO "constructors" VALUES ("3", "German");
INSERT INTO "constructors" VALUES ("4", "American");
INSERT INTO "races" VALUES ("1", "1", "Singapore Grand Prix");
INSERT INTO "races" VALUES ("2", "2", "British Grand Prix");
INSERT INTO "races" VALUES ("3", "3", "Italian Grand Prix");
INSERT INTO "races" VALUES ("4", "4", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("5", "5", "Monaco Grand Prix");