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

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"surname" TEXT,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

CREATE TABLE "results" (
"resultId" INT,
"driverId" INT,
"position" INT,
"statusId" INT,
PRIMARY KEY ("resultId"),
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 "driverStandings" VALUES ("1", "120.5");
INSERT INTO "driverStandings" VALUES ("2", "95.0");
INSERT INTO "driverStandings" VALUES ("3", "80.0");
INSERT INTO "driverStandings" VALUES ("4", "60.0");
INSERT INTO "driverStandings" VALUES ("5", "45.0");
INSERT INTO "driverStandings" VALUES ("6", "30.0");
INSERT INTO "driverStandings" VALUES ("7", "15.0");
INSERT INTO "drivers" VALUES ("1", "Smith", "American");
INSERT INTO "drivers" VALUES ("2", "Johnson", "American");
INSERT INTO "drivers" VALUES ("3", "Williams", "British");
INSERT INTO "drivers" VALUES ("4", "Brown", "German");
INSERT INTO "drivers" VALUES ("5", "Jones", "American");
INSERT INTO "drivers" VALUES ("6", "Garcia", "Spanish");
INSERT INTO "drivers" VALUES ("7", "Miller", "American");
INSERT INTO "status" VALUES ("1", "Finished");
INSERT INTO "status" VALUES ("2", "Puncture");
INSERT INTO "status" VALUES ("3", "Accident");
INSERT INTO "status" VALUES ("4", "Engine Failure");
INSERT INTO "status" VALUES ("5", "Disqualified");
INSERT INTO "results" VALUES ("1", "1", "5", "2");
INSERT INTO "results" VALUES ("2", "2", "12", "2");
INSERT INTO "results" VALUES ("3", "3", "1", "1");
INSERT INTO "results" VALUES ("4", "4", "8", "4");
INSERT INTO "results" VALUES ("5", "5", "15", "3");
INSERT INTO "results" VALUES ("6", "6", "3", "1");
INSERT INTO "results" VALUES ("7", "7", "20", "2");
INSERT INTO "results" VALUES ("8", "1", "7", "1");
INSERT INTO "results" VALUES ("9", "2", "10", "5");
INSERT INTO "results" VALUES ("10", "5", "18", "2");