This commit is contained in:
Nick Griffey 2024-01-25 18:48:11 -06:00
parent f9bfd7b7e6
commit 6ac7517a56
20 changed files with 477 additions and 0 deletions

30
sql/keys/appearances.sql Normal file
View File

@ -0,0 +1,30 @@
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")
);
INSERT INTO "pk_appearances" SELECT DISTINCT * FROM "appearances";
DROP TABLE "appearances";
ALTER TABLE "pk_appearances" RENAME TO "appearances";
commit;

View File

@ -0,0 +1,16 @@
begin;
CREATE TABLE IF NOT EXISTS "pk_awardssharemanagers" (
"awardID" TEXT,
"yearID" NUMERIC,
"lgID" TEXT,
"playerID" TEXT,
"pointsWon" NUMERIC,
"pointsMax" NUMERIC,
"votesFirst" NUMERIC,
PRIMARY KEY("playerID","awardID","yearID","lgID")
);
INSERT INTO "pk_awardssharemanagers" SELECT DISTINCT * FROM "awardssharemanagers";
DROP TABLE "awardssharemanagers";
ALTER TABLE "pk_awardssharemanagers" RENAME TO "awardssharemanagers";
commit;

View File

@ -0,0 +1,16 @@
begin;
CREATE TABLE IF NOT EXISTS "pk_awardsshareplayers" (
"awardID" TEXT,
"yearID" NUMERIC,
"lgID" TEXT,
"playerID" TEXT,
"pointsWon" NUMERIC,
"pointsMax" NUMERIC,
"votesFirst" NUMERIC,
PRIMARY KEY("awardID","yearID","playerID","lgID")
);
INSERT INTO "pk_awardsshareplayers" SELECT DISTINCT * FROM "awardsshareplayers";
DROP TABLE "awardsshareplayers";
ALTER TABLE "pk_awardsshareplayers" RENAME TO "awardsshareplayers";
commit;

31
sql/keys/batting.sql Normal file
View File

@ -0,0 +1,31 @@
begin;
CREATE TABLE IF NOT EXISTS "pk_batting" (
"playerID" TEXT,
"yearID" NUMERIC,
"stint" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"G" NUMERIC,
"AB" NUMERIC,
"R" NUMERIC,
"H" NUMERIC,
"2B" NUMERIC,
"3B" NUMERIC,
"HR" NUMERIC,
"RBI" NUMERIC,
"SB" NUMERIC,
"CS" NUMERIC,
"BB" NUMERIC,
"SO" NUMERIC,
"IBB" NUMERIC,
"HBP" NUMERIC,
"SH" NUMERIC,
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID")
);
INSERT INTO "pk_batting" SELECT DISTINCT * FROM "batting";
DROP TABLE "batting";
ALTER TABLE "pk_batting" RENAME TO "batting";
commit;

31
sql/keys/battingpost.sql Normal file
View File

@ -0,0 +1,31 @@
begin;
CREATE TABLE IF NOT EXISTS "pk_battingpost" (
"yearID" NUMERIC,
"round" NUMERIC,
"playerID" TEXT,
"teamID" TEXT,
"lgID" TEXT,
"G" NUMERIC,
"AB" NUMERIC,
"R" NUMERIC,
"H" NUMERIC,
"2B" NUMERIC,
"3B" NUMERIC,
"HR" NUMERIC,
"RBI" NUMERIC,
"SB" NUMERIC,
"CS" NUMERIC,
"BB" NUMERIC,
"SO" NUMERIC,
"IBB" NUMERIC,
"HBP" NUMERIC,
"SH" NUMERIC,
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("yearID","playerID","round")
);
INSERT INTO "pk_battingpost" SELECT DISTINCT * FROM "battingpost";
DROP TABLE "battingpost";
ALTER TABLE "pk_battingpost" RENAME TO "battingpost";
commit;

View File

@ -0,0 +1,12 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_collegeplaying" (
"playerID" TEXT,
"schoolID" TEXT,
"yearID" NUMERIC,
PRIMARY KEY("playerID","yearID","schoolID")
);
INSERT INTO "pk_collegeplaying" SELECT DISTINCT * FROM "collegeplaying";
DROP TABLE "collegeplaying";
ALTER TABLE "pk_collegeplaying" RENAME TO "collegeplaying";
COMMIT;

27
sql/keys/fielding.sql Normal file
View File

@ -0,0 +1,27 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_fielding" (
"playerID" TEXT,
"yearID" NUMERIC,
"stint" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"POS" TEXT,
"G" NUMERIC,
"GS" NUMERIC,
"InnOuts" NUMERIC,
"PO" NUMERIC,
"A" NUMERIC,
"E" NUMERIC,
"DP" NUMERIC,
"PB" NUMERIC,
"WP" NUMERIC,
"SB" NUMERIC,
"CS" NUMERIC,
"ZR" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID","POS")
);
INSERT INTO "pk_fielding" SELECT DISTINCT * FROM "fielding";
DROP TABLE "fielding";
ALTER TABLE "pk_fielding" RENAME TO "fielding";
COMMIT;

