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

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

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

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



INSERT INTO "constructors" VALUES ("1", "Honda Racing", "Japanese");
INSERT INTO "constructors" VALUES ("2", "Toyota Gazoo", "Japanese");
INSERT INTO "constructors" VALUES ("3", "Red Bull Racing", "Austrian");
INSERT INTO "constructors" VALUES ("4", "Mercedes", "German");
INSERT INTO "constructors" VALUES ("5", "Williams", "British");
INSERT INTO "races" VALUES ("101");
INSERT INTO "races" VALUES ("102");
INSERT INTO "races" VALUES ("103");
INSERT INTO "constructorResults" VALUES ("1001", "101", "1", "0.0");
INSERT INTO "constructorResults" VALUES ("1002", "102", "1", "0.0");
INSERT INTO "constructorResults" VALUES ("1003", "103", "1", "5.0");
INSERT INTO "constructorResults" VALUES ("1004", "101", "2", "0.0");
INSERT INTO "constructorResults" VALUES ("1005", "102", "2", "0.0");
INSERT INTO "constructorResults" VALUES ("1006", "103", "2", "0.0");
INSERT INTO "constructorResults" VALUES ("1007", "101", "3", "25.0");
INSERT INTO "constructorResults" VALUES ("1008", "102", "3", "18.0");
INSERT INTO "constructorResults" VALUES ("1009", "103", "3", "15.0");
INSERT INTO "constructorResults" VALUES ("1010", "101", "4", "10.0");
INSERT INTO "constructorResults" VALUES ("1011", "102", "4", "12.0");
INSERT INTO "constructorResults" VALUES ("1012", "101", "5", "0.0");
INSERT INTO "constructorResults" VALUES ("1013", "102", "5", "3.0");
INSERT INTO "constructorStandings" VALUES ("2001", "101", "1", "0.0", "0");
INSERT INTO "constructorStandings" VALUES ("2002", "102", "1", "0.0", "0");
INSERT INTO "constructorStandings" VALUES ("2003", "103", "1", "5.0", "1");
INSERT INTO "constructorStandings" VALUES ("2004", "101", "2", "0.0", "0");
INSERT INTO "constructorStandings" VALUES ("2005", "102", "2", "0.0", "0");
INSERT INTO "constructorStandings" VALUES ("2006", "103", "2", "0.0", "0");
INSERT INTO "constructorStandings" VALUES ("2007", "101", "3", "25.0", "2");
INSERT INTO "constructorStandings" VALUES ("2008", "102", "3", "18.0", "1");
INSERT INTO "constructorStandings" VALUES ("2009", "103", "3", "15.0", "0");
INSERT INTO "constructorStandings" VALUES ("2010", "101", "4", "10.0", "0");
INSERT INTO "constructorStandings" VALUES ("2011", "102", "4", "12.0", "0");
INSERT INTO "constructorStandings" VALUES ("2012", "101", "5", "0.0", "0");
INSERT INTO "constructorStandings" VALUES ("2013", "102", "5", "3.0", "0");