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", "BMW Sauber");
INSERT INTO "constructors" VALUES ("6", "Red Bull");
INSERT INTO "constructors" VALUES ("7", "Toyota");
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");
INSERT INTO "drivers" VALUES ("2", "Felipe", "Massa");
INSERT INTO "drivers" VALUES ("3", "Kimi", "Räikkönen");
INSERT INTO "drivers" VALUES ("4", "Robert", "Kubica");
INSERT INTO "drivers" VALUES ("5", "Nick", "Heidfeld");
INSERT INTO "drivers" VALUES ("6", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("7", "Jarno", "Trulli");
INSERT INTO "drivers" VALUES ("8", "Mark", "Webber");
INSERT INTO "drivers" VALUES ("9", "Nico", "Rosberg");
INSERT INTO "drivers" VALUES ("10", "Kazuki", "Nakajima");
INSERT INTO "drivers" VALUES ("11", "Rubens", "Barrichello");
INSERT INTO "drivers" VALUES ("12", "David", "Coulthard");
INSERT INTO "drivers" VALUES ("13", "Timo", "Glock");
INSERT INTO "drivers" VALUES ("14", "Takuma", "Sato");
INSERT INTO "drivers" VALUES ("15", "Nelson", "Piquet Jr.");
INSERT INTO "drivers" VALUES ("16", "Giancarlo", "Fisichella");
INSERT INTO "drivers" VALUES ("17", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("18", "Adrian", "Sutil");
INSERT INTO "drivers" VALUES ("19", "Anthony", "Davidson");
INSERT INTO "drivers" VALUES ("20", "Jenson", "Button");
INSERT INTO "drivers" VALUES ("21", "Sebastien", "Bourdais");
INSERT INTO "drivers" VALUES ("22", "Heikki", "Kovalainen");
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", "2007", "Australian Grand Prix");
INSERT INTO "races" VALUES ("5", "2009", "Australian Grand Prix");
INSERT INTO "races" VALUES ("6", "2008", "Chinese Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "1:34:50.616");
INSERT INTO "results" VALUES ("2", "1", "5", "1:34:56.469");
INSERT INTO "results" VALUES ("3", "1", "9", "1:34:57.006");
INSERT INTO "results" VALUES ("4", "1", "6", "1:34:57.163");
INSERT INTO "results" VALUES ("5", "1", "7", "1:34:58.208");
INSERT INTO "results" VALUES ("6", "1", "10", "1:34:58.280");
INSERT INTO "results" VALUES ("7", "1", "11", "1:34:58.831");
INSERT INTO "results" VALUES ("8", "1", "13", "1:34:59.282");
INSERT INTO "results" VALUES ("9", "1", "14", "1:34:59.883");
INSERT INTO "results" VALUES ("10", "1", "18", "1:35:00.100");
INSERT INTO "results" VALUES ("11", "1", "21", "1:35:00.500");
INSERT INTO "results" VALUES ("12", "1", "22", "1:35:01.000");
INSERT INTO "results" VALUES ("13", "1", "2", "\N");
INSERT INTO "results" VALUES ("14", "1", "3", "\N");
INSERT INTO "results" VALUES ("15", "1", "4", "\N");
INSERT INTO "results" VALUES ("16", "1", "8", "\N");
INSERT INTO "results" VALUES ("17", "1", "12", "\N");
INSERT INTO "results" VALUES ("18", "1", "15", "\N");
INSERT INTO "results" VALUES ("19", "1", "16", "\N");
INSERT INTO "results" VALUES ("20", "1", "17", "\N");
INSERT INTO "results" VALUES ("21", "1", "19", "\N");
INSERT INTO "results" VALUES ("22", "1", "20", "\N");
INSERT INTO "results" VALUES ("23", "2", "1", "1:31:42.145");
INSERT INTO "results" VALUES ("24", "2", "3", "1:31:47.600");
INSERT INTO "results" VALUES ("25", "2", "5", "1:31:48.000");
INSERT INTO "results" VALUES ("26", "2", "2", "\N");
INSERT INTO "results" VALUES ("27", "4", "1", "1:34:50.616");
INSERT INTO "results" VALUES ("28", "4", "5", "1:34:56.469");
INSERT INTO "results" VALUES ("29", "5", "1", "1:34:50.616");
INSERT INTO "results" VALUES ("30", "5", "5", "1:34:56.469");
INSERT INTO "results" VALUES ("31", "6", "1", "1:34:50.616");
INSERT INTO "results" VALUES ("32", "6", "5", "1:34:56.469");