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,
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,
"position" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "constructors" VALUES ("1", "Mercedes");
INSERT INTO "constructors" VALUES ("2", "Red Bull");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Williams");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc");
INSERT INTO "drivers" VALUES ("4", "Lando", "Norris");
INSERT INTO "drivers" VALUES ("5", "George", "Russell");
INSERT INTO "drivers" VALUES ("6", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("7", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("8", "Valtteri", "Bottas");
INSERT INTO "drivers" VALUES ("9", "Daniel", "Ricciardo");
INSERT INTO "drivers" VALUES ("10", "Kimi", "Raikkonen");
INSERT INTO "races" VALUES ("1", "2009", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2010", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("3", "2010", "Australian Grand Prix");
INSERT INTO "races" VALUES ("4", "2011", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("5", "2011", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("6", "2012", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("7", "2012", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("8", "2013", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("9", "2013", "British Grand Prix");
INSERT INTO "races" VALUES ("10", "2014", "German Grand Prix");
INSERT INTO "races" VALUES ("11", "2014", "Hungarian Grand Prix");
INSERT INTO "races" VALUES ("12", "2015", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("13", "2015", "Italian Grand Prix");
INSERT INTO "races" VALUES ("14", "2016", "Singapore Grand Prix");
INSERT INTO "races" VALUES ("15", "2016", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("16", "2017", "United States Grand Prix");
INSERT INTO "races" VALUES ("17", "2017", "Mexican Grand Prix");
INSERT INTO "races" VALUES ("18", "2018", "Brazilian Grand Prix");
INSERT INTO "races" VALUES ("19", "2018", "Abu Dhabi Grand Prix");
INSERT INTO "races" VALUES ("20", "2019", "French Grand Prix");
INSERT INTO "races" VALUES ("21", "2019", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("22", "2020", "Styrian Grand Prix");
INSERT INTO "races" VALUES ("23", "2020", "Hungarian Grand Prix");
INSERT INTO "races" VALUES ("24", "2021", "Portuguese Grand Prix");
INSERT INTO "races" VALUES ("25", "2021", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("26", "2022", "Miami Grand Prix");
INSERT INTO "races" VALUES ("27", "2022", "Azerbaijan Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "3");
INSERT INTO "results" VALUES ("2", "2", "1", "1");
INSERT INTO "results" VALUES ("3", "3", "1", "6");
INSERT INTO "results" VALUES ("4", "4", "1", "1");
INSERT INTO "results" VALUES ("5", "5", "1", "2");
INSERT INTO "results" VALUES ("6", "6", "1", "8");
INSERT INTO "results" VALUES ("7", "7", "1", "1");
INSERT INTO "results" VALUES ("8", "8", "1", "3");
INSERT INTO "results" VALUES ("9", "9", "1", "1");
INSERT INTO "results" VALUES ("10", "10", "1", "1");
INSERT INTO "results" VALUES ("11", "11", "1", "3");
INSERT INTO "results" VALUES ("12", "12", "1", "1");
INSERT INTO "results" VALUES ("13", "13", "1", "2");
INSERT INTO "results" VALUES ("14", "14", "1", "3");
INSERT INTO "results" VALUES ("15", "15", "1", "1");
INSERT INTO "results" VALUES ("16", "16", "1", "1");
INSERT INTO "results" VALUES ("17", "17", "1", "9");
INSERT INTO "results" VALUES ("18", "18", "1", "1");
INSERT INTO "results" VALUES ("19", "19", "1", "4");
INSERT INTO "results" VALUES ("20", "20", "1", "1");
INSERT INTO "results" VALUES ("21", "21", "1", "5");
INSERT INTO "results" VALUES ("22", "22", "1", "4");
INSERT INTO "results" VALUES ("23", "23", "1", "1");
INSERT INTO "results" VALUES ("24", "24", "1", "1");
INSERT INTO "results" VALUES ("25", "25", "1", "2");
INSERT INTO "results" VALUES ("26", "26", "1", "13");
INSERT INTO "results" VALUES ("27", "27", "1", "8");
INSERT INTO "results" VALUES ("28", "2", "2", "2");
INSERT INTO "results" VALUES ("29", "3", "2", "1");
INSERT INTO "results" VALUES ("30", "4", "3", "5");
INSERT INTO "results" VALUES ("31", "5", "4", "7");
INSERT INTO "results" VALUES ("32", "6", "5", "1");
INSERT INTO "results" VALUES ("33", "7", "6", "2");
INSERT INTO "results" VALUES ("34", "8", "7", "1");
INSERT INTO "results" VALUES ("35", "9", "8", "2");
INSERT INTO "results" VALUES ("36", "10", "9", "5");
INSERT INTO "results" VALUES ("37", "11", "10", "1");