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

CREATE TABLE "circuits" (
"circuitId" INT,
"name" TEXT,
PRIMARY KEY ("circuitId")
);

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 "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 "driverStandings" VALUES ("1", "25.0");
INSERT INTO "driverStandings" VALUES ("2", "18.0");
INSERT INTO "driverStandings" VALUES ("3", "15.0");
INSERT INTO "driverStandings" VALUES ("4", "12.0");
INSERT INTO "driverStandings" VALUES ("5", "10.0");
INSERT INTO "circuits" VALUES ("1", "Albert Park Grand Prix Circuit");
INSERT INTO "circuits" VALUES ("2", "Sepang International Circuit");
INSERT INTO "circuits" VALUES ("3", "Bahrain International Circuit");
INSERT INTO "circuits" VALUES ("4", "Circuit de Catalunya");
INSERT INTO "circuits" VALUES ("5", "Istanbul Park");
INSERT INTO "circuits" VALUES ("6", "Circuit de Monaco");
INSERT INTO "circuits" VALUES ("7", "Circuit Gilles Villeneuve");
INSERT INTO "circuits" VALUES ("8", "Circuit de Nevers Magny-Cours");
INSERT INTO "circuits" VALUES ("9", "Silverstone Circuit");
INSERT INTO "circuits" VALUES ("10", "Hockenheimring");
INSERT INTO "constructors" VALUES ("1", "Ferrari");
INSERT INTO "constructors" VALUES ("2", "McLaren");
INSERT INTO "constructors" VALUES ("3", "BMW Sauber");
INSERT INTO "constructors" VALUES ("4", "Renault");
INSERT INTO "constructors" VALUES ("5", "Williams");
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", "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 "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", "2008", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("5", "2008", "Turkish Grand Prix");
INSERT INTO "races" VALUES ("6", "2008", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("7", "2008", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("8", "2008", "French Grand Prix");
INSERT INTO "races" VALUES ("9", "2008", "British Grand Prix");
INSERT INTO "races" VALUES ("10", "2008", "German Grand Prix");
INSERT INTO "races" VALUES ("11", "2007", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("12", "2009", "Canadian Grand Prix");
INSERT INTO "results" VALUES ("1", "7", "1", "1", "1:34:21.873");
INSERT INTO "results" VALUES ("2", "7", "4", "2", "1:34:26.345");
INSERT INTO "results" VALUES ("3", "7", "5", "3", "1:34:27.123");
INSERT INTO "results" VALUES ("4", "7", "2", "4", "1:34:28.987");
INSERT INTO "results" VALUES ("5", "7", "3", "5", "1:34:29.567");
INSERT INTO "results" VALUES ("6", "7", "6", "6", "1:34:30.001");
INSERT INTO "results" VALUES ("7", "7", "7", "7", "1:34:31.234");
INSERT INTO "results" VALUES ("8", "7", "8", "8", "1:34:32.456");
INSERT INTO "results" VALUES ("9", "7", "9", "9", "1:34:33.789");
INSERT INTO "results" VALUES ("10", "7", "10", "10", "1:34:34.999");
INSERT INTO "results" VALUES ("11", "1", "1", "1", "1:34:50.000");
INSERT INTO "results" VALUES ("12", "11", "1", "1", "1:34:21.873");
INSERT INTO "results" VALUES ("13", "12", "1", "1", "1:34:21.873");