add teamcodes table

This commit is contained in:
2024-01-27 21:19:48 -06:00
parent b30302eea6
commit 9f0ac4098b
3 changed files with 29 additions and 1 deletions

View File

@@ -342,4 +342,13 @@ CREATE TABLE IF NOT EXISTS "fieldingofsplit" (
);
insert into fieldingofsplit select distinct * from "transformed"."fieldingofsplit";
create table if not exists teamcodes (
"team" text,
"franchise" text,
primary key("team"),
foreign key("franchise") references "franchises"("ID")
);
insert into teamcodes select distinct * from "transformed"."teamcodes";
COMMIT;

18
sql/teamcodes.sql Normal file
View File

@@ -0,0 +1,18 @@
begin;
attach database 'baseball-raw.db' as 'raw';
create table if not exists teamcodes (
"team" text,
"franchise" text
);
insert into teamcodes
select distinct teamid, franchid from "raw"."teams";
update teamcodes
set team = 'WS9'
where team = 'WAS' and franchise = 'WAS';
update teamcodes
set team = 'PHP'
where team = 'PH4' and franchise = 'PHQ';
commit;