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,
"nationality" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

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

CREATE TABLE "results" (
"resultId" INT,
"driverId" INT,
"fastestLapSpeed" TEXT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "constructors" VALUES ("1", "Mercedes", "German");
INSERT INTO "constructors" VALUES ("2", "Red Bull", "Austrian");
INSERT INTO "constructors" VALUES ("3", "Ferrari", "Italian");
INSERT INTO "constructors" VALUES ("4", "McLaren", "British");
INSERT INTO "constructors" VALUES ("5", "Alpine", "French");
INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "Dutch");
INSERT INTO "drivers" VALUES ("3", "Monegasque");
INSERT INTO "drivers" VALUES ("4", "Mexican");
INSERT INTO "drivers" VALUES ("5", "Spanish");
INSERT INTO "drivers" VALUES ("6", "German");
INSERT INTO "drivers" VALUES ("7", "French");
INSERT INTO "drivers" VALUES ("8", "Finnish");
INSERT INTO "qualifying" VALUES ("1", "1:25.000");
INSERT INTO "qualifying" VALUES ("2", "1:24.500");
INSERT INTO "qualifying" VALUES ("3", "1:24.800");
INSERT INTO "qualifying" VALUES ("4", "1:25.100");
INSERT INTO "qualifying" VALUES ("5", "1:26.000");
INSERT INTO "results" VALUES ("1", "1", "240.500");
INSERT INTO "results" VALUES ("2", "2", "242.100");
INSERT INTO "results" VALUES ("3", "3", "241.800");
INSERT INTO "results" VALUES ("4", "4", "239.900");
INSERT INTO "results" VALUES ("5", "5", "238.000");
INSERT INTO "results" VALUES ("6", "1", "240.100");
INSERT INTO "results" VALUES ("7", "2", "242.500");
INSERT INTO "results" VALUES ("8", "3", "241.000");
INSERT INTO "results" VALUES ("9", "6", "239.500");
INSERT INTO "results" VALUES ("10", "7", "237.000");
INSERT INTO "results" VALUES ("11", "8", "236.500");