30 lines
748 B
PL/PgSQL
30 lines
748 B
PL/PgSQL
pragma foreign_keys = 0;
|
|
|
|
begin;
|
|
attach database 'baseball-raw.db' as 'raw';
|
|
|
|
create temp table collegeplaying as
|
|
select * from "raw".collegeplaying;
|
|
|
|
-- fix school id
|
|
update collegeplaying
|
|
set schoolID = 'cwpost'
|
|
where schoolID = 'ctpostu';
|
|
|
|
-- baseball almanac says Dick Woodson didn't play in college, and i can't find
|
|
-- another source that says otherwise
|
|
delete from collegeplaying
|
|
where playerid = 'woodsdi01';
|
|
|
|
CREATE TABLE IF NOT EXISTS main."collegeplaying" (
|
|
"player" TEXT,
|
|
"school" TEXT,
|
|
"year" NUMERIC,
|
|
PRIMARY KEY("player","year","school"),
|
|
foreign key("player") references "people"("ID"),
|
|
foreign key("school") references "schools"("ID")
|
|
);
|
|
|
|
insert into main.collegeplaying select distinct * from temp."collegeplaying";
|
|
commit;
|