use playerstints table for foreign keys

This commit is contained in:
Nick Griffey 2024-01-29 21:37:11 -06:00
parent 460604fc49
commit 6d4e593065
1 changed files with 10 additions and 11 deletions

View File

@ -191,8 +191,8 @@ CREATE TABLE IF NOT EXISTS "batting" (
"SH" NUMERIC,
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("player","year","stint","team"),
foreign key("year","player","team") references "appearances"("year","player","team")
PRIMARY KEY("player","year","stint"),
foreign key("year","player","stint") references "playerstints"("year","player","stint")
);
insert into batting select distinct * from "transformed"."batting";
@ -215,8 +215,8 @@ CREATE TABLE IF NOT EXISTS "fielding" (
"SB" NUMERIC,
"CS" NUMERIC,
"ZR" NUMERIC,
PRIMARY KEY("player","year","stint","team","POS"),
foreign key("year","player","team") references "appearances"("year","player","team")
PRIMARY KEY("player","year","stint","POS"),
foreign key("year","player","stint") references "playerstints"("year","player","stint")
);
insert into fielding select distinct * from "transformed"."fielding";
@ -251,8 +251,8 @@ CREATE TABLE IF NOT EXISTS "pitching" (
"SH" NUMERIC,
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("player","year","stint","team"),
foreign key("year","player","team") references "appearances"("year","player","team")
PRIMARY KEY("player","year","stint"),
foreign key("year","player","stint") references "playerstints"("year","player","stint")
);
insert into pitching select distinct * from "transformed"."pitching";
@ -335,8 +335,8 @@ CREATE TABLE IF NOT EXISTS "fieldingofsplit" (
"SB" NUMERIC,
"CS" NUMERIC,
"ZR" NUMERIC,
PRIMARY KEY("player","year","stint","team","POS"),
foreign key("year","player","team") references "appearances"("year","player","team")
PRIMARY KEY("player","year","stint","POS"),
foreign key("year","player","stint") references "playerstints"("year","player","stint")
);
insert into fieldingofsplit select distinct * from "transformed"."fieldingofsplit";
@ -492,9 +492,8 @@ CREATE TABLE IF NOT EXISTS "fieldingof" (
"Glf" NUMERIC,
"Gcf" NUMERIC,
"Grf" NUMERIC,
PRIMARY KEY("player","year","stint")
foreign key("player") references "people"("ID"),
foreign key("year") references "seasons"("year")
PRIMARY KEY("player","year","stint"),
foreign key("year","player","stint") references "playerstints"("year","player","stint")
);
insert into fieldingof select distinct * from "transformed"."fieldingof";