15
sql/keys/fieldingof.sql Normal file
View File

@ -0,0 +1,15 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_fieldingof" (
"playerID" TEXT,
"yearID" NUMERIC,
"stint" NUMERIC,
"Glf" NUMERIC,
"Gcf" NUMERIC,
"Grf" NUMERIC,
PRIMARY KEY("playerID","yearID","stint")
);
INSERT INTO "pk_fieldingof" SELECT DISTINCT * FROM "fieldingof";
DROP TABLE "fieldingof";
ALTER TABLE "pk_fieldingof" RENAME TO "fieldingof";
COMMIT;

View File

@ -0,0 +1,27 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_fieldingofsplit" (
"playerID" TEXT,
"yearID" NUMERIC,
"stint" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"POS" TEXT,
"G" NUMERIC,
"GS" NUMERIC,
"InnOuts" NUMERIC,
"PO" NUMERIC,
"A" NUMERIC,
"E" NUMERIC,
"DP" NUMERIC,
"PB" NUMERIC,
"WP" NUMERIC,
"SB" NUMERIC,
"CS" NUMERIC,
"ZR" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID","POS")
);
INSERT INTO "pk_fieldingofsplit" SELECT DISTINCT * FROM "fieldingofsplit";
DROP TABLE "fieldingofsplit";
ALTER TABLE "pk_fieldingofsplit" RENAME TO "fieldingofsplit";
COMMIT;

26
sql/keys/fieldingpost.sql Normal file
View File

@ -0,0 +1,26 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_fieldingpost" (
"playerID" TEXT,
"yearID" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"round" NUMERIC,
"POS" TEXT,
"G" NUMERIC,
"GS" NUMERIC,
"InnOuts" NUMERIC,
"PO" NUMERIC,
"A" NUMERIC,
"E" NUMERIC,
"DP" NUMERIC,
"TP" NUMERIC,
"PB" NUMERIC,
"SB" NUMERIC,
"CS" NUMERIC,
PRIMARY KEY("playerID","yearID","round","POS")
);
INSERT INTO "pk_fieldingpost" SELECT DISTINCT * FROM "fieldingpost";
DROP TABLE "fieldingpost";
ALTER TABLE "pk_fieldingpost" RENAME TO "fieldingpost";
COMMIT;

18
sql/keys/halloffame.sql Normal file
View File

@ -0,0 +1,18 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_halloffame" (
"playerID" TEXT,
"yearID" NUMERIC,
"votedBy" TEXT,
"ballots" NUMERIC,
"needed" NUMERIC,
"votes" NUMERIC,
"inducted" TEXT,
"category" TEXT,
"needed_note" TEXT,
PRIMARY KEY("playerID","yearID","votedBy")
);
INSERT INTO "pk_halloffame" SELECT DISTINCT * FROM "halloffame";
DROP TABLE "halloffame";
ALTER TABLE "pk_halloffame" RENAME TO "halloffame";
COMMIT;

15
sql/keys/parks.sql Normal file
View File

@ -0,0 +1,15 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_parks" (
"park.key" TEXT,
"park.name" TEXT,
"park.alias" TEXT,
"city" TEXT,
"state" TEXT,
"country" TEXT,
PRIMARY KEY("park.key")
);
INSERT INTO "pk_parks" SELECT DISTINCT * FROM "parks";
DROP TABLE "parks";
ALTER TABLE "pk_parks" RENAME TO "parks";
COMMIT;

39
sql/keys/pitching.sql Normal file
View File

@ -0,0 +1,39 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_pitching" (
"playerID" TEXT,
"yearID" NUMERIC,
"stint" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"W" NUMERIC,
"L" NUMERIC,
"G" NUMERIC,
"GS" NUMERIC,
"CG" NUMERIC,
"SHO" NUMERIC,
"SV" NUMERIC,
"IPouts" NUMERIC,
"H" NUMERIC,
"ER" NUMERIC,
"HR" NUMERIC,
"BB" NUMERIC,
"SO" NUMERIC,
"BAOpp" NUMERIC,
"ERA" NUMERIC,
"IBB" NUMERIC,
"WP" NUMERIC,
"HBP" NUMERIC,
"BK" NUMERIC,
"BFP" NUMERIC,
"GF" NUMERIC,
"R" NUMERIC,
"SH" NUMERIC,
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("playerID","yearID","stint","teamID")
);
INSERT INTO "pk_pitching" SELECT DISTINCT * FROM "pitching";
DROP TABLE "pitching";
ALTER TABLE "pk_pitching" RENAME TO "pitching";
COMMIT;

39
sql/keys/pitchingpost.sql Normal file
View File

