move seriespost
This commit is contained in:
parent
3f619aaf62
commit
30010d5880
3
Makefile
3
Makefile
|
@ -9,7 +9,7 @@ baseball.db: baseball-transformed.db sql/load.sql
|
||||||
cat sql/load.sql | sqlite3 baseball.db
|
cat sql/load.sql | sqlite3 baseball.db
|
||||||
sqlite3 baseball.db "VACUUM"
|
sqlite3 baseball.db "VACUUM"
|
||||||
|
|
||||||
baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/franchiseseasons.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
|
baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/franchiseseasons.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
|
||||||
rm -f baseball-transformed.db
|
rm -f baseball-transformed.db
|
||||||
cp baseball-raw.db baseball-transformed.db
|
cp baseball-raw.db baseball-transformed.db
|
||||||
cat sql/franchises.sql | sqlite3 baseball-transformed.db
|
cat sql/franchises.sql | sqlite3 baseball-transformed.db
|
||||||
|
@ -26,6 +26,7 @@ baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/f
|
||||||
cat sql/appearances.sql | sqlite3 baseball-transformed.db
|
cat sql/appearances.sql | sqlite3 baseball-transformed.db
|
||||||
cat sql/homegames.sql | sqlite3 baseball-transformed.db
|
cat sql/homegames.sql | sqlite3 baseball-transformed.db
|
||||||
cat sql/people.sql | sqlite3 baseball-transformed.db
|
cat sql/people.sql | sqlite3 baseball-transformed.db
|
||||||
|
cat sql/seriespost.sql | sqlite3 baseball-transformed.db
|
||||||
|
|
||||||
baseball-raw.db:
|
baseball-raw.db:
|
||||||
rm -f baseball-raw.db
|
rm -f baseball-raw.db
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
begin;
|
|
||||||
CREATE TABLE IF NOT EXISTS "pk_appearances" (
|
|
||||||
"yearID" NUMERIC,
|
|
||||||
"teamID" TEXT,
|
|
||||||
"lgID" TEXT,
|
|
||||||
"playerID" TEXT,
|
|
||||||
"G_all" NUMERIC,
|
|
||||||
"GS" NUMERIC,
|
|
||||||
"G_batting" NUMERIC,
|
|
||||||
"G_defense" NUMERIC,
|
|
||||||
"G_p" NUMERIC,
|
|
||||||
"G_c" NUMERIC,
|
|
||||||
"G_1b" NUMERIC,
|
|
||||||
"G_2b" NUMERIC,
|
|
||||||
"G_3b" NUMERIC,
|
|
||||||
"G_ss" NUMERIC,
|
|
||||||
"G_lf" NUMERIC,
|
|
||||||
"G_cf" NUMERIC,
|
|
||||||
"G_rf" NUMERIC,
|
|
||||||
"G_of" NUMERIC,
|
|
||||||
"G_dh" NUMERIC,
|
|
||||||
"G_ph" NUMERIC,
|
|
||||||
"G_pr" NUMERIC,
|
|
||||||
PRIMARY KEY("yearID","teamID","playerID"),
|
|
||||||
foreign key("playerID") references "people"("playerID")
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO "pk_appearances" SELECT DISTINCT * FROM "appearances";
|
|
||||||
DROP TABLE "appearances";
|
|
||||||
ALTER TABLE "pk_appearances" RENAME TO "appearances";
|
|
||||||
commit;
|
|
|
@ -1,19 +0,0 @@
|
||||||
BEGIN;
|
|
||||||
CREATE TABLE IF NOT EXISTS "pk_homegames" (
|
|
||||||
"year.key" NUMERIC,
|
|
||||||
"league.key" TEXT,
|
|
||||||
"team.key" TEXT,
|
|
||||||
"park.key" TEXT,
|
|
||||||
"span.first" TEXT,
|
|
||||||
"span.last" TEXT,
|
|
||||||
"games" NUMERIC,
|
|
||||||
"openings" NUMERIC,
|
|
||||||
"attendance" NUMERIC,
|
|
||||||
PRIMARY KEY("year.key","team.key","park.key"),
|
|
||||||
foreign key("park.key") references "parks"("park.key")
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO "pk_homegames" SELECT DISTINCT * FROM "homegames";
|
|
||||||
DROP TABLE "homegames";
|
|
||||||
ALTER TABLE "pk_homegames" RENAME TO "homegames";
|
|
||||||
COMMIT;
|
|
|
@ -1,18 +0,0 @@
|
||||||
BEGIN;
|
|
||||||
CREATE TABLE IF NOT EXISTS "pk_seriespost" (
|
|
||||||
"yearID" NUMERIC,
|
|
||||||
"round" NUMERIC,
|
|
||||||
"teamIDwinner" TEXT,
|
|
||||||
"lgIDwinner" TEXT,
|
|
||||||
"teamIDloser" TEXT,
|
|
||||||
"lgIDloser" TEXT,
|
|
||||||
"wins" NUMERIC,
|
|
||||||
"losses" NUMERIC,
|
|
||||||
"ties" NUMERIC,
|
|
||||||
PRIMARY KEY("yearID","round")
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO "pk_seriespost" SELECT DISTINCT * FROM "seriespost";
|
|
||||||
DROP TABLE "seriespost";
|
|
||||||
ALTER TABLE "pk_seriespost" RENAME TO "seriespost";
|
|
||||||
COMMIT;
|
|
14
sql/load.sql
14
sql/load.sql
|
@ -303,4 +303,18 @@ CREATE TABLE IF NOT EXISTS "homegames" (
|
||||||
);
|
);
|
||||||
|
|
||||||
insert into homegames select distinct * from "transformed"."homegames";
|
insert into homegames select distinct * from "transformed"."homegames";
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "seriespost" (
|
||||||
|
"year" NUMERIC,
|
||||||
|
"round" NUMERIC,
|
||||||
|
"winner" TEXT,
|
||||||
|
"loser" TEXT,
|
||||||
|
"wins" NUMERIC,
|
||||||
|
"losses" NUMERIC,
|
||||||
|
"ties" NUMERIC,
|
||||||
|
PRIMARY KEY("year","round"),
|
||||||
|
foreign key("year") references "seasons"("year")
|
||||||
|
);
|
||||||
|
|
||||||
|
insert into seriespost select distinct * from "transformed"."seriespost";
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
Loading…
Reference in New Issue