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

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

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



INSERT INTO "drivers" VALUES ("1", "1980-05-12", "British");
INSERT INTO "drivers" VALUES ("2", "1984-11-23", "German");
INSERT INTO "drivers" VALUES ("3", "1986-07-30", "Italian");
INSERT INTO "drivers" VALUES ("4", "1979-01-15", "Brazilian");
INSERT INTO "drivers" VALUES ("5", "1983-09-05", "French");
INSERT INTO "drivers" VALUES ("6", "1987-12-20", "Spanish");
INSERT INTO "drivers" VALUES ("7", "1982-03-10", "Australian");
INSERT INTO "drivers" VALUES ("8", "1985-06-25", "Dutch");
INSERT INTO "drivers" VALUES ("9", "1975-08-14", "Finnish");
INSERT INTO "drivers" VALUES ("10", "1981-02-28", "Japanese");
INSERT INTO "races" VALUES ("101", "2000", "1");
INSERT INTO "races" VALUES ("102", "2001", "2");
INSERT INTO "races" VALUES ("103", "2002", "3");
INSERT INTO "races" VALUES ("104", "2003", "4");
INSERT INTO "races" VALUES ("105", "2004", "5");
INSERT INTO "races" VALUES ("106", "2005", "6");
INSERT INTO "races" VALUES ("107", "1999", "7");
INSERT INTO "races" VALUES ("108", "2006", "8");
INSERT INTO "results" VALUES ("1001", "101", "1", "1", "58");
INSERT INTO "results" VALUES ("1002", "101", "2", "2", "49");
INSERT INTO "results" VALUES ("1003", "101", "3", "3", "60");
INSERT INTO "results" VALUES ("1004", "102", "4", "1", "55");
INSERT INTO "results" VALUES ("1005", "102", "5", "2", "48");
INSERT INTO "results" VALUES ("1006", "103", "6", "1", "62");
INSERT INTO "results" VALUES ("1007", "103", "7", "2", "51");
INSERT INTO "results" VALUES ("1008", "104", "8", "1", "47");
INSERT INTO "results" VALUES ("1009", "104", "9", "2", "53");
INSERT INTO "results" VALUES ("1010", "105", "10", "1", "59");
INSERT INTO "results" VALUES ("1011", "105", "1", "2", "50");
INSERT INTO "results" VALUES ("1012", "106", "2", "1", "54");
INSERT INTO "results" VALUES ("1013", "106", "3", "2", "45");
INSERT INTO "results" VALUES ("1014", "107", "4", "1", "56");
INSERT INTO "results" VALUES ("1015", "108", "5", "1", "57");