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

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

CREATE TABLE "seasons" (
"year" INT UNIQUE,
PRIMARY KEY ("year")
);



INSERT INTO "circuits" VALUES ("1", "Albert Park Grand Prix Circuit", "Australia");
INSERT INTO "circuits" VALUES ("2", "Sepang International Circuit", "Malaysia");
INSERT INTO "circuits" VALUES ("3", "Shanghai International Circuit", "China");
INSERT INTO "circuits" VALUES ("4", "Bahrain International Circuit", "Bahrain");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco", "Monaco");
INSERT INTO "circuits" VALUES ("6", "Silverstone Circuit", "United Kingdom");
INSERT INTO "circuits" VALUES ("7", "Hockenheimring", "Germany");
INSERT INTO "circuits" VALUES ("8", "Circuit de Spa-Francorchamps", "Belgium");
INSERT INTO "circuits" VALUES ("9", "Monza Circuit", "Italy");
INSERT INTO "circuits" VALUES ("10", "Suzuka Circuit", "Japan");
INSERT INTO "seasons" VALUES ("2004");
INSERT INTO "seasons" VALUES ("2005");
INSERT INTO "seasons" VALUES ("2006");
INSERT INTO "races" VALUES ("101", "2005", "United States Grand Prix", "2005-06-19");
INSERT INTO "races" VALUES ("102", "2005", "Turkish Grand Prix", "2005-08-21");
INSERT INTO "races" VALUES ("103", "2005", "Italian Grand Prix", "2005-09-11");
INSERT INTO "races" VALUES ("104", "2005", "Belgian Grand Prix", "2005-08-28");
INSERT INTO "races" VALUES ("105", "2005", "Monaco Grand Prix", "2005-05-22");
INSERT INTO "races" VALUES ("106", "2005", "British Grand Prix", "2005-07-10");
INSERT INTO "races" VALUES ("107", "2005", "Malaysian Grand Prix", "2005-04-03");
INSERT INTO "races" VALUES ("108", "2005", "Australian Grand Prix", "2005-03-06");
INSERT INTO "races" VALUES ("109", "2005", "Japanese Grand Prix", "2005-10-09");
INSERT INTO "races" VALUES ("110", "2005", "Chinese Grand Prix", "2005-10-16");
INSERT INTO "races" VALUES ("111", "2005", "Bahrain Grand Prix", "2005-04-03");
INSERT INTO "races" VALUES ("201", "2004", "Brazilian Grand Prix", "2004-03-07");
INSERT INTO "races" VALUES ("202", "2006", "Canadian Grand Prix", "2006-06-11");