move managers

This commit is contained in:
Nick Griffey 2024-01-27 23:14:56 -06:00
parent 00f197d89f
commit 3a60d30ff8
5 changed files with 30 additions and 24 deletions

View File

@ -9,7 +9,7 @@ baseball.db: baseball-transformed.db sql/load.sql
cat sql/load.sql | sqlite3 baseball.db
sqlite3 baseball.db "VACUUM"
baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/teamseasons.sql sql/seasons.sql sql/parks.sql sql/collegeplaying.sql sql/schools.sql sql/people.sql sql/salaries.sql sql/batting.sql sql/pitching.sql sql/fielding.sql sql/appearances.sql sql/homegames.sql sql/seriespost.sql sql/fieldingofsplit.sql sql/teams.sql sql/leagues.sql
baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/teamseasons.sql sql/seasons.sql sql/parks.sql sql/collegeplaying.sql sql/schools.sql sql/people.sql sql/salaries.sql sql/batting.sql sql/pitching.sql sql/fielding.sql sql/appearances.sql sql/homegames.sql sql/seriespost.sql sql/fieldingofsplit.sql sql/teams.sql sql/leagues.sql sql/managers.sql
rm -f baseball-transformed.db
cp baseball-raw.db baseball-transformed.db
cat sql/franchises.sql | sqlite3 baseball-transformed.db
@ -30,6 +30,7 @@ baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/t
cat sql/fieldingofsplit.sql | sqlite3 baseball-transformed.db
cat sql/teams.sql | sqlite3 baseball-transformed.db
cat sql/leagues.sql | sqlite3 baseball-transformed.db
cat sql/managers.sql | sqlite3 baseball-transformed.db
baseball-raw.db:
rm -f baseball-raw.db

View File

@ -1,4 +0,0 @@
begin;
alter table managers drop column "lgID";
alter table managers drop column "rank";
commit;

View File

@ -1,19 +0,0 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_managers" (
"playerID" TEXT,
"yearID" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"inseason" NUMERIC,
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
"rank" NUMERIC,
"plyrMgr" TEXT,
PRIMARY KEY("playerID","yearID","teamID","inseason"),
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_managers" SELECT DISTINCT * FROM "managers";
DROP TABLE "managers";
ALTER TABLE "pk_managers" RENAME TO "managers";
COMMIT;

View File

@ -356,4 +356,20 @@ create table if not exists "leagues" (
);
insert into leagues select distinct * from "transformed"."leagues";
CREATE TABLE IF NOT EXISTS "managers" (
"ID" TEXT,
"year" NUMERIC,
"team" TEXT,
"inseason" NUMERIC,
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
"plyrMgr" TEXT,
PRIMARY KEY("ID","year","team","inseason"),
foreign key("ID") references "people"("ID"),
foreign key("year","team") references "teamseasons"("year","team")
);
insert into managers select distinct * from "transformed"."managers";
COMMIT;

12
sql/managers.sql Normal file
View File

@ -0,0 +1,12 @@
begin;
alter table managers drop column "lgID";
alter table managers drop column "rank";
update managers
set teamid = 'WS9'
where teamid = 'WAS' and yearid between 1891 and 1899;
update managers
set teamid = 'PHP'
where teamid = 'PH4' and yearid between 1890 and 1891;
commit;