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

CREATE TABLE "constructors" (
"constructorId" INT,
"name" TEXT,
PRIMARY KEY ("constructorId")
);

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

CREATE TABLE "status" (
"statusId" INT UNIQUE,
"status" TEXT,
PRIMARY KEY ("statusId")
);



INSERT INTO "constructorResults" VALUES ("1", "15.0");
INSERT INTO "constructorResults" VALUES ("2", "10.0");
INSERT INTO "constructorResults" VALUES ("3", "8.0");
INSERT INTO "constructorResults" VALUES ("4", "6.0");
INSERT INTO "constructorResults" VALUES ("5", "5.0");
INSERT INTO "constructorResults" VALUES ("6", "4.0");
INSERT INTO "constructorResults" VALUES ("7", "3.0");
INSERT INTO "constructorResults" VALUES ("8", "2.0");
INSERT INTO "constructorResults" VALUES ("9", "1.0");
INSERT INTO "constructorResults" VALUES ("10", "0.0");
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 "constructors" VALUES ("6", "Red Bull");
INSERT INTO "constructors" VALUES ("7", "Toyota");
INSERT INTO "constructors" VALUES ("8", "Super Aguri");
INSERT INTO "constructors" VALUES ("9", "Honda");
INSERT INTO "constructors" VALUES ("10", "Spyker");
INSERT INTO "drivers" VALUES ("1");
INSERT INTO "drivers" VALUES ("2");
INSERT INTO "drivers" VALUES ("3");
INSERT INTO "drivers" VALUES ("4");
INSERT INTO "drivers" VALUES ("5");
INSERT INTO "drivers" VALUES ("6");
INSERT INTO "drivers" VALUES ("7");
INSERT INTO "drivers" VALUES ("8");
INSERT INTO "drivers" VALUES ("9");
INSERT INTO "drivers" VALUES ("10");
INSERT INTO "drivers" VALUES ("11");
INSERT INTO "drivers" VALUES ("12");
INSERT INTO "drivers" VALUES ("13");
INSERT INTO "drivers" VALUES ("14");
INSERT INTO "drivers" VALUES ("15");
INSERT INTO "drivers" VALUES ("16");
INSERT INTO "drivers" VALUES ("17");
INSERT INTO "drivers" VALUES ("18");
INSERT INTO "drivers" VALUES ("19");
INSERT INTO "drivers" VALUES ("20");
INSERT INTO "drivers" VALUES ("21");
INSERT INTO "drivers" VALUES ("22");
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", "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", "2008", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("6", "2006", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("7", "2007", "Monaco Grand Prix");
INSERT INTO "status" VALUES ("1", "Finished");
INSERT INTO "status" VALUES ("2", "Disqualified");
INSERT INTO "status" VALUES ("3", "Accident");
INSERT INTO "status" VALUES ("4", "Engine");
INSERT INTO "status" VALUES ("5", "Gearbox");
INSERT INTO "status" VALUES ("6", "Collision");
INSERT INTO "status" VALUES ("7", "Retired");
INSERT INTO "status" VALUES ("8", "Spun off");
INSERT INTO "status" VALUES ("9", "Suspension");
INSERT INTO "status" VALUES ("10", "Brakes");
INSERT INTO "results" VALUES ("1", "3", "1", "1:33:27.515", "1");
INSERT INTO "results" VALUES ("2", "3", "2", "1:33:28.650", "1");
INSERT INTO "results" VALUES ("3", "3", "3", "1:33:30.123", "1");
INSERT INTO "results" VALUES ("4", "3", "4", "1:33:35.456", "1");
INSERT INTO "results" VALUES ("5", "3", "5", "1:33:40.789", "1");
INSERT INTO "results" VALUES ("6", "3", "6", "1:33:45.123", "1");
INSERT INTO "results" VALUES ("7", "3", "7", "1:33:50.456", "1");
INSERT INTO "results" VALUES ("8", "3", "8", "1:33:55.789", "1");
INSERT INTO "results" VALUES ("9", "3", "9", "1:34:00.123", "1");
INSERT INTO "results" VALUES ("10", "3", "10", "1:34:05.456", "1");
INSERT INTO "results" VALUES ("11", "3", "11", "NULL", "3");
INSERT INTO "results" VALUES ("12", "3", "12", "NULL", "4");
INSERT INTO "results" VALUES ("13", "3", "13", "NULL", "5");
INSERT INTO "results" VALUES ("14", "3", "14", "NULL", "6");
INSERT INTO "results" VALUES ("15", "3", "15", "NULL", "7");
INSERT INTO "results" VALUES ("16", "3", "16", "NULL", "8");
INSERT INTO "results" VALUES ("17", "3", "17", "NULL", "9");
INSERT INTO "results" VALUES ("18", "3", "18", "NULL", "10");
INSERT INTO "results" VALUES ("19", "3", "19", "NULL", "2");
INSERT INTO "results" VALUES ("20", "1", "20", "1:30:00.000", "1");
INSERT INTO "results" VALUES ("21", "2", "21", "1:35:00.000", "1");
INSERT INTO "results" VALUES ("22", "5", "22", "NULL", "3");
INSERT INTO "results" VALUES ("23", "6", "1", "NULL", "4");
INSERT INTO "results" VALUES ("24", "7", "2", "1:20:00.000", "1");