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

CREATE TABLE "constructors" (
"constructorId" INT,
"name" TEXT,
PRIMARY KEY ("constructorId")
);

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

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

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

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



INSERT INTO "constructorResults" VALUES ("1", "15.0");
INSERT INTO "constructorResults" VALUES ("2", "10.0");
INSERT INTO "constructorResults" VALUES ("3", "5.0");
INSERT INTO "constructorResults" VALUES ("4", "2.0");
INSERT INTO "constructorResults" VALUES ("5", "0.0");
INSERT INTO "constructors" VALUES ("1", "Ferrari");
INSERT INTO "constructors" VALUES ("2", "Mercedes");
INSERT INTO "constructors" VALUES ("3", "Red Bull");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Williams");
INSERT INTO "drivers" VALUES ("1", "Alex", "Yoong");
INSERT INTO "drivers" VALUES ("2", "Michael", "Schumacher");
INSERT INTO "drivers" VALUES ("3", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("4", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("5", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("6", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("7", "Kimi", "Raikkonen");
INSERT INTO "drivers" VALUES ("8", "Valtteri", "Bottas");
INSERT INTO "drivers" VALUES ("9", "Daniel", "Ricciardo");
INSERT INTO "drivers" VALUES ("10", "Lando", "Norris");
INSERT INTO "qualifying" VALUES ("1", "1");
INSERT INTO "qualifying" VALUES ("2", "5");
INSERT INTO "qualifying" VALUES ("3", "10");
INSERT INTO "qualifying" VALUES ("4", "15");
INSERT INTO "qualifying" VALUES ("5", "20");
INSERT INTO "races" VALUES ("1", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("2", "Australian Grand Prix");
INSERT INTO "races" VALUES ("3", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("4", "British Grand Prix");
INSERT INTO "races" VALUES ("5", "Italian Grand Prix");
INSERT INTO "races" VALUES ("6", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("7", "Brazilian Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "18");
INSERT INTO "results" VALUES ("2", "2", "1", "21");
INSERT INTO "results" VALUES ("3", "3", "1", "19");
INSERT INTO "results" VALUES ("4", "4", "2", "1");
INSERT INTO "results" VALUES ("5", "1", "3", "2");
INSERT INTO "results" VALUES ("6", "2", "4", "1");
INSERT INTO "results" VALUES ("7", "3", "5", "3");
INSERT INTO "results" VALUES ("8", "4", "6", "5");
INSERT INTO "results" VALUES ("9", "5", "7", "4");
INSERT INTO "results" VALUES ("10", "6", "8", "6");
INSERT INTO "results" VALUES ("11", "7", "9", "7");
INSERT INTO "results" VALUES ("12", "1", "10", "8");
INSERT INTO "results" VALUES ("13", "5", "1", "17");
INSERT INTO "results" VALUES ("14", "6", "1", "20");
INSERT INTO "results" VALUES ("15", "7", "1", "16");