Compare commits

..

6 Commits

Author SHA1 Message Date
filifa
c46190d5a8 set death months and days to null 2025-08-06 19:08:08 -04:00
filifa
e34da70285 fix George Frazier's info 2025-08-06 19:07:49 -04:00
filifa
7900c660a6 remove redundant insert 2025-08-06 19:07:31 -04:00
filifa
7ebd375743 split up ohtani position row 2025-08-06 18:47:41 -04:00
filifa
6e17945d33 disable checks in files with problems 2024-05-05 19:12:55 -05:00
filifa
557e016751 fix small typo 2024-05-05 19:12:55 -05:00
5 changed files with 32 additions and 6 deletions

View File

@@ -3,7 +3,7 @@
from [the Lahman database/Baseball Databank](https://seanlahman.com).
A makefile and SQL scripts are provided that can create a database from
Lahman's CSV files. Ideally, this means that as long as new releases continue,
Lahman's CSV files. Ideally, this means that as long as new releases continue
(and the structure of the releases is maintained), an up-to-date database can
be created. I have also done my best to normalize the data, incorporate
constraints, and correct errors I've found.

View File

@@ -54,6 +54,15 @@ where startingpos = '';
delete from allstarstartingpos
where startingpos is null;
insert into allstarstartingpos
values
('ohtansh01', 2021, 0, 'AL', 1),
('ohtansh01', 2021, 0, 'AL', 10)
;
delete from allstarstartingpos
where startingpos = '1;10';
CREATE TABLE "allstarstartingpos" (
"player" NUMERIC,
"year" NUMERIC,

View File

@@ -15,6 +15,8 @@ this program. If not, see <https://www.gnu.org/licenses/>.
*/
pragma foreign_keys = 0;
-- check constraints are disabled for this file because the G_of constraint fails for a lot of records and i don't feel like correcting it right now
pragma ignore_check_constraints = 1;
begin;
attach database 'lahman-raw.db' as 'raw';
@@ -122,8 +124,7 @@ CREATE TABLE IF NOT EXISTS "appearances" (
"G_lf" NUMERIC check ("G_lf" <= "G_all"),
"G_cf" NUMERIC check ("G_cf" <= "G_all"),
"G_rf" NUMERIC check ("G_rf" <= "G_all"),
-- there should be a G_of <= G_all constraint, but there's a lot of rows that fail and i don't feel like correcting them right now
"G_of" NUMERIC,
"G_of" NUMERIC check ("G_of" <= "G_all"),
"G_dh" NUMERIC check ("G_dh" <= "G_all"),
"G_ph" NUMERIC check ("G_ph" <= "G_all"),
"G_pr" NUMERIC check ("G_pr" <= "G_all"),

View File

@@ -15,6 +15,8 @@ this program. If not, see <https://www.gnu.org/licenses/>.
*/
pragma foreign_keys = 0;
-- checks are disabled because there's a check for if inducted is Y or N, but there are too many rows i don't feel like correcting right now
pragma ignore_check_constraints = 1;
begin;
attach database 'lahman-raw.db' as 'raw';
@@ -44,8 +46,7 @@ CREATE TABLE IF NOT EXISTS main."halloffame" (
"ballots" TEXT,
"needed" TEXT,
"votes" NUMERIC,
-- we could have a check for if inducted is Y or N, but there are too many rows i don't feel like correcting right now
"inducted" TEXT,
"inducted" TEXT check ("inducted" in ('Y','N')),
"category" TEXT,
"needed_note" text,
PRIMARY KEY("player","year","votedBy")

View File

@@ -26,12 +26,18 @@ alter table people drop column "ID";
-- insert some missing people
insert into people values
('fowlebu99', 1858, 3, 16, 'USA', 'NY', 'Fort Plain', 1913, 2, 26, 'USA', 'NY', 'Frankfort', 'Bud', 'Fowler', 'John W. Jackson', 155, 67, 'R', 'R', null, null, null, 'fowlebu99'),
('thompan01', null, null, null, null, null, null, null, null, null, null, null, null, null, 'Thompson', null, null, null, null, null, '1875-04-26', '1875-05-17', null, 'thompan01');
delete from people
where playerID = 'kellyho99';
delete from people
where playerID = 'frazge99';
update people
set bbrefID = 'frazege99'
where playerID = 'frazege99';
update people
set
birthcountry = nullif(birthcountry, ''),
@@ -55,6 +61,15 @@ set
bbrefID = nullif(bbrefid, ''),
retroID = nullif(retroid, '');
-- we don't know exactly when Alfredo Cabrera died
update people
set deathMonth = null
where deathMonth = 0;
update people
set deathDay = null
where deathDay = 0;
update people
set throws = 'B'
where throws = 'S';