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 "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Max", "Verstappen");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc");
INSERT INTO "drivers" VALUES ("4", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("5", "Valtteri", "Bottas");
INSERT INTO "races" VALUES ("1001", "2010", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1002", "2010", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1003", "2011", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1004", "2011", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("1005", "2012", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1006", "2012", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("1007", "2013", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1008", "2013", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("1009", "2014", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1010", "2014", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("1011", "2015", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1012", "2015", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("1013", "2016", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1014", "2016", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1015", "2017", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1016", "2017", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("1017", "2018", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1018", "2018", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1019", "2019", "Australian Grand Prix");
INSERT INTO "races" VALUES ("1020", "2019", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1021", "2020", "Austrian Grand Prix");
INSERT INTO "races" VALUES ("1022", "2020", "Styrian Grand Prix");
INSERT INTO "races" VALUES ("1023", "2021", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1024", "2021", "Emilia Romagna Grand Prix");
INSERT INTO "races" VALUES ("1025", "2022", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1026", "2022", "Saudi Arabian Grand Prix");
INSERT INTO "races" VALUES ("1027", "2023", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("1028", "2023", "Saudi Arabian Grand Prix");
INSERT INTO "results" VALUES ("1", "1001", "1", "2");
INSERT INTO "results" VALUES ("2", "1001", "2", "1");
INSERT INTO "results" VALUES ("3", "1003", "1", "1");
INSERT INTO "results" VALUES ("4", "1003", "3", "3");
INSERT INTO "results" VALUES ("5", "1005", "1", "3");
INSERT INTO "results" VALUES ("6", "1005", "4", "1");
INSERT INTO "results" VALUES ("7", "1007", "1", "5");
INSERT INTO "results" VALUES ("8", "1007", "5", "2");
INSERT INTO "results" VALUES ("9", "1009", "1", "1");
INSERT INTO "results" VALUES ("10", "1009", "2", "4");
INSERT INTO "results" VALUES ("11", "1011", "1", "1");
INSERT INTO "results" VALUES ("12", "1011", "3", "5");
INSERT INTO "results" VALUES ("13", "1013", "1", "2");
INSERT INTO "results" VALUES ("14", "1013", "4", "1");
INSERT INTO "results" VALUES ("15", "1015", "1", "2");
INSERT INTO "results" VALUES ("16", "1015", "2", "1");
INSERT INTO "results" VALUES ("17", "1017", "1", "2");
INSERT INTO "results" VALUES ("18", "1017", "3", "1");
INSERT INTO "results" VALUES ("19", "1019", "1", "2");
INSERT INTO "results" VALUES ("20", "1019", "5", "1");
INSERT INTO "results" VALUES ("21", "1021", "1", "4");
INSERT INTO "results" VALUES ("22", "1021", "2", "1");
INSERT INTO "results" VALUES ("23", "1023", "1", "3");
INSERT INTO "results" VALUES ("24", "1023", "2", "1");
INSERT INTO "results" VALUES ("25", "1025", "1", "3");
INSERT INTO "results" VALUES ("26", "1025", "3", "1");
INSERT INTO "results" VALUES ("27", "1027", "1", "5");
INSERT INTO "results" VALUES ("28", "1027", "2", "1");
INSERT INTO "results" VALUES ("29", "1002", "1", "1");
INSERT INTO "results" VALUES ("30", "1004", "1", "2");
INSERT INTO "results" VALUES ("31", "1006", "1", "1");
INSERT INTO "results" VALUES ("32", "1008", "1", "3");
INSERT INTO "results" VALUES ("33", "1010", "1", "1");
INSERT INTO "results" VALUES ("34", "1012", "1", "2");
INSERT INTO "results" VALUES ("35", "1014", "1", "1");
INSERT INTO "results" VALUES ("36", "1016", "1", "1");
INSERT INTO "results" VALUES ("37", "1018", "1", "3");
INSERT INTO "results" VALUES ("38", "1020", "1", "1");
INSERT INTO "results" VALUES ("39", "1022", "1", "1");
INSERT INTO "results" VALUES ("40", "1024", "1", "2");
INSERT INTO "results" VALUES ("41", "1026", "1", "10");
INSERT INTO "results" VALUES ("42", "1028", "1", "6");