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

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", "Circuit de Barcelona-Catalunya", "Spain", "http://www.circuitcat.com");
INSERT INTO "circuits" VALUES ("2", "Jerez Circuit", "Spain", "http://www.circuitodejerez.com");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "United Kingdom", "http://www.silverstone.co.uk");
INSERT INTO "circuits" VALUES ("4", "Monza Circuit", "Italy", "http://www.monzanet.it");
INSERT INTO "circuits" VALUES ("5", "Circuit Ricardo Tormo", "Spain", "http://www.circuitvalencia.com");
INSERT INTO "races" VALUES ("101", "2009", "1", "Spanish Grand Prix", "2009-05-10");
INSERT INTO "races" VALUES ("102", "2009", "2", "Spanish Grand Prix", "2009-05-17");
INSERT INTO "races" VALUES ("103", "2008", "1", "Spanish Grand Prix", "2008-05-11");
INSERT INTO "races" VALUES ("104", "2010", "1", "Spanish Grand Prix", "2010-05-09");
INSERT INTO "races" VALUES ("105", "2009", "3", "British Grand Prix", "2009-07-12");
INSERT INTO "races" VALUES ("106", "2009", "5", "Spanish Grand Prix", "2009-06-15");