@ -0,0 +1,39 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_pitchingpost" (
"playerID" TEXT,
"yearID" NUMERIC,
"round" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"W" NUMERIC,
"L" NUMERIC,
"G" NUMERIC,
"GS" NUMERIC,
"CG" NUMERIC,
"SHO" NUMERIC,
"SV" NUMERIC,
"IPouts" NUMERIC,
"H" NUMERIC,
"ER" NUMERIC,
"HR" NUMERIC,
"BB" NUMERIC,
"SO" NUMERIC,
"BAOpp" NUMERIC,
"ERA" NUMERIC,
"IBB" NUMERIC,
"WP" NUMERIC,
"HBP" NUMERIC,
"BK" NUMERIC,
"BFP" NUMERIC,
"GF" NUMERIC,
"R" NUMERIC,
"SH" NUMERIC,
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("playerID","yearID","round")
);
INSERT INTO "pk_pitchingpost" SELECT DISTINCT * FROM "pitchingpost";
DROP TABLE "pitchingpost";
ALTER TABLE "pk_pitchingpost" RENAME TO "pitchingpost";
COMMIT;

14
sql/keys/salaries.sql Normal file
View File

@ -0,0 +1,14 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_salaries" (
"yearID" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"playerID" TEXT,
"salary" NUMERIC,
PRIMARY KEY("yearID","playerID","teamID")
);
INSERT INTO "pk_salaries" SELECT DISTINCT * FROM "salaries";
DROP TABLE "salaries";
ALTER TABLE "pk_salaries" RENAME TO "salaries";
COMMIT;

14
sql/keys/schools.sql Normal file
View File

@ -0,0 +1,14 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_schools" (
"schoolID" TEXT,
"name_full" TEXT,
"city" TEXT,
"state" TEXT,
"country" TEXT,
PRIMARY KEY("schoolID")
);
INSERT INTO "pk_schools" SELECT DISTINCT * FROM "schools";
DROP TABLE "schools";
ALTER TABLE "pk_schools" RENAME TO "schools";
COMMIT;

18
sql/keys/seriespost.sql Normal file
View File

@ -0,0 +1,18 @@
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;

57
sql/keys/teams.sql Normal file
View File

@ -0,0 +1,57 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_teams" (
"yearID" NUMERIC,
"lgID" TEXT,
"teamID" TEXT,
"franchID" TEXT,
"divID" TEXT,
"Rank" NUMERIC,
"G" NUMERIC,
"Ghome" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
"DivWin" NUMERIC,
"WCWin" NUMERIC,
"LgWin" NUMERIC,
"WSWin" NUMERIC,
"R" NUMERIC,
"AB" NUMERIC,
"H" NUMERIC,
"2B" NUMERIC,
"3B" NUMERIC,
"HR" NUMERIC,
"BB" NUMERIC,
"SO" NUMERIC,
"SB" NUMERIC,
"CS" NUMERIC,
"HBP" NUMERIC,
"SF" NUMERIC,
"RA" NUMERIC,
"ER" NUMERIC,
"ERA" NUMERIC,
"CG" NUMERIC,
"SHO" NUMERIC,
"SV" NUMERIC,
"IPouts" NUMERIC,
"HA" NUMERIC,
"HRA" NUMERIC,
"BBA" NUMERIC,
"SOA" NUMERIC,
"E" NUMERIC,
"DP" NUMERIC,
"FP" NUMERIC,
"name" NUMERIC,
"park" NUMERIC,
"attendance" NUMERIC,
"BPF" NUMERIC,
"PPF" NUMERIC,
"teamIDBR" TEXT,
"teamIDlahman45" TEXT,
"teamIDretro" TEXT,
PRIMARY KEY("yearID","teamID")
);
INSERT INTO "pk_teams" SELECT DISTINCT * FROM "teams";
DROP TABLE "teams";
ALTER TABLE "pk_teams" RENAME TO "teams";
COMMIT;

View File

@ -0,0 +1,13 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_teamsfranchises" (
"franchID" TEXT,
"franchName" TEXT,
"active" TEXT,
"NAassoc" TEXT,
PRIMARY KEY("franchID")
);
INSERT INTO "pk_teamsfranchises" SELECT DISTINCT * FROM "teamsfranchises";
DROP TABLE "teamsfranchises";
ALTER TABLE "pk_teamsfranchises" RENAME TO "teamsfranchises";
COMMIT;

19
sql/keys/teamshalf.sql Normal file
View File

@ -0,0 +1,19 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_teamshalf" (
"yearID" NUMERIC,
"lgID" TEXT,
"teamID" TEXT,
"Half" NUMERIC,
"divID" TEXT,
"DivWin" TEXT,
"Rank" NUMERIC,
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
PRIMARY KEY("Half","yearID","teamID")
);
INSERT INTO "pk_teamshalf" SELECT DISTINCT * FROM "teamshalf";
DROP TABLE "teamshalf";
ALTER TABLE "pk_teamshalf" RENAME TO "teamshalf";
COMMIT;