add yearlyawards table
This commit is contained in:
parent
6b3d32cef9
commit
09b33302aa
3
Makefile
3
Makefile
|
@ -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 sql/managers.sql sql/awardsmanagers.sql sql/battingpost.sql sql/fieldingpost.sql sql/pitchingpost.sql sql/appearancespost.sql sql/awardsshareplayers.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 sql/awardsmanagers.sql sql/battingpost.sql sql/fieldingpost.sql sql/pitchingpost.sql sql/appearancespost.sql sql/awardsshareplayers.sql sql/yearlyawards.sql
|
||||
rm -f baseball-transformed.db
|
||||
cp baseball-raw.db baseball-transformed.db
|
||||
cat sql/franchises.sql | sqlite3 baseball-transformed.db
|
||||
|
@ -37,6 +37,7 @@ baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/t
|
|||
cat sql/pitchingpost.sql | sqlite3 baseball-transformed.db
|
||||
cat sql/appearancespost.sql | sqlite3 baseball-transformed.db
|
||||
cat sql/awardsshareplayers.sql | sqlite3 baseball-transformed.db
|
||||
cat sql/yearlyawards.sql | sqlite3 baseball-transformed.db
|
||||
|
||||
baseball-raw.db:
|
||||
rm -f baseball-raw.db
|
||||
|
|
11
sql/load.sql
11
sql/load.sql
|
@ -534,4 +534,15 @@ CREATE TABLE IF NOT EXISTS "awardsshareplayers" (
|
|||
);
|
||||
|
||||
insert into awardsshareplayers select distinct * from "transformed"."awardsshareplayers";
|
||||
|
||||
create table if not exists "yearlyawards" (
|
||||
"year" numeric,
|
||||
"award" text,
|
||||
"league" text,
|
||||
primary key("year","award","league"),
|
||||
foreign key("year") references "seasons"("year"),
|
||||
foreign key("award") references "awards"("ID")
|
||||
);
|
||||
|
||||
insert into yearlyawards select distinct * from "transformed"."yearlyawards";
|
||||
COMMIT;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
begin;
|
||||
attach database 'baseball-raw.db' as 'raw';
|
||||
create table if not exists "yearlyawards" (
|
||||
"year" numeric,
|
||||
"award" text,
|
||||
"league" text
|
||||
);
|
||||
|
||||
insert into yearlyawards
|
||||
select distinct yearid, awardid, lgID
|
||||
from "raw".awardsmanagers
|
||||
union
|
||||
select distinct yearid, awardid, lgID
|
||||
from "raw".awardsplayers;
|
||||
commit;
|
Loading…
Reference in New Issue