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

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

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



INSERT INTO "circuits" VALUES ("1", "Indianapolis Motor Speedway", "Indianapolis", "USA", "218");
INSERT INTO "circuits" VALUES ("2", "Circuit of the Americas", "Austin", "USA", "231");
INSERT INTO "circuits" VALUES ("3", "Long Beach Street Circuit", "Long Beach", "USA", "15");
INSERT INTO "circuits" VALUES ("4", "Monza", "Monza", "Italy", "162");
INSERT INTO "circuits" VALUES ("5", "Silverstone Circuit", "Silverstone", "UK", "150");
INSERT INTO "constructors" VALUES ("1", "Ferrari");
INSERT INTO "constructors" VALUES ("2", "McLaren");
INSERT INTO "constructors" VALUES ("3", "Williams");
INSERT INTO "races" VALUES ("101", "2006", "1", "United States Grand Prix", "2006-06-18");
INSERT INTO "races" VALUES ("102", "2006", "3", "Long Beach Grand Prix", "2006-04-09");
INSERT INTO "races" VALUES ("103", "2007", "2", "United States Grand Prix", "2007-06-17");
INSERT INTO "races" VALUES ("104", "2006", "4", "Italian Grand Prix", "2006-09-10");
INSERT INTO "races" VALUES ("105", "2005", "1", "United States Grand Prix", "2005-06-19");