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 "races" (
"raceId" INT UNIQUE,
"year" INT,
"name" TEXT,
"date" DATE,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"position" INT,
"time" TEXT,
"fastestLapSpeed" TEXT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId")
);



INSERT INTO "races" VALUES ("1", "2009", "Spanish Grand Prix", "2009-05-10");
INSERT INTO "races" VALUES ("2", "2009", "Monaco Grand Prix", "2009-05-24");
INSERT INTO "races" VALUES ("3", "2010", "Spanish Grand Prix", "2010-05-09");
INSERT INTO "races" VALUES ("4", "2009", "British Grand Prix", "2009-07-12");
INSERT INTO "results" VALUES ("2", "1", "2", "1:20:30.000", "188.7");
INSERT INTO "results" VALUES ("3", "1", "3", "1:21:00.000", "189.2");
INSERT INTO "results" VALUES ("4", "1", "4", "1:21:30.000", "187.9");
INSERT INTO "results" VALUES ("5", "1", "5", "1:22:00.000", "190.0");
INSERT INTO "results" VALUES ("6", "2", "1", "1:30:00.000", "185.0");
INSERT INTO "results" VALUES ("7", "2", "2", "1:30:30.000", "184.5");
INSERT INTO "results" VALUES ("8", "3", "1", "1:19:00.000", "192.0");
INSERT INTO "results" VALUES ("9", "3", "2", "1:19:30.000", "191.5");
INSERT INTO "results" VALUES ("10", "4", "1", "1:25:00.000", "188.0");
INSERT INTO "results" VALUES ("11", "4", "2", "1:25:30.000", "187.5");