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 "driverStandings" (
"driverStandingsId" INT,
"points" FLOAT,
PRIMARY KEY ("driverStandingsId")
);

CREATE TABLE "pitStops" (
"raceId" INT,
"driverId" INT,
"stop" INT,
"lap" INT,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

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

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")
);

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



INSERT INTO "driverStandings" VALUES ("1", "25.0");
INSERT INTO "driverStandings" VALUES ("2", "18.0");
INSERT INTO "driverStandings" VALUES ("3", "15.0");
INSERT INTO "driverStandings" VALUES ("4", "12.0");
INSERT INTO "driverStandings" VALUES ("5", "10.0");
INSERT INTO "constructors" VALUES ("1", "McLaren");
INSERT INTO "constructors" VALUES ("2", "Red Bull");
INSERT INTO "constructors" VALUES ("3", "Ferrari");
INSERT INTO "constructors" VALUES ("4", "Mercedes");
INSERT INTO "constructors" VALUES ("5", "Lotus");
INSERT INTO "drivers" VALUES ("1", "Lewis", "Hamilton");
INSERT INTO "drivers" VALUES ("2", "Sebastian", "Vettel");
INSERT INTO "drivers" VALUES ("3", "Fernando", "Alonso");
INSERT INTO "drivers" VALUES ("4", "Jenson", "Button");
INSERT INTO "drivers" VALUES ("5", "Mark", "Webber");
INSERT INTO "races" VALUES ("1", "2011", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2011", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("3", "2012", "Australian Grand Prix");
INSERT INTO "races" VALUES ("4", "2011", "Chinese Grand Prix");
INSERT INTO "races" VALUES ("5", "2010", "Australian Grand Prix");
INSERT INTO "pitStops" VALUES ("1", "1", "1", "15");
INSERT INTO "pitStops" VALUES ("1", "1", "2", "30");
INSERT INTO "pitStops" VALUES ("1", "2", "1", "12");
INSERT INTO "pitStops" VALUES ("1", "4", "1", "18");
INSERT INTO "pitStops" VALUES ("2", "1", "1", "10");
INSERT INTO "pitStops" VALUES ("3", "1", "1", "14");
INSERT INTO "pitStops" VALUES ("4", "1", "1", "16");
INSERT INTO "pitStops" VALUES ("1", "3", "1", "17");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "2");
INSERT INTO "results" VALUES ("3", "3");
INSERT INTO "results" VALUES ("4", "4");
INSERT INTO "results" VALUES ("5", "5");