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 UNIQUE,
"driverRef" 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,
"constructorId" INT,
"position" INT,
"points" FLOAT,
"rank" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId"),
FOREIGN KEY ("constructorId") REFERENCES "constructors"("constructorId")
);



INSERT INTO "constructors" VALUES ("1", "McLaren");
INSERT INTO "constructors" VALUES ("2", "Ferrari");
INSERT INTO "constructors" VALUES ("3", "BMW Sauber");
INSERT INTO "constructors" VALUES ("4", "Renault");
INSERT INTO "constructors" VALUES ("5", "Williams");
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", "Super Aguri");
INSERT INTO "drivers" VALUES ("1", "hamilton");
INSERT INTO "drivers" VALUES ("2", "alonso");
INSERT INTO "drivers" VALUES ("3", "raikkonen");
INSERT INTO "drivers" VALUES ("4", "massa");
INSERT INTO "drivers" VALUES ("5", "heidfeld");
INSERT INTO "drivers" VALUES ("6", "kubica");
INSERT INTO "drivers" VALUES ("7", "rosberg");
INSERT INTO "drivers" VALUES ("8", "webber");
INSERT INTO "drivers" VALUES ("9", "coulthard");
INSERT INTO "drivers" VALUES ("10", "trulli");
INSERT INTO "drivers" VALUES ("11", "sato");
INSERT INTO "drivers" VALUES ("12", "vettel");
INSERT INTO "drivers" VALUES ("13", "button");
INSERT INTO "drivers" VALUES ("14", "barrichello");
INSERT INTO "drivers" VALUES ("15", "fisichella");
INSERT INTO "drivers" VALUES ("16", "kovalainen");
INSERT INTO "drivers" VALUES ("17", "speed");
INSERT INTO "drivers" VALUES ("18", "liuzzi");
INSERT INTO "drivers" VALUES ("19", "sutil");
INSERT INTO "drivers" VALUES ("20", "albers");
INSERT INTO "drivers" VALUES ("21", "wurz");
INSERT INTO "drivers" VALUES ("22", "davidson");
INSERT INTO "races" VALUES ("1", "2007", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2007", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("3", "2007", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("4", "2007", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("5", "2007", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("6", "2007", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("7", "2007", "United States Grand Prix");
INSERT INTO "races" VALUES ("8", "2007", "French Grand Prix");
INSERT INTO "races" VALUES ("9", "2007", "British Grand Prix");
INSERT INTO "races" VALUES ("10", "2007", "European Grand Prix");
INSERT INTO "races" VALUES ("11", "2007", "Hungarian Grand Prix");
INSERT INTO "races" VALUES ("12", "2007", "Turkish Grand Prix");
INSERT INTO "races" VALUES ("13", "2007", "Italian Grand Prix");
INSERT INTO "races" VALUES ("14", "2007", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("15", "2007", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("16", "2007", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("17", "2007", "Brazilian Grand Prix");
INSERT INTO "races" VALUES ("18", "2008", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("19", "2006", "Canadian Grand Prix");
INSERT INTO "results" VALUES ("1", "6", "1", "1", "1", "10.0", "1");
INSERT INTO "results" VALUES ("2", "6", "2", "1", "7", "2.0", "7");
INSERT INTO "results" VALUES ("3", "6", "3", "2", "5", "4.0", "5");
INSERT INTO "results" VALUES ("4", "6", "4", "2", "10", "0.0", "10");
INSERT INTO "results" VALUES ("5", "6", "5", "3", "6", "3.0", "6");
INSERT INTO "results" VALUES ("6", "6", "6", "3", "4", "5.0", "4");
INSERT INTO "results" VALUES ("7", "6", "7", "5", "8", "1.0", "8");
INSERT INTO "results" VALUES ("8", "6", "8", "6", "9", "0.0", "9");
INSERT INTO "results" VALUES ("9", "6", "9", "6", "11", "0.0", "11");
INSERT INTO "results" VALUES ("10", "6", "10", "7", "12", "0.0", "12");
INSERT INTO "results" VALUES ("11", "6", "11", "10", "13", "0.0", "13");
INSERT INTO "results" VALUES ("12", "6", "12", "8", "14", "0.0", "14");
INSERT INTO "results" VALUES ("13", "6", "13", "9", "15", "0.0", "15");
INSERT INTO "results" VALUES ("14", "6", "14", "9", "16", "0.0", "16");
INSERT INTO "results" VALUES ("15", "6", "15", "4", "17", "0.0", "17");
INSERT INTO "results" VALUES ("16", "6", "16", "4", "18", "0.0", "18");
INSERT INTO "results" VALUES ("17", "6", "17", "8", "19", "0.0", "19");
INSERT INTO "results" VALUES ("18", "6", "18", "8", "20", "0.0", "20");
INSERT INTO "results" VALUES ("19", "6", "19", "10", "21", "0.0", "21");
INSERT INTO "results" VALUES ("20", "6", "20", "9", "22", "0.0", "22");
INSERT INTO "results" VALUES ("21", "6", "21", "5", "2", "8.0", "2");
INSERT INTO "results" VALUES ("22", "6", "22", "7", "3", "6.0", "3");
INSERT INTO "results" VALUES ("23", "18", "1", "1", "2", "8.0", "2");
INSERT INTO "results" VALUES ("24", "18", "2", "4", "1", "10.0", "1");
INSERT INTO "results" VALUES ("25", "19", "1", "1", "3", "6.0", "3");
INSERT INTO "results" VALUES ("26", "19", "2", "4", "1", "10.0", "1");