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,
"position" INT,
PRIMARY KEY ("constructorStandingsId")
);

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

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



INSERT INTO "constructors" VALUES ("1", "Honda", "Japanese");
INSERT INTO "constructors" VALUES ("2", "Toyota", "Japanese");
INSERT INTO "constructors" VALUES ("3", "Nissan", "Japanese");
INSERT INTO "constructors" VALUES ("4", "Ferrari", "Italian");
INSERT INTO "constructors" VALUES ("5", "Mercedes", "German");
INSERT INTO "constructors" VALUES ("6", "Red Bull", "Austrian");
INSERT INTO "races" VALUES ("101", "Grand Prix 2023 - Race 1");
INSERT INTO "races" VALUES ("102", "Grand Prix 2023 - Race 2");
INSERT INTO "races" VALUES ("103", "Grand Prix 2023 - Race 3");
INSERT INTO "races" VALUES ("104", "Grand Prix 2023 - Race 4");
INSERT INTO "races" VALUES ("105", "Grand Prix 2023 - Race 5");
INSERT INTO "constructorResults" VALUES ("1", "101", "1", "0.0");
INSERT INTO "constructorResults" VALUES ("2", "102", "1", "0.0");
INSERT INTO "constructorResults" VALUES ("3", "103", "1", "10.0");
INSERT INTO "constructorResults" VALUES ("4", "101", "2", "0.0");
INSERT INTO "constructorResults" VALUES ("5", "102", "2", "0.0");
INSERT INTO "constructorResults" VALUES ("6", "103", "2", "0.0");
INSERT INTO "constructorResults" VALUES ("7", "104", "2", "5.0");
INSERT INTO "constructorResults" VALUES ("8", "101", "3", "0.0");
INSERT INTO "constructorResults" VALUES ("9", "102", "3", "1.0");
INSERT INTO "constructorResults" VALUES ("10", "103", "3", "0.0");
INSERT INTO "constructorResults" VALUES ("11", "104", "3", "0.0");
INSERT INTO "constructorResults" VALUES ("12", "105", "3", "0.0");
INSERT INTO "constructorResults" VALUES ("13", "101", "4", "25.0");
INSERT INTO "constructorResults" VALUES ("14", "102", "4", "18.0");
INSERT INTO "constructorResults" VALUES ("15", "101", "5", "15.0");
INSERT INTO "constructorResults" VALUES ("16", "102", "5", "12.0");
INSERT INTO "constructorResults" VALUES ("17", "103", "5", "0.0");
INSERT INTO "constructorResults" VALUES ("18", "104", "5", "0.0");
INSERT INTO "constructorResults" VALUES ("19", "101", "6", "10.0");
INSERT INTO "constructorResults" VALUES ("20", "102", "6", "8.0");
INSERT INTO "constructorStandings" VALUES ("1", "5");
INSERT INTO "constructorStandings" VALUES ("2", "7");
INSERT INTO "constructorStandings" VALUES ("3", "9");
INSERT INTO "constructorStandings" VALUES ("4", "1");
INSERT INTO "constructorStandings" VALUES ("5", "2");
INSERT INTO "constructorStandings" VALUES ("6", "3");