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

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

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

CREATE TABLE "results" (
"resultId" INT,
"position" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "circuits" VALUES ("1", "Sepang International Circuit");
INSERT INTO "circuits" VALUES ("2", "Monza");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco");
INSERT INTO "circuits" VALUES ("5", "Suzuka Circuit");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Williams");
INSERT INTO "races" VALUES ("101", "2017", "1", "Malaysian Grand Prix", "http://en.wikipedia.org/wiki/2017_Malaysian_Grand_Prix");
INSERT INTO "races" VALUES ("102", "2016", "1", "Malaysian Grand Prix", "http://en.wikipedia.org/wiki/2016_Malaysian_Grand_Prix");
INSERT INTO "races" VALUES ("103", "2015", "2", "Italian Grand Prix", "http://en.wikipedia.org/wiki/2015_Italian_Grand_Prix");
INSERT INTO "races" VALUES ("104", "2014", "3", "British Grand Prix", "http://en.wikipedia.org/wiki/2014_British_Grand_Prix");
INSERT INTO "races" VALUES ("105", "2018", "1", "Malaysian Grand Prix", "http://en.wikipedia.org/wiki/2018_Malaysian_Grand_Prix");
INSERT INTO "races" VALUES ("106", "2019", "4", "Monaco Grand Prix", "http://en.wikipedia.org/wiki/2019_Monaco_Grand_Prix");
INSERT INTO "races" VALUES ("107", "2020", "5", "Japanese Grand Prix", "http://en.wikipedia.org/wiki/2020_Japanese_Grand_Prix");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "1");
INSERT INTO "results" VALUES ("5", "4");