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,
"driverId" INT,
"points" FLOAT,
"position" INT,
PRIMARY KEY ("driverStandingsId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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

CREATE TABLE "qualifying" (
"qualifyId" INT,
"position" INT,
PRIMARY KEY ("qualifyId")
);

CREATE TABLE "results" (
"resultId" INT,
"driverId" INT,
"position" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton", "1985-01-07", "British");
INSERT INTO "drivers" VALUES ("2", "Sebastian", "Vettel", "1987-07-03", "German");
INSERT INTO "drivers" VALUES ("3", "Kimi", "Raikkonen", "1979-10-17", "Finnish");
INSERT INTO "drivers" VALUES ("4", "Fernando", "Alonso", "1981-07-29", "Spanish");
INSERT INTO "drivers" VALUES ("5", "Nico", "Rosberg", "1985-06-27", "German");
INSERT INTO "drivers" VALUES ("6", "Jenson", "Button", "1980-01-19", "British");
INSERT INTO "drivers" VALUES ("7", "Mika", "Hakkinen", "1968-09-28", "Finnish");
INSERT INTO "drivers" VALUES ("8", "Max", "Verstappen", "1997-09-30", "Dutch");
INSERT INTO "drivers" VALUES ("9", "Daniel", "Ricciardo", "1989-07-01", "Australian");
INSERT INTO "drivers" VALUES ("10", "Valtteri", "Bottas", "1989-08-28", "Finnish");
INSERT INTO "driverStandings" VALUES ("1", "1", "347.0", "1");
INSERT INTO "driverStandings" VALUES ("2", "2", "317.0", "2");
INSERT INTO "driverStandings" VALUES ("3", "3", "206.0", "3");
INSERT INTO "driverStandings" VALUES ("4", "4", "252.0", "2");
INSERT INTO "driverStandings" VALUES ("5", "5", "385.0", "1");
INSERT INTO "driverStandings" VALUES ("6", "6", "270.0", "2");
INSERT INTO "driverStandings" VALUES ("7", "7", "120.0", "5");
INSERT INTO "driverStandings" VALUES ("8", "8", "395.0", "1");
INSERT INTO "driverStandings" VALUES ("9", "9", "198.0", "4");
INSERT INTO "driverStandings" VALUES ("10", "10", "210.0", "2");
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 "results" VALUES ("1", "1", "1");
INSERT INTO "results" VALUES ("2", "2", "2");
INSERT INTO "results" VALUES ("3", "3", "3");
INSERT INTO "results" VALUES ("4", "4", "2");
INSERT INTO "results" VALUES ("5", "5", "1");
INSERT INTO "results" VALUES ("6", "6", "2");
INSERT INTO "results" VALUES ("7", "7", "4");
INSERT INTO "results" VALUES ("8", "8", "1");
INSERT INTO "results" VALUES ("9", "9", "5");
INSERT INTO "results" VALUES ("10", "10", "2");