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 "driverStandings" (
"driverStandingsId" INT,
"position" INT,
PRIMARY KEY ("driverStandingsId")
);

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

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"dob" DATE,
PRIMARY KEY ("driverId")
);

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

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

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



INSERT INTO "driverStandings" VALUES ("1", "1");
INSERT INTO "driverStandings" VALUES ("2", "2");
INSERT INTO "driverStandings" VALUES ("3", "3");
INSERT INTO "driverStandings" VALUES ("4", "4");
INSERT INTO "driverStandings" VALUES ("5", "5");
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", "1980-01-01");
INSERT INTO "drivers" VALUES ("2", "1982-05-15");
INSERT INTO "drivers" VALUES ("3", "1986-03-20");
INSERT INTO "drivers" VALUES ("4", "1975-11-10");
INSERT INTO "drivers" VALUES ("5", "1990-07-22");
INSERT INTO "drivers" VALUES ("6", "1984-09-01");
INSERT INTO "drivers" VALUES ("7", "1983-02-28");
INSERT INTO "drivers" VALUES ("8", "1978-04-05");
INSERT INTO "qualifying" VALUES ("1", "1");
INSERT INTO "qualifying" VALUES ("2", "2");
INSERT INTO "qualifying" VALUES ("3", "3");
INSERT INTO "qualifying" VALUES ("4", "4");
INSERT INTO "qualifying" VALUES ("5", "5");
INSERT INTO "races" VALUES ("1", "2000");
INSERT INTO "races" VALUES ("2", "2001");
INSERT INTO "races" VALUES ("3", "2002");
INSERT INTO "races" VALUES ("4", "2003");
INSERT INTO "races" VALUES ("5", "2004");
INSERT INTO "races" VALUES ("6", "2005");
INSERT INTO "races" VALUES ("7", "2006");
INSERT INTO "races" VALUES ("8", "1999");
INSERT INTO "results" VALUES ("1", "1", "1", "55");
INSERT INTO "results" VALUES ("2", "1", "2", "50");
INSERT INTO "results" VALUES ("3", "2", "3", "60");
INSERT INTO "results" VALUES ("4", "2", "4", "52");
INSERT INTO "results" VALUES ("5", "3", "1", "45");
INSERT INTO "results" VALUES ("6", "3", "5", "58");
INSERT INTO "results" VALUES ("7", "4", "2", "51");
INSERT INTO "results" VALUES ("8", "4", "6", "49");
INSERT INTO "results" VALUES ("9", "5", "4", "53");
INSERT INTO "results" VALUES ("10", "5", "7", "56");
INSERT INTO "results" VALUES ("11", "6", "1", "54");
INSERT INTO "results" VALUES ("12", "6", "8", "48");
INSERT INTO "results" VALUES ("13", "7", "1", "60");
INSERT INTO "results" VALUES ("14", "8", "4", "55");
INSERT INTO "results" VALUES ("15", "1", "4", "57");
INSERT INTO "results" VALUES ("16", "2", "1", "59");
INSERT INTO "results" VALUES ("17", "3", "2", "53");
INSERT INTO "results" VALUES ("18", "4", "3", "40");
INSERT INTO "results" VALUES ("19", "5", "6", "55");
INSERT INTO "results" VALUES ("20", "6", "7", "45");