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,
"round" 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", "Circuit de Monaco", "Monte Carlo", "Monaco");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "Silverstone", "United Kingdom");
INSERT INTO "circuits" VALUES ("4", "Circuit of the Americas", "Austin", "USA");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit", "Suzuka", "Japan");
INSERT INTO "circuits" VALUES ("6", "Spa-Francorchamps", "Stavelot", "Belgium");
INSERT INTO "circuits" VALUES ("7", "Monza Circuit", "Monza", "Italy");
INSERT INTO "circuits" VALUES ("8", "Marina Bay Street Circuit", "Singapore", "Singapore");
INSERT INTO "circuits" VALUES ("9", "Baku City Circuit", "Baku", "Azerbaijan");
INSERT INTO "circuits" VALUES ("10", "Yas Marina Circuit", "Abu Dhabi", "UAE");
INSERT INTO "races" VALUES ("101", "2017", "1", "1", "Australian Grand Prix", "2017-03-26");
INSERT INTO "races" VALUES ("102", "2017", "2", "9", "Azerbaijan Grand Prix", "2017-04-30");
INSERT INTO "races" VALUES ("103", "2017", "3", "6", "Belgian Grand Prix", "2017-08-27");
INSERT INTO "races" VALUES ("104", "2017", "4", "3", "British Grand Prix", "2017-07-16");
INSERT INTO "races" VALUES ("105", "2017", "5", "2", "Monaco Grand Prix", "2017-05-28");
INSERT INTO "races" VALUES ("106", "2017", "6", "7", "Italian Grand Prix", "2017-09-03");
INSERT INTO "races" VALUES ("107", "2017", "7", "8", "Singapore Grand Prix", "2017-09-17");
INSERT INTO "races" VALUES ("108", "2017", "8", "4", "United States Grand Prix", "2017-10-22");
INSERT INTO "races" VALUES ("109", "2017", "9", "5", "Japanese Grand Prix", "2017-10-08");
INSERT INTO "races" VALUES ("110", "2017", "10", "10", "Abu Dhabi Grand Prix", "2017-11-26");