Remove foreign key constraints on teamid

This commit is contained in:
Nick Griffey 2024-01-25 19:59:14 -06:00
parent 3bd573b00d
commit f6f17cc47c
15 changed files with 14 additions and 30 deletions

View File

@ -9,8 +9,7 @@ CREATE TABLE "pk_allstarfull" (
"GP" NUMERIC,
"startingPos" NUMERIC,
primary key("playerID","yearID","gameNum","startingPos"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_allstarfull" SELECT DISTINCT * FROM "allstarfull";

View File

@ -22,8 +22,7 @@ CREATE TABLE IF NOT EXISTS "pk_appearances" (
"G_ph" NUMERIC,
"G_pr" NUMERIC,
PRIMARY KEY("yearID","teamID","playerID"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_appearances" SELECT DISTINCT * FROM "appearances";

View File

@ -23,8 +23,7 @@ CREATE TABLE IF NOT EXISTS "pk_batting" (
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_batting" SELECT DISTINCT * FROM "batting";

View File

@ -23,8 +23,7 @@ CREATE TABLE IF NOT EXISTS "pk_battingpost" (
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("yearID","playerID","round"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_battingpost" SELECT DISTINCT * FROM "battingpost";

View File

@ -19,8 +19,7 @@ CREATE TABLE IF NOT EXISTS "pk_fielding" (
"CS" NUMERIC,
"ZR" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID","POS"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_fielding" SELECT DISTINCT * FROM "fielding";

View File

@ -19,8 +19,7 @@ CREATE TABLE IF NOT EXISTS "pk_fieldingofsplit" (
"CS" NUMERIC,
"ZR" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID","POS"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_fieldingofsplit" SELECT DISTINCT * FROM "fieldingofsplit";

View File

@ -18,8 +18,7 @@ CREATE TABLE IF NOT EXISTS "pk_fieldingpost" (
"SB" NUMERIC,
"CS" NUMERIC,
PRIMARY KEY("playerID","yearID","round","POS"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_fieldingpost" SELECT DISTINCT * FROM "fieldingpost";

View File

@ -10,7 +10,6 @@ CREATE TABLE IF NOT EXISTS "pk_homegames" (
"openings" NUMERIC,
"attendance" NUMERIC,
PRIMARY KEY("year.key","team.key","park.key"),
foreign key("team.key") references "teams"("teamID"),
foreign key("park.key") references "parks"("park.key")
);

View File

@ -11,8 +11,7 @@ CREATE TABLE IF NOT EXISTS "pk_managers" (
"rank" NUMERIC,
"plyrMgr" TEXT,
PRIMARY KEY("playerID","yearID","teamID","inseason"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_managers" SELECT DISTINCT * FROM "managers";
DROP TABLE "managers";

View File

@ -11,8 +11,7 @@ CREATE TABLE IF NOT EXISTS "pk_managershalf" (
"L" NUMERIC,
"rank" NUMERIC,
PRIMARY KEY("playerID","yearID","teamID","inseason","half"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_managershalf" SELECT DISTINCT * FROM "managershalf";

View File

@ -31,8 +31,7 @@ CREATE TABLE IF NOT EXISTS "pk_pitching" (
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_pitching" SELECT DISTINCT * FROM "pitching";

View File

@ -31,8 +31,7 @@ CREATE TABLE IF NOT EXISTS "pk_pitchingpost" (
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("playerID","yearID","round"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_pitchingpost" SELECT DISTINCT * FROM "pitchingpost";

View File

@ -6,8 +6,7 @@ CREATE TABLE IF NOT EXISTS "pk_salaries" (
"playerID" TEXT,
"salary" NUMERIC,
PRIMARY KEY("yearID","playerID","teamID"),
foreign key("playerID") references "people"("playerID"),
foreign key("teamID") references "teams"("teamID")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_salaries" SELECT DISTINCT * FROM "salaries";

View File

@ -9,9 +9,7 @@ CREATE TABLE IF NOT EXISTS "pk_seriespost" (
"wins" NUMERIC,
"losses" NUMERIC,
"ties" NUMERIC,
PRIMARY KEY("yearID","round"),
foreign key("teamIDwinner") references "teams"("teamID"),
foreign key("teamIDloser") references "teams"("teamID")
PRIMARY KEY("yearID","round")
);
INSERT INTO "pk_seriespost" SELECT DISTINCT * FROM "seriespost";

View File

@ -10,8 +10,7 @@ CREATE TABLE IF NOT EXISTS "pk_teamshalf" (
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
PRIMARY KEY("Half","yearID","teamID"),
foreign key("teamID") references "teams"("teamID")
PRIMARY KEY("Half","yearID","teamID")
);
INSERT INTO "pk_teamshalf" SELECT DISTINCT * FROM "teamshalf";