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 "pitStops" (
"raceId" INT,
"driverId" INT,
"stop" INT,
"duration" TEXT,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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

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



INSERT INTO "drivers" VALUES ("1", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("2", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("3", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("4", "Mark", "Webber");
INSERT INTO "drivers" VALUES ("5", "Jenson", "Button");
INSERT INTO "drivers" VALUES ("6", "Felipe", "Massa");
INSERT INTO "drivers" VALUES ("7", "Michael", "Schumacher");
INSERT INTO "drivers" VALUES ("8", "Nico", "Rosberg");
INSERT INTO "drivers" VALUES ("9", "Nick", "Heidfeld");
INSERT INTO "drivers" VALUES ("10", "Vitaly", "Petrov");
INSERT INTO "races" VALUES ("1", "2011", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2011", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("3", "2010", "Australian Grand Prix");
INSERT INTO "races" VALUES ("4", "2012", "Australian Grand Prix");
INSERT INTO "races" VALUES ("5", "2011", "Chinese Grand Prix");
INSERT INTO "pitStops" VALUES ("1", "1", "1", "23.500");
INSERT INTO "pitStops" VALUES ("1", "1", "2", "22.800");
INSERT INTO "pitStops" VALUES ("1", "2", "1", "24.100");
INSERT INTO "pitStops" VALUES ("1", "2", "2", "23.000");
INSERT INTO "pitStops" VALUES ("1", "3", "1", "25.000");
INSERT INTO "pitStops" VALUES ("1", "4", "1", "23.900");
INSERT INTO "pitStops" VALUES ("1", "5", "1", "24.500");
INSERT INTO "pitStops" VALUES ("1", "6", "1", "25.200");
INSERT INTO "pitStops" VALUES ("1", "7", "1", "24.800");
INSERT INTO "pitStops" VALUES ("1", "8", "1", "23.700");
INSERT INTO "pitStops" VALUES ("1", "9", "1", "24.300");
INSERT INTO "pitStops" VALUES ("1", "10", "1", "24.000");
INSERT INTO "pitStops" VALUES ("2", "1", "1", "23.000");
INSERT INTO "pitStops" VALUES ("3", "1", "1", "22.500");
INSERT INTO "pitStops" VALUES ("4", "1", "1", "23.100");
INSERT INTO "pitStops" VALUES ("1", "1", "3", "22.900");
INSERT INTO "pitStops" VALUES ("1", "2", "3", "23.200");
INSERT INTO "pitStops" VALUES ("1", "3", "2", "24.900");
INSERT INTO "pitStops" VALUES ("1", "4", "2", "23.800");
INSERT INTO "pitStops" VALUES ("1", "5", "2", "24.600");