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 "constructors" (
"constructorId" INT,
"name" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "drivers" (
"driverId" INT,
"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,
"rank" INT,
"fastestLapTime" TEXT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "constructors" VALUES ("1", "Ferrari");
INSERT INTO "constructors" VALUES ("2", "McLaren");
INSERT INTO "constructors" VALUES ("3", "Renault");
INSERT INTO "constructors" VALUES ("4", "Williams");
INSERT INTO "constructors" VALUES ("5", "Red Bull");
INSERT INTO "drivers" VALUES ("1", "Michael", "Schumacher");
INSERT INTO "drivers" VALUES ("2", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("3", "Felipe", "Massa");
INSERT INTO "drivers" VALUES ("4", "Jenson", "Button");
INSERT INTO "drivers" VALUES ("5", "Kimi", "Raikkonen");
INSERT INTO "drivers" VALUES ("6", "Giancarlo", "Fisichella");
INSERT INTO "drivers" VALUES ("7", "Rubens", "Barrichello");
INSERT INTO "drivers" VALUES ("8", "Mark", "Webber");
INSERT INTO "drivers" VALUES ("9", "Nick", "Heidfeld");
INSERT INTO "drivers" VALUES ("10", "Juan Pablo", "Montoya");
INSERT INTO "drivers" VALUES ("11", "Ralf", "Schumacher");
INSERT INTO "drivers" VALUES ("12", "David", "Coulthard");
INSERT INTO "drivers" VALUES ("13", "Jarno", "Trulli");
INSERT INTO "drivers" VALUES ("14", "Nico", "Rosberg");
INSERT INTO "drivers" VALUES ("15", "Scott", "Speed");
INSERT INTO "drivers" VALUES ("16", "Christijan", "Albers");
INSERT INTO "drivers" VALUES ("17", "Tiago", "Monteiro");
INSERT INTO "drivers" VALUES ("18", "Takuma", "Sato");
INSERT INTO "drivers" VALUES ("19", "Franck", "Montagny");
INSERT INTO "drivers" VALUES ("20", "Vitantonio", "Liuzzi");
INSERT INTO "drivers" VALUES ("21", "Christian", "Klien");
INSERT INTO "drivers" VALUES ("22", "Robert", "Doornbos");
INSERT INTO "races" VALUES ("1", "2006", "United States Grand Prix");
INSERT INTO "races" VALUES ("2", "2006", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("3", "2005", "United States Grand Prix");
INSERT INTO "races" VALUES ("4", "2007", "United States Grand Prix");
INSERT INTO "races" VALUES ("5", "2006", "Monaco Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "1", "1:12.777");
INSERT INTO "results" VALUES ("2", "1", "3", "2", "1:12.888");
INSERT INTO "results" VALUES ("3", "1", "2", "3", "1:13.001");
INSERT INTO "results" VALUES ("4", "1", "6", "4", "1:13.123");
INSERT INTO "results" VALUES ("5", "1", "7", "5", "1:13.250");
INSERT INTO "results" VALUES ("6", "1", "5", "6", "1:13.300");
INSERT INTO "results" VALUES ("7", "1", "10", "7", "1:13.450");
INSERT INTO "results" VALUES ("8", "1", "8", "8", "1:13.500");
INSERT INTO "results" VALUES ("9", "1", "9", "9", "1:13.600");
INSERT INTO "results" VALUES ("10", "1", "11", "10", "1:13.700");
INSERT INTO "results" VALUES ("11", "1", "12", "11", "1:13.800");
INSERT INTO "results" VALUES ("12", "1", "13", "12", "1:13.900");
INSERT INTO "results" VALUES ("13", "1", "14", "13", "1:14.000");
INSERT INTO "results" VALUES ("14", "1", "15", "14", "1:14.100");
INSERT INTO "results" VALUES ("15", "1", "16", "15", "1:14.200");
INSERT INTO "results" VALUES ("16", "1", "17", "16", "1:14.300");
INSERT INTO "results" VALUES ("17", "1", "18", "17", "1:14.400");
INSERT INTO "results" VALUES ("18", "1", "19", "18", "1:14.500");
INSERT INTO "results" VALUES ("19", "1", "20", "19", "1:14.600");
INSERT INTO "results" VALUES ("20", "1", "21", "20", "1:14.700");
INSERT INTO "results" VALUES ("21", "2", "1", "1", "1:31.450");
INSERT INTO "results" VALUES ("22", "2", "2", "2", "1:31.500");
INSERT INTO "results" VALUES ("23", "3", "1", "1", "1:11.000");
INSERT INTO "results" VALUES ("24", "4", "2", "1", "1:15.000");
INSERT INTO "results" VALUES ("25", "5", "1", "1", "1:15.000");
INSERT INTO "results" VALUES ("26", "5", "2", "2", "1:15.100");