move salaries
This commit is contained in:
parent
632410ce88
commit
0c4d00ddfc
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/franchiseseasons.sql sql/seasons.sql sql/parks.sql sql/collegeplaying.sql sql/schools.sql sql/people.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
|
||||
rm -f baseball-transformed.db
|
||||
cp baseball-raw.db baseball-transformed.db
|
||||
cat sql/franchises.sql | sqlite3 baseball-transformed.db
|
||||
|
@ -19,6 +19,7 @@ baseball-transformed.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/f
|
|||
cat sql/parks.sql | sqlite3 baseball-transformed.db
|
||||
cat sql/collegeplaying.sql | sqlite3 baseball-transformed.db
|
||||
cat sql/schools.sql | sqlite3 baseball-transformed.db
|
||||
cat sql/salaries.sql | sqlite3 baseball-transformed.db
|
||||
|
||||
baseball-raw.db:
|
||||
rm -f baseball-raw.db
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
BEGIN;
|
||||
CREATE TABLE IF NOT EXISTS "pk_salaries" (
|
||||
"yearID" NUMERIC,
|
||||
"teamID" TEXT,
|
||||
"lgID" TEXT,
|
||||
"playerID" TEXT,
|
||||
"salary" NUMERIC,
|
||||
PRIMARY KEY("yearID","playerID","teamID"),
|
||||
foreign key("playerID") references "people"("playerID")
|
||||
);
|
||||
|
||||
INSERT INTO "pk_salaries" SELECT DISTINCT * FROM "salaries";
|
||||
DROP TABLE "salaries";
|
||||
ALTER TABLE "pk_salaries" RENAME TO "salaries";
|
||||
COMMIT;
|
12
sql/load.sql
12
sql/load.sql
|
@ -156,4 +156,16 @@ CREATE TABLE IF NOT EXISTS "schools" (
|
|||
);
|
||||
|
||||
insert into schools select distinct * from "transformed"."schools";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "salaries" (
|
||||
"year" NUMERIC,
|
||||
"team" TEXT,
|
||||
"player" TEXT,
|
||||
"salary" NUMERIC,
|
||||
PRIMARY KEY("year","player","team"),
|
||||
foreign key("player") references "people"("ID"),
|
||||
foreign key("year") references "seasons"("year")
|
||||
);
|
||||
|
||||
insert into salaries select distinct * from "transformed"."salaries";
|
||||
COMMIT;
|
||||
|
|
Loading…
Reference in New Issue