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,
PRIMARY KEY ("driverId")
);

CREATE TABLE "qualifying" (
"qualifyId" INT,
"raceId" INT,
"driverId" INT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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



INSERT INTO "drivers" VALUES ("1", "Max", "Verstappen", "1997-09-30");
INSERT INTO "drivers" VALUES ("2", "Lewis", "Hamilton", "1985-01-07");
INSERT INTO "drivers" VALUES ("3", "Charles", "Leclerc", "1997-10-16");
INSERT INTO "drivers" VALUES ("4", "Fernando", "Alonso", "1981-07-29");
INSERT INTO "drivers" VALUES ("5", "Lando", "Norris", "1999-11-13");
INSERT INTO "drivers" VALUES ("6", "Sebastian", "Vettel", "1987-07-03");
INSERT INTO "drivers" VALUES ("7", "George", "Russell", "1998-02-15");
INSERT INTO "drivers" VALUES ("8", "Daniel", "Ricciardo", "1989-07-01");
INSERT INTO "drivers" VALUES ("9", "Carlos", "Sainz", "1994-09-01");
INSERT INTO "drivers" VALUES ("10", "Kimi", "Raikkonen", "1979-10-17");
INSERT INTO "races" VALUES ("101", "2015", "Australian Grand Prix", "2015-03-15", "16:00:00");
INSERT INTO "races" VALUES ("102", "2015", "Malaysian Grand Prix", "2015-03-29", "15:00:00");
INSERT INTO "races" VALUES ("103", "2016", "Australian Grand Prix", "2016-03-20", "16:00:00");
INSERT INTO "races" VALUES ("104", "2017", "Bahrain Grand Prix", "2017-04-16", "18:00:00");
INSERT INTO "races" VALUES ("105", "2018", "Monaco Grand Prix", "2018-05-27", "15:10:00");
INSERT INTO "races" VALUES ("106", "2019", "Austrian Grand Prix", "2019-06-30", "15:10:00");
INSERT INTO "races" VALUES ("107", "2020", "British Grand Prix", "2020-08-02", "14:10:00");
INSERT INTO "races" VALUES ("108", "2021", "Italian Grand Prix", "2021-09-12", "15:00:00");
INSERT INTO "races" VALUES ("109", "2022", "Abu Dhabi Grand Prix", "2022-11-20", "17:00:00");
INSERT INTO "races" VALUES ("110", "2014", "Brazilian Grand Prix", "2014-11-09", "14:00:00");
INSERT INTO "qualifying" VALUES ("1", "101", "1");
INSERT INTO "qualifying" VALUES ("2", "101", "2");
INSERT INTO "qualifying" VALUES ("3", "102", "1");
INSERT INTO "qualifying" VALUES ("4", "102", "3");
INSERT INTO "qualifying" VALUES ("5", "103", "2");
INSERT INTO "qualifying" VALUES ("6", "103", "4");
INSERT INTO "qualifying" VALUES ("7", "104", "3");
INSERT INTO "qualifying" VALUES ("8", "104", "5");
INSERT INTO "qualifying" VALUES ("9", "105", "1");
INSERT INTO "qualifying" VALUES ("10", "105", "7");
INSERT INTO "qualifying" VALUES ("11", "106", "5");
INSERT INTO "qualifying" VALUES ("12", "106", "9");
INSERT INTO "qualifying" VALUES ("13", "107", "7");
INSERT INTO "qualifying" VALUES ("14", "107", "8");
INSERT INTO "qualifying" VALUES ("15", "108", "1");
INSERT INTO "qualifying" VALUES ("16", "108", "2");
INSERT INTO "qualifying" VALUES ("17", "109", "3");
INSERT INTO "qualifying" VALUES ("18", "109", "5");
INSERT INTO "qualifying" VALUES ("19", "110", "6");
INSERT INTO "qualifying" VALUES ("20", "110", "10");
INSERT INTO "qualifying" VALUES ("21", "101", "4");
INSERT INTO "qualifying" VALUES ("22", "103", "1");
INSERT INTO "qualifying" VALUES ("23", "104", "7");
INSERT INTO "qualifying" VALUES ("24", "104", "5");
INSERT INTO "qualifying" VALUES ("25", "101", "3");