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

CREATE TABLE "qualifying" (
"qualifyId" INT,
"position" INT,
PRIMARY KEY ("qualifyId")
);

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



INSERT INTO "circuits" VALUES ("1", "Sepang International Circuit", "Malaysia");
INSERT INTO "circuits" VALUES ("2", "Circuit de Barcelona-Catalunya", "Spain");
INSERT INTO "circuits" VALUES ("3", "Silverstone Circuit", "UK");
INSERT INTO "circuits" VALUES ("4", "Monza Circuit", "Italy");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco", "Monaco");
INSERT INTO "circuits" VALUES ("6", "Suzuka International Racing Course", "Japan");
INSERT INTO "circuits" VALUES ("7", "Circuit of the Americas", "USA");
INSERT INTO "circuits" VALUES ("8", "Autódromo José Carlos Pace", "Brazil");
INSERT INTO "circuits" VALUES ("9", "Yas Marina Circuit", "UAE");
INSERT INTO "circuits" VALUES ("10", "Albert Park Circuit", "Australia");
INSERT INTO "qualifying" VALUES ("1", "1");
INSERT INTO "qualifying" VALUES ("2", "2");
INSERT INTO "qualifying" VALUES ("3", "3");
INSERT INTO "qualifying" VALUES ("4", "4");
INSERT INTO "qualifying" VALUES ("5", "5");
INSERT INTO "qualifying" VALUES ("6", "6");
INSERT INTO "qualifying" VALUES ("7", "7");
INSERT INTO "qualifying" VALUES ("8", "8");
INSERT INTO "qualifying" VALUES ("9", "9");
INSERT INTO "qualifying" VALUES ("10", "10");
INSERT INTO "races" VALUES ("1", "2015", "1", "1:31:42.574");
INSERT INTO "races" VALUES ("2", "2016", "2", "1:33:00.000");
INSERT INTO "races" VALUES ("3", "2017", "1", "1:30:45.000");
INSERT INTO "races" VALUES ("4", "2018", "3", "1:28:30.123");
INSERT INTO "races" VALUES ("5", "2019", "4", "1:18:00.000");
INSERT INTO "races" VALUES ("6", "2015", "5", "1:49:00.000");
INSERT INTO "races" VALUES ("7", "2016", "1", "1:32:15.000");
INSERT INTO "races" VALUES ("8", "2017", "6", "1:27:00.000");
INSERT INTO "races" VALUES ("9", "2018", "7", "1:35:00.000");
INSERT INTO "races" VALUES ("10", "2019", "8", "1:30:00.000");
INSERT INTO "races" VALUES ("11", "2015", "9", "1:38:00.000");
INSERT INTO "races" VALUES ("12", "2016", "10", "1:24:00.000");
INSERT INTO "races" VALUES ("13", "2017", "2", "1:31:00.000");
INSERT INTO "races" VALUES ("14", "2018", "1", "1:30:00.000");
INSERT INTO "races" VALUES ("15", "2019", "3", "1:29:00.000");