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 UNIQUE,
"forename" TEXT,
"surname" TEXT,
"dob" DATE,
"nationality" TEXT,
"url" TEXT,
PRIMARY KEY ("driverId")
);

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"year" INT,
"name" TEXT,
"date" DATE,
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 "drivers" VALUES ("1", "Max", "Verstappen", "1997-09-30", "Dutch", "http://en.wikipedia.org/wiki/Max_Verstappen");
INSERT INTO "drivers" VALUES ("2", "Lewis", "Hamilton", "1985-01-07", "British", "http://en.wikipedia.org/wiki/Lewis_Hamilton");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc", "1997-10-16", "Monegasque", "http://en.wikipedia.org/wiki/Charles_Leclerc");
INSERT INTO "drivers" VALUES ("4", "Lando", "Norris", "1999-11-13", "British", "http://en.wikipedia.org/wiki/Lando_Norris");
INSERT INTO "drivers" VALUES ("5", "George", "Russell", "1998-02-15", "British", "http://en.wikipedia.org/wiki/George_Russell");
INSERT INTO "drivers" VALUES ("6", "Carlos", "Sainz", "1994-09-01", "Spanish", "http://en.wikipedia.org/wiki/Carlos_Sainz_Jr.");
INSERT INTO "drivers" VALUES ("7", "Fernando", "Alonso", "1981-07-29", "Spanish", "http://en.wikipedia.org/wiki/Fernando_Alonso");
INSERT INTO "drivers" VALUES ("8", "Yuki", "Tsunoda", "2000-05-11", "Japanese", "http://en.wikipedia.org/wiki/Yuki_Tsunoda");
INSERT INTO "drivers" VALUES ("9", "Oscar", "Piastri", "2001-04-06", "Australian", "http://en.wikipedia.org/wiki/Oscar_Piastri");
INSERT INTO "drivers" VALUES ("10", "Liam", "Lawson", "2002-02-11", "New Zealander", "http://en.wikipedia.org/wiki/Liam_Lawson");
INSERT INTO "races" VALUES ("1", "2015", "Australian Grand Prix", "2015-03-15");
INSERT INTO "races" VALUES ("2", "2015", "Malaysian Grand Prix", "2015-03-29");
INSERT INTO "races" VALUES ("3", "2018", "Australian Grand Prix", "2018-03-25");
INSERT INTO "races" VALUES ("4", "2019", "Australian Grand Prix", "2019-03-17");
INSERT INTO "races" VALUES ("5", "2021", "Bahrain Grand Prix", "2021-03-28");
INSERT INTO "races" VALUES ("6", "2023", "Bahrain Grand Prix", "2023-03-05");
INSERT INTO "races" VALUES ("7", "2023", "Saudi Arabian Grand Prix", "2023-03-19");
INSERT INTO "races" VALUES ("8", "2023", "Australian Grand Prix", "2023-04-02");
INSERT INTO "races" VALUES ("9", "2023", "Singapore Grand Prix", "2023-09-17");
INSERT INTO "races" VALUES ("10", "2023", "Japanese Grand Prix", "2023-09-24");
INSERT INTO "results" VALUES ("1", "1", "1", "8");
INSERT INTO "results" VALUES ("2", "1", "2", "1");
INSERT INTO "results" VALUES ("3", "2", "1", "7");
INSERT INTO "results" VALUES ("4", "3", "3", "6");
INSERT INTO "results" VALUES ("5", "4", "4", "12");
INSERT INTO "results" VALUES ("6", "5", "8", "9");
INSERT INTO "results" VALUES ("7", "6", "9", "11");
INSERT INTO "results" VALUES ("8", "7", "10", "13");
INSERT INTO "results" VALUES ("9", "8", "9", "8");
INSERT INTO "results" VALUES ("10", "9", "10", "9");
INSERT INTO "results" VALUES ("11", "10", "10", "11");
INSERT INTO "results" VALUES ("12", "6", "1", "2");
INSERT INTO "results" VALUES ("13", "6", "2", "5");
INSERT INTO "results" VALUES ("14", "6", "3", "3");
INSERT INTO "results" VALUES ("15", "6", "4", "6");
INSERT INTO "results" VALUES ("16", "6", "5", "7");
INSERT INTO "results" VALUES ("17", "6", "6", "4");
INSERT INTO "results" VALUES ("18", "6", "7", "9");
INSERT INTO "results" VALUES ("19", "6", "8", "10");