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

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

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"year" INT,
"name" TEXT,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"position" 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", "8.0");
INSERT INTO "constructorResults" VALUES ("3", "6.0");
INSERT INTO "constructorResults" VALUES ("4", "5.0");
INSERT INTO "constructorResults" VALUES ("5", "4.0");
INSERT INTO "constructorResults" VALUES ("6", "3.0");
INSERT INTO "constructorResults" VALUES ("7", "2.0");
INSERT INTO "constructorResults" VALUES ("8", "1.0");
INSERT INTO "constructorResults" VALUES ("9", "0.0");
INSERT INTO "constructorResults" VALUES ("10", "0.0");
INSERT INTO "constructors" VALUES ("1", "McLaren");
INSERT INTO "constructors" VALUES ("2", "Ferrari");
INSERT INTO "constructors" VALUES ("3", "BMW Sauber");
INSERT INTO "constructors" VALUES ("4", "Williams");
INSERT INTO "constructors" VALUES ("5", "Renault");
INSERT INTO "constructors" VALUES ("6", "Toyota");
INSERT INTO "constructors" VALUES ("7", "Red Bull");
INSERT INTO "constructors" VALUES ("8", "Toro Rosso");
INSERT INTO "constructors" VALUES ("9", "Honda");
INSERT INTO "constructors" VALUES ("10", "Force India");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton", "http://en.wikipedia.org/wiki/Lewis_Hamilton");
INSERT INTO "drivers" VALUES ("2", "Nick", "Heidfeld", "http://en.wikipedia.org/wiki/Nick_Heidfeld");
INSERT INTO "drivers" VALUES ("3", "Nico", "Rosberg", "http://en.wikipedia.org/wiki/Nico_Rosberg");
INSERT INTO "drivers" VALUES ("4", "Fernando", "Alonso", "http://en.wikipedia.org/wiki/Fernando_Alonso");
INSERT INTO "drivers" VALUES ("5", "Heikki", "Kovalainen", "http://en.wikipedia.org/wiki/Heikki_Kovalainen");
INSERT INTO "drivers" VALUES ("6", "Rubens", "Barrichello", "http://en.wikipedia.org/wiki/Rubens_Barrichello");
INSERT INTO "drivers" VALUES ("7", "Kazuki", "Nakajima", "http://en.wikipedia.org/wiki/Kazuki_Nakajima");
INSERT INTO "drivers" VALUES ("8", "Sebastien", "Bourdais", "http://en.wikipedia.org/wiki/S%C3%A9bastien_Bourdais");
INSERT INTO "drivers" VALUES ("9", "Kimi", "Raikkonen", "http://en.wikipedia.org/wiki/Kimi_R%C3%A4ikk%C3%B6nen");
INSERT INTO "drivers" VALUES ("10", "Robert", "Kubica", "http://en.wikipedia.org/wiki/Robert_Kubica");
INSERT INTO "drivers" VALUES ("11", "Felipe", "Massa", "http://en.wikipedia.org/wiki/Felipe_Massa");
INSERT INTO "drivers" VALUES ("12", "Jarno", "Trulli", "http://en.wikipedia.org/wiki/Jarno_Trulli");
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", "2008", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2008", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("3", "2008", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("4", "2009", "Australian Grand Prix");
INSERT INTO "races" VALUES ("5", "2007", "Australian Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "1", "01:34:50.616");
INSERT INTO "results" VALUES ("2", "1", "2", "2", "01:34:56.296");
INSERT INTO "results" VALUES ("3", "1", "3", "3", "01:34:57.006");
INSERT INTO "results" VALUES ("4", "1", "4", "4", "01:34:57.616");
INSERT INTO "results" VALUES ("5", "1", "5", "5", "01:34:58.116");
INSERT INTO "results" VALUES ("6", "1", "6", "6", "01:34:59.000");
INSERT INTO "results" VALUES ("7", "1", "7", "7", "01:35:00.000");
INSERT INTO "results" VALUES ("8", "1", "8", "8", "01:35:01.000");
INSERT INTO "results" VALUES ("9", "1", "9", "9", "NULL");
INSERT INTO "results" VALUES ("10", "1", "10", "10", "NULL");
INSERT INTO "results" VALUES ("11", "1", "11", "11", "NULL");
INSERT INTO "results" VALUES ("12", "1", "12", "12", "NULL");
INSERT INTO "results" VALUES ("13", "2", "9", "1", "01:31:18.564");
INSERT INTO "results" VALUES ("14", "2", "10", "2", "01:31:23.000");
INSERT INTO "results" VALUES ("15", "4", "1", "1", "01:34:50.000");
INSERT INTO "results" VALUES ("16", "5", "1", "1", "01:34:50.000");