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 "driverStandings" (
"driverStandingsId" INT,
"position" INT,
PRIMARY KEY ("driverStandingsId")
);

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,
"year" INT,
"name" TEXT,
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 "driverStandings" VALUES ("1", "1");
INSERT INTO "driverStandings" VALUES ("2", "2");
INSERT INTO "driverStandings" VALUES ("3", "3");
INSERT INTO "driverStandings" VALUES ("4", "4");
INSERT INTO "driverStandings" VALUES ("5", "5");
INSERT INTO "driverStandings" VALUES ("6", "6");
INSERT INTO "driverStandings" VALUES ("7", "7");
INSERT INTO "driverStandings" VALUES ("8", "8");
INSERT INTO "driverStandings" VALUES ("9", "9");
INSERT INTO "driverStandings" VALUES ("10", "10");
INSERT INTO "constructors" VALUES ("1", "Ferrari");
INSERT INTO "constructors" VALUES ("2", "McLaren");
INSERT INTO "constructors" VALUES ("3", "Williams");
INSERT INTO "constructors" VALUES ("4", "Renault");
INSERT INTO "constructors" VALUES ("5", "Red Bull");
INSERT INTO "constructors" VALUES ("6", "Mercedes");
INSERT INTO "constructors" VALUES ("7", "Sauber");
INSERT INTO "constructors" VALUES ("8", "Force India");
INSERT INTO "constructors" VALUES ("9", "Toro Rosso");
INSERT INTO "constructors" VALUES ("10", "Honda");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Felipe", "Massa");
INSERT INTO "drivers" VALUES ("3", "Kimi", "Raikkonen");
INSERT INTO "drivers" VALUES ("4", "Robert", "Kubica");
INSERT INTO "drivers" VALUES ("5", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("6", "Nick", "Heidfeld");
INSERT INTO "drivers" VALUES ("7", "Heikki", "Kovalainen");
INSERT INTO "drivers" VALUES ("8", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("9", "Jarno", "Trulli");
INSERT INTO "drivers" VALUES ("10", "Timo", "Glock");
INSERT INTO "drivers" VALUES ("11", "Nico", "Rosberg");
INSERT INTO "drivers" VALUES ("12", "Rubens", "Barrichello");
INSERT INTO "drivers" VALUES ("13", "Jenson", "Button");
INSERT INTO "drivers" VALUES ("14", "Giancarlo", "Fisichella");
INSERT INTO "drivers" VALUES ("15", "Kazuki", "Nakajima");
INSERT INTO "drivers" VALUES ("16", "Nelson", "Piquet Jr.");
INSERT INTO "drivers" VALUES ("17", "Mark", "Webber");
INSERT INTO "drivers" VALUES ("18", "David", "Coulthard");
INSERT INTO "drivers" VALUES ("19", "Adrian", "Sutil");
INSERT INTO "drivers" VALUES ("20", "Sebastien", "Bourdais");
INSERT INTO "drivers" VALUES ("21", "Takuma", "Sato");
INSERT INTO "drivers" VALUES ("22", "Michael", "Schumacher");
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", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("2", "2008", "Brazilian Grand Prix");
INSERT INTO "races" VALUES ("3", "2007", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("4", "2008", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("5", "2009", "Australian Grand Prix");
INSERT INTO "races" VALUES ("6", "2008", "Malaysian Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "1:36:10.627");
INSERT INTO "results" VALUES ("2", "1", "2", "1:36:17.427");
INSERT INTO "results" VALUES ("3", "1", "3", "1:36:23.027");
INSERT INTO "results" VALUES ("4", "1", "4", "1:36:28.127");
INSERT INTO "results" VALUES ("5", "1", "5", "1:36:33.227");
INSERT INTO "results" VALUES ("6", "1", "6", "1:36:38.327");
INSERT INTO "results" VALUES ("7", "1", "7", "1:36:43.427");
INSERT INTO "results" VALUES ("8", "1", "8", "1:36:48.527");
INSERT INTO "results" VALUES ("9", "1", "9", "1:36:53.627");
INSERT INTO "results" VALUES ("10", "1", "10", "1:36:58.727");
INSERT INTO "results" VALUES ("11", "1", "11", "1:37:03.827");
INSERT INTO "results" VALUES ("12", "1", "12", "1:37:08.927");
INSERT INTO "results" VALUES ("13", "1", "13", "1:37:14.027");
INSERT INTO "results" VALUES ("14", "1", "14", "1:37:19.127");
INSERT INTO "results" VALUES ("15", "1", "15", "1:37:24.227");
INSERT INTO "results" VALUES ("16", "1", "16", "1:37:29.327");
INSERT INTO "results" VALUES ("17", "1", "17", "1:37:34.427");
INSERT INTO "results" VALUES ("18", "1", "18", "1:37:39.527");
INSERT INTO "results" VALUES ("19", "1", "19", "1:37:44.627");
INSERT INTO "results" VALUES ("20", "1", "20", "1:37:49.727");
INSERT INTO "results" VALUES ("21", "1", "21", "NULL");
INSERT INTO "results" VALUES ("22", "1", "22", "NULL");
INSERT INTO "results" VALUES ("23", "2", "1", "1:30:00.000");
INSERT INTO "results" VALUES ("24", "3", "5", "1:20:00.000");
INSERT INTO "results" VALUES ("25", "4", "8", "1:35:00.000");
INSERT INTO "results" VALUES ("26", "5", "13", "1:40:00.000");
INSERT INTO "results" VALUES ("27", "6", "1", "1:32:00.000");
INSERT INTO "results" VALUES ("28", "6", "21", "1:33:00.000");
INSERT INTO "results" VALUES ("29", "3", "22", "1:21:00.000");