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 "constructorResults" (
"constructorResultsId" INT,
"raceId" INT,
"constructorId" INT,
"points" FLOAT,
PRIMARY KEY ("constructorResultsId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("constructorId") REFERENCES "constructors"("constructorId")
);

CREATE TABLE "constructorStandings" (
"constructorStandingsId" INT,
"points" FLOAT,
"position" INT,
PRIMARY KEY ("constructorStandingsId")
);

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

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



INSERT INTO "races" VALUES ("8");
INSERT INTO "races" VALUES ("9");
INSERT INTO "races" VALUES ("10");
INSERT INTO "constructors" VALUES ("1", "Speedster Racing", "http://speedsterracing.com");
INSERT INTO "constructors" VALUES ("2", "Turbo Motors", "http://turbomotors.com");
INSERT INTO "constructors" VALUES ("3", "Rapid Wheels", "http://rapidwheels.com");
INSERT INTO "constructorResults" VALUES ("1", "9", "1", "25.0");
INSERT INTO "constructorResults" VALUES ("2", "9", "2", "18.0");
INSERT INTO "constructorResults" VALUES ("3", "9", "3", "25.0");
INSERT INTO "constructorResults" VALUES ("4", "8", "1", "15.0");
INSERT INTO "constructorResults" VALUES ("5", "8", "2", "20.0");
INSERT INTO "constructorResults" VALUES ("6", "10", "3", "10.0");
INSERT INTO "constructorStandings" VALUES ("1", "43.0", "1");
INSERT INTO "constructorStandings" VALUES ("2", "38.0", "2");
INSERT INTO "constructorStandings" VALUES ("3", "35.0", "3");