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 "constructors" (
"constructorId" INT,
"name" TEXT,
PRIMARY KEY ("constructorId")
);

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

CREATE TABLE "qualifying" (
"qualifyId" INT,
"raceId" INT,
"driverId" INT,
"q2" TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

CREATE TABLE "races" (
"raceId" INT UNIQUE,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"position" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "driverStandings" VALUES ("1", "10.0");
INSERT INTO "driverStandings" VALUES ("2", "15.0");
INSERT INTO "driverStandings" VALUES ("3", "8.0");
INSERT INTO "driverStandings" VALUES ("4", "25.0");
INSERT INTO "driverStandings" VALUES ("5", "12.0");
INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull Racing");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Aston Martin");
INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "Dutch");
INSERT INTO "drivers" VALUES ("3", "German");
INSERT INTO "drivers" VALUES ("4", "Spanish");
INSERT INTO "drivers" VALUES ("5", "French");
INSERT INTO "drivers" VALUES ("6", "Finnish");
INSERT INTO "drivers" VALUES ("7", "Mexican");
INSERT INTO "races" VALUES ("345");
INSERT INTO "races" VALUES ("346");
INSERT INTO "races" VALUES ("347");
INSERT INTO "races" VALUES ("348");
INSERT INTO "races" VALUES ("349");
INSERT INTO "qualifying" VALUES ("1", "345", "1", "0:01:18");
INSERT INTO "qualifying" VALUES ("2", "345", "2", "0:01:17");
INSERT INTO "qualifying" VALUES ("3", "346", "3", "0:01:16");
INSERT INTO "qualifying" VALUES ("4", "347", "4", "0:01:15");
INSERT INTO "qualifying" VALUES ("5", "347", "5", "0:01:16");
INSERT INTO "qualifying" VALUES ("6", "347", "6", "0:01:15");
INSERT INTO "qualifying" VALUES ("7", "348", "7", "0:01:14");
INSERT INTO "qualifying" VALUES ("8", "348", "1", "0:01:15");
INSERT INTO "qualifying" VALUES ("9", "349", "2", "0:01:13");
INSERT INTO "qualifying" VALUES ("10", "349", "3", "0:01:14");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "1");
INSERT INTO "results" VALUES ("5", "4");