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 "lapTimes" (
"raceId" INT,
"driverId" INT,
"lap" INT,
"milliseconds" INT,
PRIMARY KEY ("raceId", "driverId", "lap"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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

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

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

CREATE TABLE "results" (
"resultId" INT,
"milliseconds" INT,
PRIMARY KEY ("resultId")
);



INSERT INTO "constructors" VALUES ("1", "British");
INSERT INTO "constructors" VALUES ("2", "French");
INSERT INTO "constructors" VALUES ("3", "German");
INSERT INTO "constructors" VALUES ("4", "Italian");
INSERT INTO "constructors" VALUES ("5", "American");
INSERT INTO "drivers" VALUES ("1", "French");
INSERT INTO "drivers" VALUES ("2", "British");
INSERT INTO "drivers" VALUES ("3", "French");
INSERT INTO "drivers" VALUES ("4", "German");
INSERT INTO "drivers" VALUES ("5", "Spanish");
INSERT INTO "drivers" VALUES ("6", "French");
INSERT INTO "drivers" VALUES ("7", "Finnish");
INSERT INTO "races" VALUES ("1", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("2", "British Grand Prix");
INSERT INTO "races" VALUES ("3", "French Grand Prix");
INSERT INTO "races" VALUES ("4", "Italian Grand Prix");
INSERT INTO "races" VALUES ("5", "Japanese Grand Prix");
INSERT INTO "lapTimes" VALUES ("1", "1", "1", "115000");
INSERT INTO "lapTimes" VALUES ("1", "1", "2", "125000");
INSERT INTO "lapTimes" VALUES ("1", "2", "1", "118000");
INSERT INTO "lapTimes" VALUES ("1", "3", "1", "119000");
INSERT INTO "lapTimes" VALUES ("2", "1", "1", "121000");
INSERT INTO "lapTimes" VALUES ("2", "3", "1", "110000");
INSERT INTO "lapTimes" VALUES ("2", "4", "1", "117000");
INSERT INTO "lapTimes" VALUES ("3", "5", "1", "120000");
INSERT INTO "lapTimes" VALUES ("3", "6", "1", "112000");
INSERT INTO "lapTimes" VALUES ("4", "1", "1", "116000");
INSERT INTO "lapTimes" VALUES ("4", "3", "1", "122000");
INSERT INTO "lapTimes" VALUES ("4", "6", "1", "128000");
INSERT INTO "lapTimes" VALUES ("5", "7", "1", "114000");
INSERT INTO "results" VALUES ("1", "115000");
INSERT INTO "results" VALUES ("2", "118000");
INSERT INTO "results" VALUES ("3", "119000");
INSERT INTO "results" VALUES ("4", "121000");
INSERT INTO "results" VALUES ("5", "110000");
INSERT INTO "results" VALUES ("6", "117000");
INSERT INTO "results" VALUES ("7", "120000");
INSERT INTO "results" VALUES ("8", "112000");
INSERT INTO "results" VALUES ("9", "116000");
INSERT INTO "results" VALUES ("10", "122000");
INSERT INTO "results" VALUES ("11", "128000");
INSERT INTO "results" VALUES ("12", "114000");