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 "constructorResults" (
"constructorResultsId" INT,
"points" FLOAT,
PRIMARY KEY ("constructorResultsId")
);

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

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
PRIMARY KEY ("driverId")
);

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

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"date" DATE,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"time" TEXT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "constructorResults" VALUES ("1", "10.0");
INSERT INTO "constructorResults" VALUES ("2", "15.0");
INSERT INTO "constructorResults" VALUES ("3", "25.0");
INSERT INTO "constructorResults" VALUES ("4", "0.0");
INSERT INTO "constructorResults" VALUES ("5", "12.0");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Ferrari");
INSERT INTO "constructors" VALUES ("3", "Red Bull");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Williams");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Nico", "Rosberg");
INSERT INTO "drivers" VALUES ("3", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("4", "Kimi", "Raikkonen");
INSERT INTO "drivers" VALUES ("5", "Daniel", "Ricciardo");
INSERT INTO "drivers" VALUES ("6", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("7", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("8", "Jenson", "Button");
INSERT INTO "drivers" VALUES ("9", "Felipe", "Massa");
INSERT INTO "drivers" VALUES ("10", "Valtteri", "Bottas");
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-11-29");
INSERT INTO "races" VALUES ("2", "2015-11-22");
INSERT INTO "races" VALUES ("3", "2016-03-20");
INSERT INTO "races" VALUES ("4", "2015-10-25");
INSERT INTO "races" VALUES ("5", "2016-04-03");
INSERT INTO "results" VALUES ("1", "1", "1", "1:38:00.000");
INSERT INTO "results" VALUES ("2", "1", "2", "1:38:05.000");
INSERT INTO "results" VALUES ("3", "1", "3", "1:38:10.000");
INSERT INTO "results" VALUES ("4", "1", "4", "1:38:15.000");
INSERT INTO "results" VALUES ("5", "1", "5", "1:38:20.000");
INSERT INTO "results" VALUES ("6", "1", "6", "1:38:25.000");
INSERT INTO "results" VALUES ("7", "1", "7", "NULL");
INSERT INTO "results" VALUES ("8", "1", "8", "NULL");
INSERT INTO "results" VALUES ("9", "2", "1", "1:30:00.000");
INSERT INTO "results" VALUES ("10", "2", "2", "1:30:02.000");
INSERT INTO "results" VALUES ("11", "3", "3", "1:45:00.000");
INSERT INTO "results" VALUES ("12", "3", "4", "1:45:05.000");
INSERT INTO "results" VALUES ("13", "4", "9", "1:35:00.000");
INSERT INTO "results" VALUES ("14", "4", "10", "1:35:02.000");
INSERT INTO "results" VALUES ("15", "5", "1", "1:40:00.000");