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

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

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



INSERT INTO "drivers" VALUES ("1", "rkubica", "Robert", "Kubica");
INSERT INTO "drivers" VALUES ("2", "lhamilton", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("3", "vverstappen", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("4", "sainz", "Carlos", "Sainz");
INSERT INTO "drivers" VALUES ("5", "nrosberg", "Nico", "Rosberg");
INSERT INTO "qualifying" VALUES ("1", "1", "2");
INSERT INTO "qualifying" VALUES ("2", "2", "1");
INSERT INTO "qualifying" VALUES ("3", "3", "3");
INSERT INTO "qualifying" VALUES ("4", "4", "4");
INSERT INTO "qualifying" VALUES ("5", "5", "5");
INSERT INTO "results" VALUES ("1", "3");
INSERT INTO "results" VALUES ("2", "1");
INSERT INTO "results" VALUES ("3", "2");
INSERT INTO "results" VALUES ("4", "5");
INSERT INTO "results" VALUES ("5", "4");