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,
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", "Albert Park Grand Prix Circuit", "Melbourne", "Australia");
INSERT INTO "circuits" VALUES ("2", "Sepang International Circuit", "Kuala Lumpur", "Malaysia");
INSERT INTO "circuits" VALUES ("3", "Bahrain International Circuit", "Sakhir", "Bahrain");
INSERT INTO "circuits" VALUES ("4", "Circuit de Catalunya", "Montmeló", "Spain");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("6", "Circuit Gilles Villeneuve", "Montreal", "Canada");
INSERT INTO "circuits" VALUES ("7", "Silverstone Circuit", "Silverstone", "UK");
INSERT INTO "circuits" VALUES ("8", "Hockenheimring", "Hockenheim", "Germany");
INSERT INTO "circuits" VALUES ("9", "Hungaroring", "Mogyoród", "Hungary");
INSERT INTO "circuits" VALUES ("10", "Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("11", "Autodromo Nazionale Monza", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("12", "Marina Bay Street Circuit", "Marina Bay", "Singapore");
INSERT INTO "circuits" VALUES ("13", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("14", "Autódromo José Carlos Pace", "São Paulo", "Brazil");
INSERT INTO "circuits" VALUES ("15", "Yas Marina Circuit", "Abu Dhabi", "UAE");
INSERT INTO "races" VALUES ("1", "2009", "1", "Australian Grand Prix", "2009-03-29");
INSERT INTO "races" VALUES ("2", "2009", "2", "Malaysian Grand Prix", "2009-04-05");
INSERT INTO "races" VALUES ("3", "2009", "3", "Bahrain Grand Prix", "2009-04-26");
INSERT INTO "races" VALUES ("4", "2009", "4", "Spanish Grand Prix", "2009-05-10");
INSERT INTO "races" VALUES ("5", "2009", "5", "Monaco Grand Prix", "2009-05-24");
INSERT INTO "races" VALUES ("6", "2009", "6", "Canadian Grand Prix", "2009-06-07");
INSERT INTO "races" VALUES ("7", "2009", "7", "British Grand Prix", "2009-06-21");
INSERT INTO "races" VALUES ("8", "2009", "8", "German Grand Prix", "2009-07-12");
INSERT INTO "races" VALUES ("9", "2009", "9", "Hungarian Grand Prix", "2009-07-26");
INSERT INTO "races" VALUES ("10", "2009", "10", "European Grand Prix", "2009-08-23");
INSERT INTO "races" VALUES ("11", "2009", "11", "Belgian Grand Prix", "2009-08-30");
INSERT INTO "races" VALUES ("12", "2009", "12", "Italian Grand Prix", "2009-09-13");
INSERT INTO "races" VALUES ("13", "2009", "13", "Singapore Grand Prix", "2009-09-27");
INSERT INTO "races" VALUES ("14", "2009", "14", "Japanese Grand Prix", "2009-10-04");
INSERT INTO "races" VALUES ("15", "2009", "15", "Brazilian Grand Prix", "2009-10-18");
INSERT INTO "races" VALUES ("16", "2008", "4", "Spanish Grand Prix", "2008-04-27");
INSERT INTO "races" VALUES ("17", "2010", "4", "Spanish Grand Prix", "2010-05-09");
INSERT INTO "races" VALUES ("18", "2009", "1", "Chinese Grand Prix", "2009-04-19");