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 "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 "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", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("5", "Robert", "Kubica");
INSERT INTO "drivers" VALUES ("6", "Nick", "Heidfeld");
INSERT INTO "drivers" VALUES ("7", "Nico", "Rosberg");
INSERT INTO "drivers" VALUES ("8", "Jarno", "Trulli");
INSERT INTO "drivers" VALUES ("9", "Mark", "Webber");
INSERT INTO "drivers" VALUES ("10", "David", "Coulthard");
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 "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 "results" VALUES ("1", "1", "1", "1:34:50.616");
INSERT INTO "results" VALUES ("2", "1", "2", "\N");
INSERT INTO "results" VALUES ("3", "1", "3", "1:34:51.234");
INSERT INTO "results" VALUES ("4", "1", "4", "1:34:52.111");
INSERT INTO "results" VALUES ("5", "1", "5", "\N");
INSERT INTO "results" VALUES ("6", "1", "6", "1:34:53.000");
INSERT INTO "results" VALUES ("7", "1", "7", "1:34:54.000");
INSERT INTO "results" VALUES ("8", "1", "8", "\N");
INSERT INTO "results" VALUES ("9", "1", "9", "1:34:55.000");
INSERT INTO "results" VALUES ("10", "1", "10", "\N");
INSERT INTO "results" VALUES ("11", "2", "1", "1:30:00.000");
INSERT INTO "results" VALUES ("12", "2", "2", "1:30:01.000");
INSERT INTO "results" VALUES ("13", "4", "1", "1:25:00.000");
INSERT INTO "results" VALUES ("14", "5", "1", "1:40:00.000");