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 "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
"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,
"constructorId" INT,
"position" INT,
"positionText" TEXT,
"positionOrder" INT,
"points" FLOAT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "drivers" VALUES ("1", "Sebastian", "Vettel", "German");
INSERT INTO "drivers" VALUES ("2", "Fernando", "Alonso", "Spanish");
INSERT INTO "drivers" VALUES ("3", "Lewis", "Hamilton", "British");
INSERT INTO "drivers" VALUES ("4", "Mark", "Webber", "Australian");
INSERT INTO "drivers" VALUES ("5", "Jenson", "Button", "British");
INSERT INTO "drivers" VALUES ("6", "Felipe", "Massa", "Brazilian");
INSERT INTO "drivers" VALUES ("7", "Nico", "Rosberg", "German");
INSERT INTO "drivers" VALUES ("8", "Michael", "Schumacher", "German");
INSERT INTO "races" VALUES ("101", "2010", "Singapore Grand Prix");
INSERT INTO "races" VALUES ("102", "2010", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("103", "2010", "Belgian Grand Prix");
INSERT INTO "results" VALUES ("1001", "101", "1", "1", "1", "1", "1", "25.0");
INSERT INTO "results" VALUES ("1002", "101", "2", "2", "2", "2", "2", "18.0");
INSERT INTO "results" VALUES ("1003", "101", "3", "3", "3", "3", "3", "15.0");
INSERT INTO "results" VALUES ("1004", "101", "4", "1", "4", "4", "4", "12.0");
INSERT INTO "results" VALUES ("1005", "101", "5", "4", "5", "5", "5", "10.0");
INSERT INTO "results" VALUES ("1006", "101", "6", "5", "6", "6", "6", "8.0");
INSERT INTO "results" VALUES ("1007", "101", "7", "6", "7", "7", "7", "6.0");
INSERT INTO "results" VALUES ("1008", "101", "8", "7", "8", "8", "8", "4.0");
INSERT INTO "results" VALUES ("1009", "102", "1", "1", "2", "2", "2", "18.0");
INSERT INTO "results" VALUES ("1010", "103", "3", "3", "1", "1", "1", "25.0");