Fix allstar tables
This commit is contained in:
parent
498b3ba308
commit
8ba209aea4
3
Makefile
3
Makefile
|
@ -4,7 +4,7 @@ bbdb = baseballdatabank-2023.1
|
|||
|
||||
db: baseball.db
|
||||
|
||||
baseball.db: sql/corrections/*.sql sql/keys/*.sql sql/1nf/*.sql sql/2nf/*.sql sql/3nf/*.sql
|
||||
baseball.db: sql/corrections/*.sql sql/keys/*.sql sql/1nf/*.sql sql/2nf/*.sql
|
||||
rm -f baseball.db
|
||||
sqlite3 baseball.db ".import --csv $(bbdb)/core/AllstarFull.csv allstarfull"
|
||||
sqlite3 baseball.db ".import --csv $(bbdb)/core/Appearances.csv appearances"
|
||||
|
@ -37,5 +37,4 @@ baseball.db: sql/corrections/*.sql sql/keys/*.sql sql/1nf/*.sql sql/2nf/*.sql sq
|
|||
cat sql/keys/*.sql | sqlite3 baseball.db
|
||||
cat sql/1nf/*.sql | sqlite3 baseball.db
|
||||
cat sql/2nf/*.sql | sqlite3 baseball.db
|
||||
cat sql/3nf/*.sql | sqlite3 baseball.db
|
||||
sqlite3 baseball.db "VACUUM"
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
begin;
|
||||
create table if not exists allstargames (
|
||||
"yearID" numeric,
|
||||
"gameNum" numeric,
|
||||
"gameID" text,
|
||||
primary key("yearID","gameNum")
|
||||
);
|
||||
|
||||
insert into allstargames
|
||||
select distinct yearid, gamenum, gameid
|
||||
from allstarfull;
|
||||
|
||||
alter table allstarfull drop column "gameID";
|
||||
|
||||
alter table allstarfull rename to "allstarstartingpos";
|
||||
|
||||
create table if not exists "allstars" (
|
||||
"playerID" text,
|
||||
"yearID" text,
|
||||
"gameNum" text,
|
||||
"teamID" text,
|
||||
"GP" numeric,
|
||||
primary key("playerID","yearID","gameNum"),
|
||||
foreign key("playerID") references "people"("playerID")
|
||||
);
|
||||
|
||||
insert into allstars
|
||||
select distinct playerid, yearid, gamenum, teamid, gp
|
||||
from allstarstartingpos;
|
||||
|
||||
alter table allstarstartingpos drop column "teamid";
|
||||
alter table allstarstartingpos drop column "lgID";
|
||||
alter table allstarstartingpos drop column "gp";
|
||||
commit;
|
|
@ -1,14 +0,0 @@
|
|||
begin;
|
||||
create table if not exists allstargames (
|
||||
"yearID" numeric,
|
||||
"gameNum" numeric,
|
||||
"gameID" text,
|
||||
primary key("yearID","gameNum")
|
||||
);
|
||||
|
||||
insert into allstargames
|
||||
select distinct yearid, gamenum, gameid
|
||||
from allstarfull;
|
||||
|
||||
alter table allstarfull drop column "gameID";
|
||||
commit;
|
|
@ -1,3 +0,0 @@
|
|||
begin;
|
||||
alter table allstarfull drop column "lgID";
|
||||
commit;
|
Loading…
Reference in New Issue