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,
"nationality" 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 "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", "Honda");
INSERT INTO "constructors" VALUES ("6", "Toyota");
INSERT INTO "constructors" VALUES ("7", "Red Bull");
INSERT INTO "constructors" VALUES ("8", "BMW Sauber");
INSERT INTO "constructors" VALUES ("9", "Force India");
INSERT INTO "constructors" VALUES ("10", "Brawn GP");
INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "German");
INSERT INTO "drivers" VALUES ("3", "Spanish");
INSERT INTO "drivers" VALUES ("4", "Finnish");
INSERT INTO "drivers" VALUES ("5", "Japanese");
INSERT INTO "drivers" VALUES ("6", "Brazilian");
INSERT INTO "drivers" VALUES ("7", "Italian");
INSERT INTO "drivers" VALUES ("8", "French");
INSERT INTO "drivers" VALUES ("9", "Japanese");
INSERT INTO "drivers" VALUES ("10", "Japanese");
INSERT INTO "drivers" VALUES ("11", "British");
INSERT INTO "races" VALUES ("1", "2007", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2007", "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", "2009", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("6", "2009", "Turkish Grand Prix");
INSERT INTO "races" VALUES ("7", "2006", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("8", "2010", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("9", "2007", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("10", "2008", "Singapore Grand Prix");
INSERT INTO "races" VALUES ("11", "2009", "Abu Dhabi Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "1", "1:34:50.616");
INSERT INTO "results" VALUES ("2", "1", "5", "10", "1:35:10.123");
INSERT INTO "results" VALUES ("3", "2", "5", "8", "1:30:45.789");
INSERT INTO "results" VALUES ("4", "3", "9", "12", "1:32:20.456");
INSERT INTO "results" VALUES ("5", "4", "9", "15", "NULL");
INSERT INTO "results" VALUES ("6", "5", "10", "7", "1:28:30.987");
INSERT INTO "results" VALUES ("7", "6", "10", "11", "NULL");
INSERT INTO "results" VALUES ("8", "1", "2", "2", "1:34:51.234");
INSERT INTO "results" VALUES ("9", "2", "3", "1", "1:30:40.111");
INSERT INTO "results" VALUES ("10", "3", "4", "3", "1:32:21.555");
INSERT INTO "results" VALUES ("11", "4", "1", "4", "1:25:00.000");
INSERT INTO "results" VALUES ("12", "5", "2", "5", "1:28:35.000");
INSERT INTO "results" VALUES ("13", "6", "3", "6", "1:33:00.000");
INSERT INTO "results" VALUES ("14", "9", "5", "9", "1:38:00.000");
INSERT INTO "results" VALUES ("15", "10", "9", "13", "NULL");
INSERT INTO "results" VALUES ("16", "11", "10", "14", "1:30:00.000");
INSERT INTO "results" VALUES ("17", "1", "9", "16", "NULL");
INSERT INTO "results" VALUES ("18", "2", "10", "17", "NULL");
INSERT INTO "results" VALUES ("19", "3", "5", "18", "1:33:00.000");
INSERT INTO "results" VALUES ("20", "4", "10", "19", "1:26:00.000");
INSERT INTO "results" VALUES ("21", "5", "5", "20", "NULL");
INSERT INTO "results" VALUES ("22", "6", "9", "21", "1:34:00.000");
INSERT INTO "results" VALUES ("23", "9", "9", "22", "1:39:00.000");
INSERT INTO "results" VALUES ("24", "10", "5", "23", "NULL");
INSERT INTO "results" VALUES ("25", "11", "9", "24", "1:31:00.000");