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,
"surname" TEXT,
PRIMARY KEY ("driverId")
);

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"year" INT,
"round" INT,
"name" TEXT,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"grid" INT,
"position" INT,
"points" FLOAT,
"time" TEXT,
"milliseconds" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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



INSERT INTO "drivers" VALUES ("1", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Massa");
INSERT INTO "drivers" VALUES ("3", "Raikkonen");
INSERT INTO "drivers" VALUES ("4", "Alonso");
INSERT INTO "drivers" VALUES ("5", "Kubica");
INSERT INTO "drivers" VALUES ("6", "Button");
INSERT INTO "drivers" VALUES ("7", "Heidfeld");
INSERT INTO "drivers" VALUES ("8", "Barrichello");
INSERT INTO "drivers" VALUES ("9", "Kovalainen");
INSERT INTO "drivers" VALUES ("10", "Trulli");
INSERT INTO "races" VALUES ("101", "2008", "1", "Australian Grand Prix");
INSERT INTO "status" VALUES ("1", "Finished");
INSERT INTO "status" VALUES ("2", "Accident");
INSERT INTO "status" VALUES ("3", "Engine");
INSERT INTO "status" VALUES ("4", "Retired");
INSERT INTO "status" VALUES ("5", "Disqualified");
INSERT INTO "results" VALUES ("1001", "101", "1", "1", "1", "10.0", "1:24:19.123", "5059123");
INSERT INTO "results" VALUES ("1002", "101", "2", "2", "2", "8.0", "1:24:21.500", "5059500");
INSERT INTO "results" VALUES ("1003", "101", "3", "3", "3", "6.0", "1:24:21.500", "5059500");
INSERT INTO "results" VALUES ("1004", "101", "4", "4", "4", "5.0", "1:24:22.000", "5059200");
INSERT INTO "results" VALUES ("1005", "101", "5", "5", "5", "4.0", "1:24:23.000", "5059800");
INSERT INTO "results" VALUES ("1006", "101", "6", "6", "6", "3.0", "1:24:24.000", "5060400");
INSERT INTO "results" VALUES ("1007", "101", "7", "7", "7", "2.0", "1:24:25.000", "5061000");
INSERT INTO "results" VALUES ("1008", "101", "8", "8", "8", "1.0", "1:24:26.000", "5061600");
INSERT INTO "results" VALUES ("1009", "101", "9", "9", "9", "0.5", "1:24:27.000", "5062200");
INSERT INTO "results" VALUES ("1010", "101", "10", "10", "10", "0.0", "1:24:28.000", "5062800");