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

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

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

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



INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Ferrari");
INSERT INTO "constructors" VALUES ("3", "Red Bull");
INSERT INTO "constructors" VALUES ("4", "Force India");
INSERT INTO "constructors" VALUES ("5", "Williams");
INSERT INTO "constructors" VALUES ("6", "McLaren");
INSERT INTO "constructors" VALUES ("7", "Toro Rosso");
INSERT INTO "constructors" VALUES ("8", "Haas F1 Team");
INSERT INTO "constructors" VALUES ("9", "Renault");
INSERT INTO "constructors" VALUES ("10", "Sauber");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton", "British");
INSERT INTO "drivers" VALUES ("2", "Sebastian", "Vettel", "German");
INSERT INTO "drivers" VALUES ("3", "Valtteri", "Bottas", "Finnish");
INSERT INTO "drivers" VALUES ("4", "Kimi", "Raikkonen", "Finnish");
INSERT INTO "drivers" VALUES ("5", "Max", "Verstappen", "Dutch");
INSERT INTO "drivers" VALUES ("6", "Daniel", "Ricciardo", "Australian");
INSERT INTO "drivers" VALUES ("7", "Sergio", "Perez", "Mexican");
INSERT INTO "drivers" VALUES ("8", "Esteban", "Ocon", "French");
INSERT INTO "drivers" VALUES ("9", "Felipe", "Massa", "Brazilian");
INSERT INTO "drivers" VALUES ("10", "Lance", "Stroll", "Canadian");
INSERT INTO "drivers" VALUES ("11", "Fernando", "Alonso", "Spanish");
INSERT INTO "drivers" VALUES ("12", "Stoffel", "Vandoorne", "Belgian");
INSERT INTO "drivers" VALUES ("13", "Carlos", "Sainz", "Spanish");
INSERT INTO "drivers" VALUES ("14", "Daniil", "Kvyat", "Russian");
INSERT INTO "drivers" VALUES ("15", "Romain", "Grosjean", "French");
INSERT INTO "drivers" VALUES ("16", "Kevin", "Magnussen", "Danish");
INSERT INTO "drivers" VALUES ("17", "Nico", "Hulkenberg", "German");
INSERT INTO "drivers" VALUES ("18", "Jolyon", "Palmer", "British");
INSERT INTO "drivers" VALUES ("19", "Marcus", "Ericsson", "Swedish");
INSERT INTO "drivers" VALUES ("20", "Pascal", "Wehrlein", "German");
INSERT INTO "races" VALUES ("1", "2017", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2017", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("3", "2017", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("4", "2017", "Russian Grand Prix");
INSERT INTO "races" VALUES ("5", "2016", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("6", "2018", "Chinese Grand Prix");
INSERT INTO "results" VALUES ("1", "2", "1", "1", "1", "25.0");
INSERT INTO "results" VALUES ("2", "2", "2", "2", "2", "18.0");
INSERT INTO "results" VALUES ("3", "2", "5", "3", "3", "15.0");
INSERT INTO "results" VALUES ("4", "2", "6", "3", "4", "12.0");
INSERT INTO "results" VALUES ("5", "2", "3", "1", "5", "10.0");
INSERT INTO "results" VALUES ("6", "2", "4", "2", "6", "8.0");
INSERT INTO "results" VALUES ("7", "2", "7", "4", "7", "6.0");
INSERT INTO "results" VALUES ("8", "2", "8", "4", "8", "4.0");
INSERT INTO "results" VALUES ("9", "2", "9", "5", "9", "2.0");
INSERT INTO "results" VALUES ("10", "2", "10", "5", "10", "1.0");
INSERT INTO "results" VALUES ("11", "2", "11", "6", "11", "0.0");
INSERT INTO "results" VALUES ("12", "2", "13", "7", "12", "0.0");
INSERT INTO "results" VALUES ("13", "2", "15", "8", "13", "0.0");
INSERT INTO "results" VALUES ("14", "2", "17", "9", "14", "0.0");
INSERT INTO "results" VALUES ("15", "2", "19", "10", "15", "0.0");
INSERT INTO "results" VALUES ("16", "1", "1", "1", "1", "25.0");
INSERT INTO "results" VALUES ("17", "1", "2", "2", "2", "18.0");
INSERT INTO "results" VALUES ("18", "5", "1", "1", "1", "25.0");
INSERT INTO "results" VALUES ("19", "6", "2", "2", "1", "25.0");
INSERT INTO "results" VALUES ("20", "6", "1", "1", "2", "18.0");