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

CREATE TABLE "races" (
"raceId" INT,
"name" TEXT,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"position" INT,
"time" TEXT,
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", "Ferrari");
INSERT INTO "constructors" VALUES ("3", "Red Bull Racing");
INSERT INTO "constructors" VALUES ("4", "McLaren");
INSERT INTO "constructors" VALUES ("5", "Alpine");
INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "Dutch");
INSERT INTO "drivers" VALUES ("3", "Italian");
INSERT INTO "drivers" VALUES ("4", "Spanish");
INSERT INTO "drivers" VALUES ("5", "Italian");
INSERT INTO "drivers" VALUES ("6", "German");
INSERT INTO "drivers" VALUES ("7", "Italian");
INSERT INTO "drivers" VALUES ("8", "French");
INSERT INTO "races" VALUES ("1", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("2", "Italian Grand Prix");
INSERT INTO "races" VALUES ("3", "British Grand Prix");
INSERT INTO "races" VALUES ("4", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("5", "Belgian Grand Prix");
INSERT INTO "results" VALUES ("1", "1", "1", "1", "1:30:00");
INSERT INTO "results" VALUES ("2", "1", "2", "2", "1:30:05");
INSERT INTO "results" VALUES ("3", "1", "3", "NULL", "NULL");
INSERT INTO "results" VALUES ("4", "1", "4", "3", "1:30:10");
INSERT INTO "results" VALUES ("5", "2", "1", "1", "1:25:00");
INSERT INTO "results" VALUES ("6", "2", "5", "NULL", "NULL");
INSERT INTO "results" VALUES ("7", "2", "6", "2", "1:25:03");
INSERT INTO "results" VALUES ("8", "3", "1", "1", "1:35:00");
INSERT INTO "results" VALUES ("9", "3", "2", "2", "1:35:02");
INSERT INTO "results" VALUES ("10", "3", "3", "3", "1:35:05");
INSERT INTO "results" VALUES ("11", "4", "4", "1", "1:28:00");
INSERT INTO "results" VALUES ("12", "4", "5", "NULL", "NULL");
INSERT INTO "results" VALUES ("13", "5", "7", "NULL", "NULL");
INSERT INTO "results" VALUES ("14", "5", "8", "1", "1:20:00");
INSERT INTO "results" VALUES ("15", "5", "3", "NULL", "NULL");