├── baseball-database ├── readme.md ├── .DS_Store └── lahmansbaseballdb-backup │ ├── lahmansbaseballdb_routines.sql │ ├── lahmansbaseballdb_teamsfranchises.sql │ ├── lahmansbaseballdb_awardsmanagers.sql │ ├── lahmansbaseballdb_seriespost.sql │ └── lahmansbaseballdb_parks.sql ├── chapter-4 ├── create-database.sql ├── create-teams-table.sql └── create-managers-table.sql ├── chapter-5 ├── check-secure-file-priv-setting.sql ├── import-data-with-sql-script.sql └── export-data-with-sql-script.sql ├── .DS_Store ├── Readme ├── chapter-14 ├── story-presentation.pdf ├── story-presentation.pptx └── queries-to-gather-data.sql ├── chapter-9 ├── operators.sql ├── literals.sql ├── statistical-functions.sql ├── generated-columns.sql ├── numeric-built-in-functions.sql ├── string-built-in-functions.sql ├── advanced-built-in-functions.sql └── datetime-built-in-functions.sql ├── chapter-13 ├── exploring-your-dataset.sql ├── fixing-erroneous-values.sql ├── fixing-missing-values.sql ├── fixing-rare-outlier-values.sql ├── exploring-statistical-identity.sql ├── exploring-regular-expressions.sql ├── removing-duplicate-values.sql ├── fixing-duplicate-values.sql ├── exploring-rare-missing-duplicate-values.sql └── mysql-workbench-plugin-doc-generating.py ├── chapter-8 ├── gathering-table-info.sql ├── delete.sql ├── update.sql ├── insert-multiple-row.sql ├── insert-single-row.sql ├── transactions.sql ├── insert-from-existing-table.sql └── modify-table.sql ├── chapter-11 ├── isolation-levels.sql ├── common-table-expressions.sql ├── index-hints.sql ├── correlated-subqueries.sql └── non-correlated-subqueries.sql ├── chapter-6 ├── use-statement.sql ├── commenting-sql-code.sql ├── wildcard-underscore.sql ├── wildcard-percent.sql ├── order-by-clause.sql ├── indexes-used.sql ├── select-clause.sql └── where-clause.sql ├── chapter-10 ├── aggregate-functions.sql ├── rollup.sql ├── having.sql └── group-by.sql ├── chapter-12 ├── views-alter-drop.sql ├── variables.sql ├── views-create-and-select-from.sql ├── views-delete-data-from.sql ├── stored-proc-error-handling.sql ├── temporary-tables.sql ├── views-insert-data-into.sql ├── stored-proc-create-and-alter.sql ├── views-update-data-in.sql ├── functions.sql ├── stored-proc-flow-control.sql ├── stored-proc-parameters.sql └── triggers.sql ├── chapter-15 └── examples.sql ├── chapter-7 ├── advanced-joins.sql ├── multi-table-indexes.sql ├── inner-join.sql ├── set-operators.sql └── outer-join.sql ├── LICENSE ├── baseballdatabank-csv ├── README.txt └── csv-files │ ├── TeamsFranchises.csv │ ├── AwardsManagers.csv │ ├── SeriesPost.csv │ ├── Parks.csv │ └── readme2014.txt └── README.md /baseball-database/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /chapter-4/create-database.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE yourschema; -------------------------------------------------------------------------------- /chapter-5/check-secure-file-priv-setting.sql: -------------------------------------------------------------------------------- 1 | select @@secure_file_priv; -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/learn-sql-database-programming/HEAD/.DS_Store -------------------------------------------------------------------------------- /Readme: -------------------------------------------------------------------------------- 1 | Chap 1 to 3 consist of theory and syntax codes 2 | Chap 4 to 15 have code files 3 | Chap 16 is Appendix -------------------------------------------------------------------------------- /baseball-database/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/learn-sql-database-programming/HEAD/baseball-database/.DS_Store -------------------------------------------------------------------------------- /chapter-14/story-presentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/learn-sql-database-programming/HEAD/chapter-14/story-presentation.pdf -------------------------------------------------------------------------------- /chapter-14/story-presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/learn-sql-database-programming/HEAD/chapter-14/story-presentation.pptx -------------------------------------------------------------------------------- /chapter-5/import-data-with-sql-script.sql: -------------------------------------------------------------------------------- 1 | LOAD DATA INFILE '/pathtoyourfiles/baseballdatabank-csv/csv-files/Managers.csv' 2 | INTO TABLE yourschema.managers 3 | FIELDS TERMINATED BY ','; -------------------------------------------------------------------------------- /chapter-9/operators.sql: -------------------------------------------------------------------------------- 1 | SELECT 'string'+2 as stringvalue, 2 | 1+2 as numbervalue, 3 | 1.23+2 as floatdecimalvalue, 4 | NULL+2 as 'nullvalue'; 5 | 6 | -------------------------------------------------------------------------------- /chapter-5/export-data-with-sql-script.sql: -------------------------------------------------------------------------------- 1 | SELECT * INTO OUTFILE 'results.txt' 2 | FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 3 | LINES TERMINATED BY '\n' 4 | FROM yourschema.teams; -------------------------------------------------------------------------------- /chapter-13/exploring-your-dataset.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT AVG(h) AS mean, 3 | STDDEV(h) AS stddev, 4 | VARIANCE(h) AS variance, 5 | MIN(h) AS minimum, 6 | MAX(h) AS maximum 7 | FROM batting; -------------------------------------------------------------------------------- /chapter-9/literals.sql: -------------------------------------------------------------------------------- 1 | SELECT 'string', 1, 1.23, NULL; 2 | 3 | SELECT 'string' as stringvalue, 4 | 1 as numbervalue, 5 | 1.23 as floatdecimalvalue, 6 | NULL as 'nullvalue'; -------------------------------------------------------------------------------- /chapter-8/gathering-table-info.sql: -------------------------------------------------------------------------------- 1 | #in MySQL 2 | USE yourschema; 3 | describe managers; 4 | 5 | SELECT * FROM information_schema.table_constraints 6 | WHERE table_name = 'managers' 7 | AND table_schema = 'yourschema'; 8 | 9 | SHOW CREATE TABLE managers; 10 | -------------------------------------------------------------------------------- /chapter-11/isolation-levels.sql: -------------------------------------------------------------------------------- 1 | #set transaction isolation level on a query 2 | USE lahmansbaseballdb; 3 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; /*doesn't work in oracle since it only allows serializable or read committed */ 4 | SELECT * FROM appearances; 5 | -------------------------------------------------------------------------------- /chapter-9/statistical-functions.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT COUNT(h) AS count, 3 | SUM(h) AS sum, 4 | AVG(h) AS mean, 5 | STDDEV(h) AS 'stddev', 6 | VARIANCE(h) AS 'variance', 7 | MIN(h) AS minimum, 8 | MAX(h) AS maximum 9 | FROM batting; 10 | 11 | -------------------------------------------------------------------------------- /chapter-6/use-statement.sql: -------------------------------------------------------------------------------- 1 | #with use statement 2 | USE lahmansbaseballdb; 3 | SELECT playerid, g_all, g_batting, g_defense FROM appearances; 4 | 5 | #without use statement, then database reference needs to be in front of table reference i.e. lahmansbaseballdb.appearances 6 | SELECT playerid, g_all, g_batting, g_defense FROM lahmansbaseballdb.appearances; -------------------------------------------------------------------------------- /chapter-13/fixing-erroneous-values.sql: -------------------------------------------------------------------------------- 1 | # fixing erroneous values 2 | USE lahmansbaseballdb; 3 | SELECT * FROM schools 4 | WHERE name_full = '"California Polytechnic State University'; 5 | 6 | USE lahmansbaseballdb; 7 | UPDATE schools 8 | SET name_full = 'California Polytechnic State University', 9 | city = 'San Luis Obispo', 10 | state = 'CA', 11 | country = 'USA' 12 | WHERE schoolid = 'calpolypom'; -------------------------------------------------------------------------------- /chapter-10/aggregate-functions.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT 3 | ROUND(AVG(g_all),1) as average_g_all_rounded, 4 | MAX(g_all) as max_g_all, 5 | MIN(g_all) as min_g_all, 6 | FORMAT(COUNT(g_all), 0) as count_g_all_formatted, 7 | SUM(g_all) as sum_g_all 8 | FROM appearances; 9 | 10 | 11 | USE lahmansbaseballdb; 12 | SELECT 13 | STDDEV(h) AS 'stddev', 14 | VARIANCE(h) AS 'variance' 15 | FROM batting; 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /chapter-13/fixing-missing-values.sql: -------------------------------------------------------------------------------- 1 | # fixing missing values 2 | USE lahmansbaseballdb; 3 | SELECT 4 | SUM(!ISNULL(birthyear)) AS birthyear_count, 5 | SUM(ISNULL(birthyear)) AS null_birthyear_count 6 | FROM people; 7 | 8 | USE lahmansbaseballdb; 9 | SELECT playerid, namefirst, namelast, debut 10 | FROM people 11 | WHERE birthyear is NULL; 12 | 13 | USE lahmansbaseballdb; 14 | UPDATE people 15 | SET birthyear = whateverbirthyeariscorrect 16 | WHERE playerid = 'barre01'; 17 | -------------------------------------------------------------------------------- /chapter-9/generated-columns.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | ALTER TABLE batting 3 | ADD COLUMN batavg DECIMAL(4,3) 4 | GENERATED ALWAYS AS (h/ab) 5 | AFTER lgID; 6 | 7 | USE lahmansbaseballdb; 8 | ALTER TABLE batting 9 | ADD COLUMN batavgstored DECIMAL(4,3) GENERATED ALWAYS AS (h/ab) STORED AFTER lgID; 10 | 11 | USE lahmansbaseballdb; 12 | ALTER TABLE batting 13 | ADD COLUMN batavgstored DECIMAL(4,3) 14 | GENERATED ALWAYS AS (h/NULLIF(ab,0)) 15 | STORED AFTER lgID; 16 | 17 | -------------------------------------------------------------------------------- /chapter-8/delete.sql: -------------------------------------------------------------------------------- 1 | #delete only some records from a table 2 | USE lahmansbaseballdb; 3 | SELECT * FROM collegeplaying 4 | WHERE playerid = 'blaloha01'; 5 | 6 | USE lahmansbaseballdb; 7 | DELETE FROM collegeplaying 8 | WHERE playerid = 'blaloha01' 9 | AND (schoolid IS NULL OR yearid IS NULL); 10 | 11 | #delete all data from a table 12 | USE yourschema; 13 | DELETE FROM allstarfull; 14 | 15 | #alternate script to delete all data from table 16 | USE yourschema; 17 | TRUNCATE TABLE allstarfull; 18 | -------------------------------------------------------------------------------- /chapter-10/rollup.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 3 | FROM batting 4 | GROUP BY playerid, teamid; 5 | 6 | USE lahmansbaseballdb; 7 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 8 | FROM batting 9 | GROUP BY playerid, teamid WITH ROLLUP; 10 | 11 | /* in oracle, postgresql, and sql server */ 12 | USE lahmansbaseballdb; 13 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 14 | FROM batting 15 | GROUP BY ROLLUP (playerid, teamid) 16 | ORDER BY playerid, teamid; -------------------------------------------------------------------------------- /chapter-12/views-alter-drop.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | ALTER VIEW parksalias AS /*not available in postgresql or oracle */ 3 | SELECT parkalias, parkkey, parkname, city, state, country 4 | FROM parks_copy 5 | WHERE parkalias IS NOT NULL 6 | WITH CHECK OPTION; 7 | 8 | /* use this in postgresql or oracle instead */  9 | CREATE OR REPLACE VIEW parksalias AS 10 | SELECT parkalias, parkkey, parkname, city, state, country 11 | FROM parks_copy 12 | WHERE parkalias IS NOT NULL 13 | WITH CHECK OPTION; 14 | 15 | DROP VIEW playergameinfo; -------------------------------------------------------------------------------- /chapter-15/examples.sql: -------------------------------------------------------------------------------- 1 | /* create statement all on one line is less readable */ 2 | CREATE TABLE `managers` (`managerkey` smallint NOT NULL,`playerid` varchar(9) NOT NULL,`yearid` year(4) NOT NULL,`teamid` char(3) NOT NULL); 3 | 4 | /* create statement separated into multiple lines is more readable */ 5 | CREATE TABLE `managers` ( 6 | `managerkey` smallint NOT NULL, 7 | `playerid` varchar(9) NOT NULL, 8 | `yearid` year(4) NOT NULL); 9 | 10 | /* slower query */ 11 | SELECT column WHERE UPPER(column) = 'ab'; 12 | 13 | /* faster query */ 14 | SELECT column WHERE column = 'ab'; 15 | 16 | -------------------------------------------------------------------------------- /chapter-6/commenting-sql-code.sql: -------------------------------------------------------------------------------- 1 | # this is single line comment 2 | 3 | /* 4 | this is a multi line comment 5 | */ 6 | 7 | /* 8 | Created by: Josephine Bush 9 | Created on: November 15, 2019 10 | Purpose: Selecting distinct rows in appearances table to provide in a report 11 | 12 | Modified by Modified on Modification notes 13 | JBush 11/16/19 Changed distinct to include teams and playerids 14 | */ 15 | 16 | #commenting out a section of your code 17 | USE lahmansbaseballdb; 18 | SELECT playerid, g_all, g_batting/*, g_defense*/ FROM appearances 19 | LIMIT 500 OFFSET 1000; -------------------------------------------------------------------------------- /chapter-13/fixing-rare-outlier-values.sql: -------------------------------------------------------------------------------- 1 | #fixing rare/outlier values 2 | USE lahmansbaseballdb; 3 | SELECT DISTINCT h as hits, COUNT(h) as count 4 | FROM batting 5 | GROUP BY hits 6 | ORDER BY count; 7 | 8 | USE lahmansbaseballdb; 9 | SELECT b.playerid, namefirst, namelast, 10 | yearid, teamid, g, ab, h 11 | FROM batting b 12 | INNER JOIN people p 13 | ON p.playerid = b.playerid 14 | WHERE h = 248; 15 | 16 | USE lahmansbaseballdb; 17 | UPDATE batting 18 | SET h = whatevernumberiscorrect 19 | WHERE playerid = 'cobbty01' 20 | AND yearid = 1911 21 | AND teamid = 'DET'; 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/create-teams-table.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE yourschema.`teams` ( 2 | `teamkey` smallint(5) NOT NULL AUTO_INCREMENT, 3 | `teamid` char(3) NOT NULL, 4 | `yearid` year(4) NOT NULL, 5 | `leagueid` char(2) NOT NULL, 6 | `teamrank` tinyint(2) NOT NULL, 7 | PRIMARY KEY (`teamkey`), 8 | UNIQUE KEY `teamkey_UNIQUE` (`teamkey`), 9 | KEY `teamid_yearid_leagueid_UNIQUE` (`teamid`,`yearid`,`leagueid`), 10 | CONSTRAINT `check_teamrank` CHECK (((`teamrank` >= 0) and (`teamrank` <= 12))), 11 | CONSTRAINT `check_year` CHECK (((`yearid` >= 1871) and (`yearid` <= 2155)))) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -------------------------------------------------------------------------------- /chapter-9/numeric-built-in-functions.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT ROUND(AVG(g_all),1) as average_g_all, 3 | MAX(g_all) as max_g_all, 4 | MIN(g_all) as min_g_all 5 | FROM appearances; 6 | 7 | USE lahmansbaseballdb; 8 | SELECT playerid, 9 | ROUND(AVG(g_all),1) as average_g_all, 10 | MAX(g_all) as max_g_all, 11 | MIN(g_all) as min_g_all 12 | FROM appearances 13 | GROUP BY playerid 14 | ORDER BY playerid; 15 | 16 | SELECT 17 | AVG(ab) AS mean, 18 | STDDEV(ab) AS 'stddev', 19 | VARIANCE(ab) AS 'variance', 20 | MIN(ab) AS minimum, 21 | MAX(ab) AS maximum 22 | FROM batting; -------------------------------------------------------------------------------- /chapter-11/common-table-expressions.sql: -------------------------------------------------------------------------------- 1 | #non-recursive cte 2 | USE lahmansbaseballdb; 3 | WITH avgsalarycte 4 | AS 5 | (SELECT AVG(salary) AS average_salary 6 | FROM salaries 7 | GROUP BY teamid) 8 | 9 | SELECT ROUND(AVG(average_salary), 0) AS average_of_all_teams_salaries /* use ROUND(AVG(average_salary)) in PostgreSQL */ 10 | FROM avgsalarycte 11 | WHERE average_salary > 2000000; 12 | 13 | #recursive cte 14 | WITH RECURSIVE cte (x) AS /* remove RECURSIVE to use with sql server and oracle */ 15 | ( 16 | SELECT 1 /* add FROM dual for oracle */ 17 | UNION ALL 18 | SELECT x + 1 FROM cte 19 | WHERE x < 10 20 | ) 21 | SELECT x FROM cte; -------------------------------------------------------------------------------- /chapter-12/variables.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | /* DECLARE @varname varchar(5); in sql server you have to declare the variable before setting it */ 3 | /* DECLARE @varname varchar(5) = 'ALB01'; Also, in sql server you can declare and set the variable in one line */ 4 | SET @varname := 'ALB01'; 5 | SELECT * FROM parks_copy 6 | WHERE parkkey = @varname; 7 | 8 | 9 | /* oracle variables */ 10 | DECLARE 11 | var_parkname varchar2(100); 12 | var_parkkey varchar2(5) := 'ALB01'; 13 | BEGIN 14 | SELECT parkname INTO var_parkname FROM parks_copy 15 | WHERE parkkey = var_parkkey; 16 | DBMS_OUTPUT.PUT_LINE(var_parkname); 17 | END; 18 | -------------------------------------------------------------------------------- /chapter-8/update.sql: -------------------------------------------------------------------------------- 1 | #update certain rows in a table 2 | USE lahmansbaseballdb; 3 | UPDATE collegeplaying 4 | SET schoolID = 'sandiego', yearid = 2000 5 | WHERE playerid = 'blaloha01'; 6 | 7 | USE lahmansbaseballdb; 8 | UPDATE collegeplaying 9 | SET yearid = 1999 10 | WHERE playerid = 'blaloha01'; 11 | 12 | #update all rows in a table 13 | USE lahmansbaseballdb; 14 | UPDATE managerscopy 15 | SET lgid = '--'; 16 | 17 | #update by joining to another table 18 | USE lahmansbaseballdb; 19 | UPDATE managerscopy mc 20 | INNER JOIN managers m 21 | ON m.playerid = mc.playerid 22 | AND mc.teamid = m.teamid 23 | AND mc.yearid = m.yearid 24 | SET mc.lgid = m.lgid -------------------------------------------------------------------------------- /chapter-11/index-hints.sql: -------------------------------------------------------------------------------- 1 | /*doesn't work in sql server, postgres, or oracle - see the earlier chapters for explanations*/ 2 | 3 | #create index to use 4 | USE lahmansbaseballdb; 5 | ALTER TABLE appearances 6 | ADD INDEX NC_playerid_g_cols 7 | (playerID ASC, G_all ASC, G_batting ASC, G_defense ASC) VISIBLE; 8 | 9 | #show indexes in table 10 | USE lahmansbaseballdb; 11 | SHOW INDEXES FROM appearances; 12 | 13 | #explain query without hint 14 | USE lahmansbaseballdb; 15 | EXPLAIN SELECT playerid FROM appearances; 16 | 17 | #explain query with hint 18 | USE lahmansbaseballdb; 19 | EXPLAIN SELECT playerid FROM appearances USE INDEX (PRIMARY); 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter-8/insert-multiple-row.sql: -------------------------------------------------------------------------------- 1 | #the following query inserts three rows 2 | USE lahmansbaseballdb; 3 | INSERT INTO collegeplaying 4 | (playerID, schoolID, yearID) 5 | VALUES ('blaloha01','sandiegost',2000), 6 | ('blaloha01','sandiegost',2001), 7 | ('blaloha01','sandiegost',2002); 8 | 9 | #in oracle you need to use a different syntax as shown below 10 | INSERT ALL 11 | INTO collegeplaying(playerid, schoolid, yearid) VALUES('blaloha01','sandiegost',2000) 12 | INTO collegeplaying(playerid, schoolid, yearid) VALUES('blaloha01','sandiegost',2001) 13 | INTO collegeplaying(playerid, schoolid, yearid) VALUES('blaloha01','sandiegost',2002) 14 | SELECT * FROM DUAL; -------------------------------------------------------------------------------- /chapter-12/views-create-and-select-from.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | CREATE VIEW playergameinfo AS 3 | SELECT p.playerid, birthyear, 4 | a.yearid, a.teamid, 5 | G_defense AS defensegames, 6 | H AS numberofhits 7 | FROM appearances AS a /*remove AS for oracle */ 8 | JOIN people AS p /*remove AS for oracle */ 9 | ON p.playerid = a.playerid 10 | JOIN batting AS b /*remove AS for oracle */ 11 | ON a.playerid = b.playerid 12 | AND a.yearid = b.yearid 13 | AND a.teamid = b.teamid 14 | WHERE b.yearid = 2017 15 | AND H <> 0; 16 | 17 | 18 | SELECT * FROM playergameinfo; 19 | 20 | 21 | SELECT playerid, birthyear, yearid, teamid, defensegames 22 | FROM playergameinfo 23 | WHERE teamid = 'CHA' 24 | ORDER BY defensegames DESC; -------------------------------------------------------------------------------- /chapter-13/exploring-statistical-identity.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT AVG(h) AS mean, 3 | STDDEV(h) AS stddev, 4 | VARIANCE(h) AS variance, 5 | MIN(h) AS minimum, 6 | MAX(h) AS maximum 7 | FROM batting; 8 | 9 | SELECT playerid, 10 | AVG(h) AS mean, 11 | STDDEV(h) AS stddev, 12 | VARIANCE(h) AS variance, 13 | MIN(h) AS minimum, 14 | MAX(h) AS maximum 15 | FROM batting 16 | GROUP BY playerid; 17 | 18 | SELECT yearid, 19 | AVG(h) AS mean, 20 | STDDEV(h) AS stddev, 21 | VARIANCE(h) AS variance, 22 | MIN(h) AS minimum, 23 | MAX(h) AS maximum 24 | FROM batting 25 | GROUP BY yearid; 26 | 27 | SELECT teamid, 28 | AVG(h) AS mean, 29 | STDDEV(h) AS stddev, 30 | VARIANCE(h) AS variance, 31 | MIN(h) AS minimum, 32 | MAX(h) AS maximum 33 | FROM batting 34 | GROUP BY teamid; 35 | 36 | -------------------------------------------------------------------------------- /chapter-13/exploring-regular-expressions.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT playerid 3 | FROM people 4 | WHERE playerid REGEXP '^a'; 5 | 6 | SELECT birthcity 7 | FROM people 8 | WHERE birthcity REGEXP 'y$'; 9 | 10 | SELECT birthyear 11 | FROM people 12 | WHERE birthyear REGEXP '199.'; 13 | 14 | SELECT playerid 15 | FROM people 16 | WHERE playerid REGEXP '^[C]' 17 | ORDER BY playerid; 18 | 19 | SELECT playerid 20 | FROM people 21 | WHERE playerid REGEXP '^[^C]' 22 | ORDER BY playerid; 23 | 24 | SELECT playerid 25 | FROM people 26 | WHERE playerid REGEXP '^[C|D|E]' 27 | ORDER BY playerid; 28 | 29 | SELECT birthcity 30 | FROM people 31 | WHERE birthcity REGEXP 'son+'; 32 | 33 | SELECT DISTINCT birthcity 34 | FROM people 35 | WHERE birthcity REGEXP '^[abc].{3}on$' 36 | ORDER BY birthcity; 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /chapter-6/wildcard-underscore.sql: -------------------------------------------------------------------------------- 1 | #finds all rounds that end with "LCS" 2 | USE lahmansbaseballdb; 3 | SELECT playerid, yearid, teamid, round, pos 4 | FROM fieldingpost 5 | WHERE round LIKE '_LCS'; 6 | 7 | #finds all rounds that start with "LCS" 8 | USE lahmansbaseballdb; 9 | SELECT playerid, yearid, teamid, round, pos 10 | FROM fieldingpost 11 | WHERE round LIKE 'W_'; 12 | 13 | #finds all rounds that start with "AL" and has two characters after "AL" 14 | USE lahmansbaseballdb; 15 | SELECT playerid, yearid, teamid, round, pos 16 | FROM fieldingpost 17 | WHERE round LIKE 'AL__'; 18 | 19 | #finds all rounds that begin with one character, have "L", then one character then "S" in the middle, and end with one character 20 | USE lahmansbaseballdb; 21 | SELECT playerid, yearid, teamid, round, pos 22 | FROM fieldingpost 23 | WHERE round LIKE '_L_S_'; -------------------------------------------------------------------------------- /chapter-13/removing-duplicate-values.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | DROP TABLE IF EXISTS schools_copy; 3 | CREATE TABLE schools_copy 4 | SELECT * 5 | FROM schools 6 | WHERE 1=0; 7 | 8 | USE lahmansbaseballdb; 9 | INSERT INTO schools_copy VALUES 10 | ('adelphi','Adelphi University','Garden City','NY','USA'), 11 | ('adelphi1','Adelphi University','Garden City','NY','USA'), 12 | ('akron','University of Akron','Akron','OH','USA'), 13 | ('alabama','University of Alabama','Tuscaloosa','AL','USA'), 14 | ('alabamast','Alabama State University','Montgomery','AL','USA'); 15 | 16 | SELECT name_full 17 | FROM schools_copy 18 | GROUP BY name_full 19 | HAVING count(*) >= 2; 20 | 21 | USE lahmansbaseballdb; 22 | SELECT * FROM schools_copy 23 | WHERE name_full = 'Adelphi University'; 24 | 25 | USE lahmansbaseballdb; 26 | DELETE FROM schools_copy 27 | WHERE schoolid = 'adelphi1'; 28 | 29 | 30 | -------------------------------------------------------------------------------- /chapter-13/fixing-duplicate-values.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | DROP TABLE IF EXISTS schools_copy; 3 | CREATE TABLE schools_copy 4 | SELECT * 5 | FROM schools 6 | WHERE 1=0; 7 | 8 | INSERT INTO schools_copy VALUES 9 | ('adelphi','Adelphi University','Garden City','NY','USA'), 10 | ('adrianmi','Adelphi University','Garden City','NY','USA'), 11 | ('akron','University of Akron','Akron','OH','USA'), 12 | ('alabama','University of Alabama','Tuscaloosa','AL','USA'), 13 | ('alabamast','Alabama State University','Montgomery','AL','USA'); 14 | 15 | SELECT name_full 16 | FROM schools_copy 17 | GROUP BY name_full 18 | HAVING count(*) >= 2; 19 | 20 | USE lahmansbaseballdb; 21 | SELECT * FROM schools_copy 22 | WHERE name_full = 'Adelphi University'; 23 | 24 | USE lahmansbaseballdb; 25 | UPDATE schools_copy 26 | SET name_full = 'Adrian College', city = 'Adrian', state = 'MI', country = 'USA' 27 | WHERE schoolid = 'adrianmi'; 28 | 29 | 30 | -------------------------------------------------------------------------------- /chapter-6/wildcard-percent.sql: -------------------------------------------------------------------------------- 1 | #finds all playerids that start with the letter "a" 2 | USE lahmansbaseballdb; 3 | SELECT playerid, g_all, g_batting, g_defense 4 | FROM appearances 5 | WHERE playerid LIKE 'a%'; 6 | 7 | #finds all playerids that end with the letter "a" 8 | USE lahmansbaseballdb; 9 | SELECT playerid, g_all, g_batting, g_defense 10 | FROM appearances 11 | WHERE playerid LIKE '%a'; 12 | 13 | #finds all playerids that contain "a" 14 | USE lahmansbaseballdb; 15 | SELECT playerid, g_all, g_batting, g_defense 16 | FROM appearances 17 | WHERE playerid LIKE '%a%'; 18 | 19 | #finds all playerids that start with the letters "wr" 20 | USE lahmansbaseballdb; 21 | SELECT playerid, g_all, g_batting, g_defense 22 | FROM appearances 23 | WHERE playerid LIKE 'wr%'; 24 | 25 | #finds all playerids that contain "ds" 26 | USE lahmansbaseballdb; 27 | SELECT playerid, g_all, g_batting, g_defense 28 | FROM appearances 29 | WHERE playerid LIKE '%ds%'; -------------------------------------------------------------------------------- /chapter-10/having.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 3 | FROM batting 4 | GROUP BY playerid, teamid 5 | HAVING sum_at_bats > 100; 6 | 7 | USE lahmansbaseballdb; 8 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 9 | FROM batting 10 | WHERE sum(AB) > 100 11 | GROUP BY playerid, teamid; 12 | 13 | USE lahmansbaseballdb; 14 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 15 | FROM batting 16 | GROUP BY playerid, teamid 17 | HAVING sum_at_bats > 100 18 | AND sum_at_bats < 400; 19 | 20 | USE lahmansbaseballdb; 21 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 22 | FROM batting 23 | GROUP BY playerid, teamid 24 | HAVING sum_at_bats BETWEEN 100 AND 400; 25 | 26 | USE lahmansbaseballdb; 27 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 28 | FROM batting 29 | WHERE ab <> 0 30 | AND ab IS NOT NULL 31 | GROUP BY playerid, teamid 32 | HAVING sum(AB) BETWEEN 100 and 400; 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /chapter-7/advanced-joins.sql: -------------------------------------------------------------------------------- 1 | #cross join 2 | USE lahmansbaseballdb 3 | SELECT c.playerid, c.schoolid, c.yearid, city, state, country 4 | FROM collegeplaying c 5 | CROSS JOIN schools s 6 | WHERE s.schoolid = 'akron'; 7 | 8 | #cross join without cross keyword will work the same as the cross join 9 | #does not work in sql server 10 | USE lahmansbaseballdb 11 | SELECT c.playerid, c.schoolid, c.yearid, city, state, country 12 | FROM collegeplaying c 13 | JOIN schools s 14 | WHERE s.schoolid = 'akron'; 15 | 16 | #natural join 17 | #does not work in sql server 18 | USE lahmansbaseballdb 19 | SELECT c.playerid, c.schoolid, c.yearid, s.schoolid, city, state, country 20 | FROM collegeplaying c 21 | NATURAL JOIN schools s; 22 | 23 | #self join 24 | USE lahmansbaseballdb 25 | SELECT e.FirstName + ' ' + e.LastName AS EmployeeName, 26 | m.FirstName + ' ' + m.LastName AS ManagerName 27 | FROM Employees AS e 28 | LEFT OUTER JOIN Employees m 29 | ON e.ManagerID = m.EmployeeID 30 | ORDER BY ManagerName; 31 | 32 | 33 | -------------------------------------------------------------------------------- /chapter-7/multi-table-indexes.sql: -------------------------------------------------------------------------------- 1 | #explain multi table select 2 | EXPLAIN SELECT p.playerid, p.birthyear, 3 | a.yearid, a.teamid, a.G_defense, b.H 4 | FROM lahmansbaseballdb.appearances AS a 5 | INNER JOIN lahmansbaseballdb.people AS p 6 | ON p.playerid = a.playerid 7 | INNER JOIN lahmansbaseballdb.batting AS b 8 | ON p.playerid = b.playerid 9 | WHERE b.yearid = 2017 10 | AND b.H <> 0 11 | ORDER BY p.playerid, a.yearid, a.teamid, a.G_defense, b.H; 12 | 13 | #add people table nonclustered index 14 | ALTER TABLE lahmansbaseballdb.people 15 | ADD INDEX `NC_playerid_birthyear` (playerID ASC, birthYear ASC) VISIBLE; 16 | 17 | #add appearances table nonclustered index 18 | ALTER TABLE lahmansbaseballdb.appearances 19 | ADD INDEX `NC_playerid_yearid_teamid_G_defense` (playerID ASC, yearID ASC, teamID ASC, G_defense ASC) VISIBLE; 20 | 21 | #add batting table nonclustered index 22 | ALTER TABLE lahmansbaseballdb.batting 23 | ADD INDEX `NC_playerid_yearid_H` (playerID ASC, yearID ASC, H ASC) VISIBLE; 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /chapter-10/group-by.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT playerid, teamid 3 | FROM batting 4 | GROUP BY teamid; 5 | 6 | USE lahmansbaseballdb; 7 | SELECT playerid, teamid 8 | FROM batting 9 | GROUP BY teamid, playerid; 10 | 11 | USE lahmansbaseballdb; 12 | SELECT playerid, teamid 13 | FROM batting 14 | WHERE playerid = 'aardsda01' 15 | GROUP BY teamid, playerid; 16 | 17 | USE lahmansbaseballdb; 18 | SELECT playerid, teamid 19 | FROM batting 20 | WHERE playerid = 'aardsda01'; 21 | 22 | USE lahmansbaseballdb; 23 | SELECT playerid, teamid, yearid 24 | FROM batting 25 | WHERE playerid = 'aardsda01'; 26 | 27 | USE lahmansbaseballdb; 28 | SELECT playerid, teamid 29 | FROM batting 30 | WHERE playerid = 'aardsda01' 31 | GROUP BY teamid, playerid 32 | ORDER BY playerid, teamid; 33 | 34 | USE lahmansbaseballdb; 35 | SELECT sum(AB) AS sum_at_bats 36 | FROM batting; 37 | 38 | USE lahmansbaseballdb; 39 | SELECT playerid, teamid, sum(AB) AS sum_at_bats 40 | FROM batting 41 | GROUP BY playerid, teamid; 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /chapter-13/exploring-rare-missing-duplicate-values.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT DISTINCT h as hits, COUNT(h) as count 3 | FROM batting 4 | GROUP BY hits 5 | ORDER BY count; 6 | 7 | USE lahmansbaseballdb; 8 | SELECT 9 | SUM(!ISNULL(h)) AS hits_count, 10 | SUM(ISNULL(h)) AS null_hits_count 11 | FROM batting; 12 | 13 | USE lahmansbaseballdb; 14 | SELECT 15 | SUM(!ISNULL(ibb)) AS ibb_count, 16 | SUM(ISNULL(ibb)) AS null_ibb_count 17 | FROM batting; 18 | 19 | USE lahmansbaseballdb; 20 | SELECT MIN(yearid) as minyear, 21 | MAX(yearid) as maxyear 22 | FROM batting 23 | WHERE ibb IS NULL; 24 | 25 | USE lahmansbaseballdb; 26 | SELECT name_full 27 | FROM schools 28 | GROUP BY name_full 29 | HAVING count(*) >= 2; 30 | 31 | USE lahmansbaseballdb; 32 | SELECT * FROM schools 33 | WHERE name_full = 'Bethel College'; 34 | 35 | USE lahmansbaseballdb; 36 | SELECT name_full, city 37 | FROM schools 38 | GROUP BY name_full, city 39 | HAVING count(*) >= 2; 40 | 41 | USE lahmansbaseballdb; 42 | SELECT * FROM schools 43 | WHERE name_full = '"California Polytechnic State University'; 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter-9/string-built-in-functions.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | SELECT UPPER(playerid) as playeridupper, 3 | playerid, 4 | LOWER(CONCAT(teamid, ' ', lgid)) as teamleague, 5 | teamid, 6 | lgid, 7 | LOWER(gameid) as gameidlower, 8 | gameid 9 | FROM allstarfull; 10 | 11 | SELECT CHAR_LENGTH('string'); -- returns 6 12 | SELECT LENGTH('string'); -- returns 6 13 | SELECT CONCAT('string1', 'string2'); -- returns string1string2 14 | SELECT LEFT('string', 3); -- returns str 15 | SELECT RIGHT('string', 3); -- returns ing 16 | SELECT LOWER('String'); -- returns string 17 | SELECT UPPER('String'); -- returns STRING 18 | SELECT LTRIM(' String'); -- returns String 19 | SELECT RTRIM('String '); -- returns String 20 | SELECT TRIM(' String '); -- returns String 21 | SELECT LPAD('String', 8, 'x'); -- returns String with three spaces before it 22 | SELECT RPAD('String', 8, 'x'); -- returns String with three spaces after it 23 | SELECT REPLACE('string', 'str', 'ing'); -- returns inging 24 | SELECT SUBSTRING('string', 2, 3); -- returns tri 25 | SELECT REVERSE('string'); -- returns gnirts -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /chapter-4/create-managers-table.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE yourschema.`managers` ( 2 | `managerkey` smallint(5) NOT NULL AUTO_INCREMENT, 3 | `playerid` varchar(9) NOT NULL, 4 | `yearid` year(4) NOT NULL, 5 | `teamid` char(3) NOT NULL, 6 | `games` tinyint(3) NOT NULL, 7 | `wins` tinyint(3) NOT NULL, 8 | `losses` tinyint(3) NOT NULL, 9 | `alsoplayer` char(1) NOT NULL, 10 | PRIMARY KEY (`managerkey`), 11 | UNIQUE KEY `managerkey_UNIQUE` (`managerkey`), 12 | UNIQUE KEY `playerid_yearid_teamid_UNIQUE` (`playerid`,`yearid`,`teamid`), 13 | KEY `FK_teamid_idx` (`teamid`), 14 | CONSTRAINT `FK_teamid` FOREIGN KEY (`teamid`) REFERENCES `teams` (`teamid`) ON DELETE RESTRICT ON UPDATE RESTRICT, 15 | CONSTRAINT `check_alsoplayer` CHECK ((`alsoplayer` in (_utf8mb4'Y',_utf8mb4'N'))), 16 | CONSTRAINT `check_games` CHECK (((`games` >= 0) and (`games` <= 165))), 17 | CONSTRAINT `check_losses` CHECK (((`losses` >= 0) and (`losses` <= 165))), 18 | CONSTRAINT `check_manager_year` CHECK (((`yearid` >= 1871) and (`yearid` <= 2155))), 19 | CONSTRAINT `check_wins` CHECK (((`wins` >= 0) and (`wins` <= 165)))) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT=' '; -------------------------------------------------------------------------------- /chapter-8/insert-single-row.sql: -------------------------------------------------------------------------------- 1 | #the following queries inserts one row 2 | USE lahmansbaseballdb; 3 | INSERT INTO collegeplaying 4 | (playerID, 5 | schoolID, 6 | yearID) 7 | VALUES 8 | ('blaloha01', 9 | 'sandiegost', 10 | 1999); 11 | 12 | USE lahmansbaseballdb; 13 | INSERT INTO collegeplaying 14 | (playerID, schoolID, yearID) 15 | VALUES ('blaloha01','sandiegost',1999); 16 | 17 | USE lahmansbaseballdb; 18 | INSERT INTO collegeplaying 19 | VALUES ('blaloha01','sandiegost',1999); 20 | 21 | #the following query inserts one row and only 2 columns 22 | USE lahmansbaseballdb; 23 | INSERT INTO collegeplaying 24 | (playerID, yearID) 25 | VALUES ('blaloha01', 1999); 26 | 27 | #the following query causes an error 28 | USE lahmansbaseballdb; 29 | INSERT INTO collegeplaying 30 | VALUES ('blaloha01', 1999); 31 | 32 | #the following query causes an error 33 | USE lahmansbaseballdb; 34 | INSERT INTO collegeplaying 35 | VALUES('blaloha01',1999, 'sandiegost'); 36 | 37 | #the following query causes an implicit conversion 38 | USE lahmansbaseballdb; 39 | INSERT INTO collegeplaying 40 | (playerID,schoolid) 41 | VALUES ('blaloha01', 1999); 42 | 43 | 44 | -------------------------------------------------------------------------------- /chapter-12/views-delete-data-from.sql: -------------------------------------------------------------------------------- 1 | # create copy of parks table 2 | USE lahmansbaseballdb; 3 | CREATE TABLE parks_copy AS 4 | SELECT * FROM parks 5 | 6 | CREATE VIEW parksalias AS 7 | SELECT parkalias, parkkey, parkname, 8 | city, state, country 9 | FROM parks_copy 10 | WHERE parkalias IS NOT NULL 11 | WITH CHECK OPTION; 12 | 13 | DELETE from parksalias 14 | WHERE parkkey = 'ALB01'; 15 | 16 | DELETE from parksalias 17 | WHERE parkkey = 'TST01'; 18 | 19 | #delete from view with multiple tables 20 | USE lahmansbaseballdb; 21 | DROP TABLE IF EXISTS collegeplaying_copy; 22 | CREATE TABLE collegeplaying_copy 23 | SELECT * FROM collegeplaying; 24 | 25 | USE lahmansbaseballdb; 26 | DROP VIEW IF EXISTS collegeplayingbyname; 27 | CREATE VIEW collegeplayingbyname AS 28 | SELECT namefirst, namelast, schoolid, yearid 29 | FROM collegeplaying_copy c 30 | INNER JOIN people p 31 | ON p.playerid = c.playerid; 32 | 33 | #gives error. you can't delete from view with multiple tables 34 | USE lahmansbaseballdb; 35 | DELETE FROM collegeplayingbyname 36 | WHERE (namefirst = 'David' AND namelast = 'Aardsma') 37 | AND (schoolid = 'rice' AND yearid = 2003); 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /chapter-6/order-by-clause.sql: -------------------------------------------------------------------------------- 1 | #orders results by g_all ascending 2 | USE lahmansbaseballdb; 3 | SELECT playerid, g_all, g_batting, g_defense 4 | FROM appearances 5 | ORDER BY g_all; 6 | 7 | #orders results by g_all ascending and filters on playerid starting with "a" 8 | USE lahmansbaseballdb; 9 | SELECT playerid, g_all, g_batting, g_defense 10 | FROM appearances 11 | WHERE playerid LIKE 'a%' 12 | ORDER BY g_all; 13 | 14 | #orders results by g_all descending 15 | USE lahmansbaseballdb; 16 | SELECT playerid, g_all, g_batting, g_defense 17 | FROM appearances 18 | ORDER BY g_all DESC; 19 | 20 | #orders results by playerid ascending then g_all ascending 21 | USE lahmansbaseballdb; 22 | SELECT playerid, g_all, g_batting, g_defense 23 | FROM appearances 24 | ORDER BY playerid, g_all; 25 | 26 | #orders results by playerid descending then g_all descending 27 | USE lahmansbaseballdb; 28 | SELECT playerid, g_all, g_batting, g_defense 29 | FROM appearances 30 | ORDER BY playerid DESC, g_all DESC; 31 | 32 | #orders results by playerid descending then g_all descending using column position numbers 33 | USE lahmansbaseballdb; 34 | SELECT playerid, g_all, g_batting, g_defense 35 | FROM appearances 36 | ORDER BY 1 DESC, 2 DESC; -------------------------------------------------------------------------------- /chapter-11/correlated-subqueries.sql: -------------------------------------------------------------------------------- 1 | #using exists 2 | USE lahmansbaseballdb; 3 | SELECT f.playerid, f.yearid, f.teamid, pos 4 | FROM fielding f 5 | WHERE EXISTS(SELECT 1 6 | FROM salaries s 7 | WHERE salary < 200000 8 | AND salary IS NOT NULL 9 | AND (f.playerid = s.playerid 10 | AND f.teamid = s.teamid 11 | AND f.yearid = s.yearid)) 12 | ORDER BY f.playerid; 13 | 14 | #using in 15 | USE lahmansbaseballdb; 16 | SELECT f.playerid, f.yearid, f.teamid, pos 17 | FROM fielding f 18 | WHERE playerid IN (SELECT playerid 19 | FROM salaries s 20 | WHERE salary < 200000 21 | AND salary IS NOT NULL 22 | AND (f.playerid = s.playerid 23 | AND f.teamid = s.teamid 24 | AND f.yearid = s.yearid)) 25 | ORDER BY f.playerid; 26 | 27 | #in a select 28 | USE lahmansbaseballdb; 29 | SELECT f.playerid, f.yearid, f.teamid, pos, 30 | (SELECT salary 31 | FROM salaries s 32 | WHERE (f.playerid = s.playerid 33 | AND f.teamid = s.teamid 34 | AND f.yearid = s.yearid)) AS salary 35 | FROM fielding f 36 | ORDER BY f.playerid; 37 | -------------------------------------------------------------------------------- /chapter-6/indexes-used.sql: -------------------------------------------------------------------------------- 1 | #run query to see explanation of query plan 2 | USE lahmansbaseballdb; 3 | EXPLAIN SELECT playerid, g_all, g_batting, g_defense 4 | FROM appearances; 5 | 6 | #run query to see explanation of query plan 7 | USE lahmansbaseballdb; 8 | EXPLAIN SELECT distinct playerid, g_all, g_batting, g_defense 9 | FROM appearances 10 | WHERE playerid LIKE 'a%' 11 | ORDER BY playerid; 12 | 13 | #adding index to improve query plan 14 | ALTER TABLE `lahmansbaseballdb`.`appearances` 15 | ADD INDEX `NC_playerid_g_cols` (`playerID` ASC, `G_all` ASC, `G_batting` ASC, `G_defense` ASC) VISIBLE; 16 | ; 17 | 18 | #run query to see explanation of query plan 19 | USE lahmansbaseballdb; 20 | EXPLAIN SELECT distinct playerid, g_all, g_batting, g_defense 21 | FROM appearances 22 | WHERE playerid LIKE 'a%' 23 | ORDER BY playerid; 24 | 25 | #run query to see explanation of query plan 26 | USE lahmansbaseballdb; 27 | EXPLAIN SELECT distinct playerid 28 | FROM appearances 29 | WHERE playerid LIKE 'a%' 30 | ORDER BY playerid; 31 | 32 | #run query and then see visual plan in mysql workbench 33 | USE lahmansbaseballdb; 34 | SELECT distinct playerid, g_all, g_batting, g_defense 35 | FROM appearances 36 | WHERE playerid LIKE 'a%' 37 | ORDER BY playerid; 38 | 39 | #drop index to see query plan without it 40 | ALTER TABLE `lahmansbaseballdb`.`appearances` 41 | DROP INDEX `NC_playerid_g_cols`; 42 | -------------------------------------------------------------------------------- /chapter-8/transactions.sql: -------------------------------------------------------------------------------- 1 | #start a transaction before a query 2 | USE lahmansbaseballdb; 3 | START TRANSACTION; 4 | UPDATE managerscopy 5 | SET lgid = '--'; 6 | 7 | #then either commit 8 | COMMIT; 9 | 10 | #or rollback 11 | ROLLBACK; 12 | 13 | #run multiple queries in the transaction 14 | USE lahmansbaseballdb; 15 | CREATE TABLE awards LIKE awardsmanagers; 16 | START TRANSACTION; 17 | INSERT INTO awards 18 | SELECT * FROM awardsmanagers 19 | WHERE awardid = 'BBWAA Manager of the Year'; 20 | DELETE FROM awardsmanagers 21 | WHERE awardid = 'BBWAA Manager of the Year'; 22 | COMMIT; 23 | 24 | #run DDL in middle of transaction and it causes auto commit of all queries before it 25 | USE lahmansbaseballdb; 26 | START TRANSACTION; 27 | INSERT INTO awards 28 | SELECT * FROM awardsmanagers 29 | WHERE awardid = 'BBWAA Manager of the Year'; 30 | DROP TABLE lahmansbaseballdb.managerscopy; 31 | DELETE FROM awardsmanagers 32 | WHERE awardid = 'BBWAA Manager of the Year'; 33 | COMMIT; 34 | 35 | #set autocommit off and on without using transactions 36 | SET autocommit = OFF; 37 | SET autocommit = ON; 38 | 39 | #using savepoints 40 | USE lahmansbaseballdb; 41 | START TRANSACTION; 42 | SAVEPOINT firstsavepoint; 43 | INSERT INTO awards 44 | SELECT * FROM awardsmanagers 45 | WHERE awardid = 'BBWAA Manager of the Year'; 46 | SAVEPOINT secondsavepoint; 47 | DELETE FROM awardsmanagers 48 | WHERE awardid = 'BBWAA Manager of the Year'; 49 | ROLLBACK TO firstsavepoint; -------------------------------------------------------------------------------- /chapter-9/advanced-built-in-functions.sql: -------------------------------------------------------------------------------- 1 | SELECT CURRENT_USER(); -- returns 'root@%' 2 | SELECT DATABASE(); -- returns lahmansbaseballdb (depending on which database you are using) 3 | SELECT VERSION(); -- returns '8.0.18' (depending on your MySQL version) 4 | 5 | SELECT CAST('2019-06-10 11:12:13' AS DATE); -- returns '2019-06-10' 6 | SELECT CAST('2019-06-10 11:12:13' AS UNSIGNED); -- returns 2019 7 | 8 | SELECT CONVERT('2019-06-10 11:12:13', DATE); -- returns '2019-06-10' 9 | SELECT CONVERT('100.2', decimal(5,2)); -- returns 100.20 10 | SELECT CONVERT('2019-06-10 11:12:13', unsigned); -- returns 2019 11 | SELECT CONVERT('testing' USING latin1); -- returns a BLOB 12 | 13 | SELECT IF(10<20, 1, 2); -- returns 1 14 | SELECT IF(10<20, 'true', 'false'); -- returns true 15 | 16 | -- case example 17 | USE lahmansbaseballdb; 18 | SELECT playerid, yearid, 19 | CASE 20 | WHEN g_all between 0 and 10 then 'barely any' 21 | WHEN g_all between 11 and 50 then 'some' 22 | WHEN g_all between 51 and 100 then 'many' 23 | ELSE 'tons' 24 | END 25 | from appearances; 26 | 27 | SELECT LAST_INSERT_ID(); -- if the table has auto-increment enabled, it will return the last ID that was used on insert 28 | 29 | SELECT NULLIF(1, 1); -- returns NULL 30 | SELECT NULLIF(1, 2); -- returns 1 31 | 32 | SELECT IFNULL(NULL, 'testing'); -- returns 'testing' 33 | SELECT IFNULL(NULL, NULL); -- returns NULL 34 | 35 | SELECT ISNULL(NULL); -- returns 1 36 | SELECT ISNULL('testing'); -- returns 0 -------------------------------------------------------------------------------- /chapter-12/stored-proc-error-handling.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | DELIMITER $$ 3 | CREATE PROCEDURE insertallstarfull( 4 | IN inplayerid varchar(9), 5 | IN inyearid smallint, 6 | IN ingamenum smallint 7 | ) 8 | BEGIN 9 | DECLARE EXIT HANDLER FOR 1062 10 | BEGIN 11 | SELECT CONCAT('Duplicate key (',inplayerid,',',inyearid,',',ingamenum,') occurred') AS message; 12 | END; 13 | 14 | INSERT INTO allstarfull (playerid, yearid, gamenum) 15 | VALUES (inplayerid, inyearid, ingamenum); 16 | 17 | SELECT count(*) 18 | FROM allstarfull 19 | WHERE playerid = inplayerid; 20 | END$$ 21 | DELIMITER ; 22 | 23 | # following call produces error 24 | CALL insertallstarfull('aaronha01', 1958, 0); 25 | 26 | # following call doesn't 27 | CALL insertallstarfull('aaronha01', 1954, 0); 28 | 29 | 30 | /* error handling for postgresql */ 31 | DO $$ 32 | BEGIN 33 | INSERT INTO allstarfull (playerid, yearid, gamenum) 34 | VALUES ('aaronha01', 1958, 0); 35 | exception when others then 36 | RAISE notice '% %', SQLERRM, SQLSTATE; 37 | END $$; 38 | 39 | 40 | 41 | /* error handling for sql server */ 42 | DECLARE @inplayerid varchar(9) = 'aaronha01'; 43 | DECLARE @inyearid smallint = 1958; 44 | DECLARE @ingamenum smallint = 0; 45 | 46 | BEGIN TRY 47 | INSERT INTO allstarfull (playerid, yearid, gamenum) 48 | VALUES (@inplayerid, @inyearid, @ingamenum); 49 | 50 | SELECT count(*) 51 | FROM allstarfull 52 | WHERE playerid = @inplayerid; 53 | END TRY 54 | BEGIN CATCH 55 | SELECT 56 | ERROR_NUMBER() AS ErrorNumber 57 | ,ERROR_MESSAGE() AS ErrorMessage; 58 | END CATCH; 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /chapter-12/temporary-tables.sql: -------------------------------------------------------------------------------- 1 | # create empty temporary table 2 | USE lahmansbaseballdb; 3 | CREATE TEMPORARY TABLE tempplayerinfo /*with postgres and oracle use AS after table name and with oracle use GLOBAL before TEMPORARY */ 4 | SELECT p.playerid, birthyear, 5 | a.yearid, a.teamid, 6 | G_defense AS defensegames, 7 | H AS numberofhits 8 | FROM appearances AS a /* remove AS for oracle */ 9 | JOIN people AS p /* remove AS for oracle */ 10 | ON p.playerid = a.playerid 11 | JOIN batting AS b /* remove AS for oracle */ 12 | ON a.playerid = b.playerid 13 | AND a.yearid = b.yearid 14 | AND a.teamid = b.teamid 15 | WHERE b.yearid = 2017 16 | AND H <> 0 17 | LIMIT 0; /* remove for oracle */ 18 | 19 | 20 | /* to create a temp table in sql server */ 21 | SELECT TOP 0 p.playerid, birthyear, 22 | a.yearid, a.teamid, 23 | G_defense AS defensegames, 24 | H AS numberofhits 25 | INTO #tempplayerinfo 26 | FROM appearances AS a 27 | JOIN people AS p 28 | ON p.playerid = a.playerid 29 | JOIN batting AS b 30 | ON a.playerid = b.playerid 31 | AND a.yearid = b.yearid 32 | AND a.teamid = b.teamid 33 | WHERE b.yearid = 2017 34 | AND H <> 0 35 | ORDER BY p.playerid, a.yearid, 36 | a.teamid, G_defense, H; 37 | 38 | 39 | 40 | # describe temp table columns 41 | DESCRIBE tempplayerinfo; 42 | 43 | # select from temp table 44 | SELECT * FROM tempplayerinfo; 45 | 46 | /* query temp table in sql server */ 47 | SELECT * FROM #tempplayerinfo; 48 | 49 | # delete temp table 50 | DROP TEMPORARY TABLE tempplayerinfo; 51 | 52 | /* drop temp table in sql server */ 53 | DROP TABLE #tempplayerinfo; 54 | 55 | /* drop temp table in postgresql and oracle */ 56 | DROP TABLE tempplayerinfo; 57 | -------------------------------------------------------------------------------- /chapter-7/inner-join.sql: -------------------------------------------------------------------------------- 1 | #inner join 2 | SELECT lahmansbaseballdb.people.playerid, birthyear, yearid, teamid 3 | FROM lahmansbaseballdb.appearances 4 | INNER JOIN lahmansbaseballdb.people 5 | ON lahmansbaseballdb.people.playerid = lahmansbaseballdb.appearances.playerid 6 | WHERE yearid = 2017; 7 | 8 | #inner join not using inner keyword 9 | SELECT lahmansbaseballdb.people.playerid, birthyear, yearid, teamid 10 | FROM lahmansbaseballdb.appearances 11 | JOIN lahmansbaseballdb.people 12 | ON lahmansbaseballdb.people.playerid = lahmansbaseballdb.appearances.playerid 13 | WHERE yearid = 2017; 14 | 15 | #inner join three tables 16 | SELECT lahmansbaseballdb.people.playerid, birthyear, lahmansbaseballdb.appearances.yearid, 17 | lahmansbaseballdb.appearances.teamid, G_defense, H 18 | FROM lahmansbaseballdb.appearances 19 | INNER JOIN lahmansbaseballdb.people 20 | ON lahmansbaseballdb.people.playerid = lahmansbaseballdb.appearances.playerid 21 | INNER JOIN lahmansbaseballdb.batting 22 | ON lahmansbaseballdb.people.playerid = lahmansbaseballdb.batting.playerid 23 | WHERE lahmansbaseballdb.batting.yearid = 2017 24 | AND H <> 0 25 | ORDER BY lahmansbaseballdb.people.playerid, lahmansbaseballdb.appearances.yearid, 26 | lahmansbaseballdb.appearances.teamid, G_defense, H; 27 | 28 | #table alias 29 | SELECT p.playerid, birthyear, 30 | a.yearid, a.teamid, G_defense, H 31 | FROM lahmansbaseballdb.appearances AS a 32 | INNER JOIN lahmansbaseballdb.people AS p 33 | ON p.playerid = a.playerid 34 | INNER JOIN lahmansbaseballdb.batting AS b 35 | ON p.playerid = b.playerid 36 | WHERE b.yearid = 2017 37 | AND H <> 0 38 | ORDER BY p.playerid, a.yearid, a.teamid, G_defense, H; 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /baseball-database/lahmansbaseballdb-backup/lahmansbaseballdb_routines.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `lahmansbaseballdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; 2 | USE `lahmansbaseballdb`; 3 | -- MySQL dump 10.13 Distrib 8.0.17, for Win64 (x86_64) 4 | -- 5 | -- Host: localhost Database: lahmansbaseballdb 6 | -- ------------------------------------------------------ 7 | -- Server version 8.0.17 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!50503 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Dumping events for database 'lahmansbaseballdb' 22 | -- 23 | 24 | -- 25 | -- Dumping routines for database 'lahmansbaseballdb' 26 | -- 27 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 28 | 29 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 30 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 31 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 32 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 33 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 34 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 35 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 36 | 37 | -- Dump completed on 2019-09-20 18:02:03 38 | -------------------------------------------------------------------------------- /chapter-9/datetime-built-in-functions.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | DAYNAME('2019-06-10 11:12:13') as dayofweek, 3 | MONTH('2019-06-10 11:12:13') as month, 4 | DAY('2019-06-10 11:12:13') as day, 5 | YEAR('2019-06-10 11:12:13') as year, 6 | HOUR('2019-06-10 11:12:13') as hour, 7 | MINUTE('2019-06-10 11:12:13') as minute, 8 | SECOND('2019-06-10 11:12:13') as second 9 | 10 | 11 | SELECT CURRENT_DATE(); 12 | SELECT CURRENT_TIME(); 13 | SELECT CURRENT_TIMESTAMP; 14 | SELECT NOW(); 15 | SELECT DATE_FORMAT(NOW(), '%m-%d-%y'); 16 | SELECT TIME_FORMAT(NOW(), '%T'); 17 | SELECT ADDDATE('2020-01-01', INTERVAL 5 DAY); -- returns 2020-01-06 18 | SELECT ADDTIME('2020-01-01 10:10:10', '8:10:5'); -- returns 2020-01-01 18:20:15 19 | SELECT DATE_SUB('2020-01-01', INTERVAL 5 DAY); -- returns 2019-12-27 20 | SELECT DATEDIFF('2020-01-01', '2020-01-03'); -- returns -2 21 | SELECT DATE('2019-06-10 12:12:12'); -- returns 2019-06-10 22 | SELECT DAY('2019-06-10 12:12:12'); -- returns 10 23 | SELECT DAYNAME('2019-06-10 12:12:12'); -- returns Monday 24 | SELECT DAYOFMONTH('2019-06-10 12:12:12'); -- returns 10 25 | SELECT DAYOFWEEK('2019-06-10 12:12:12'); -- returns 2 26 | SELECT DAYOFYEAR('2019-06-10 12:12:12'); -- returns 161 27 | SELECT HOUR('2019-06-10 12:12:12'); -- returns 12 28 | SELECT LAST_DAY('2019-06-10 12:12:12'); -- returns 2019-06-30 29 | SELECT MINUTE('2019-06-10 12:12:12'); -- returns 12 30 | SELECT MONTH('2019-06-10 12:12:12'); -- returns 6 31 | SELECT MONTHNAME('2019-06-10 12:12:12'); -- returns June 32 | SELECT SECOND('2019-06-10 12:12:12'); -- returns 12 33 | SELECT WEEK('2019-06-10 12:12:12'); -- returns 23 34 | SELECT WEEKDAY('2019-06-10 12:12:12'); -- returns 0 35 | SELECT WEEKOFYEAR('2019-06-10 12:12:12'); -- returns 24 36 | SELECT YEAR('2019-06-10 12:12:12'); -- returns 2019 37 | SELECT YEARWEEK('2019-06-10 12:12:12'); -- returns 201923 -------------------------------------------------------------------------------- /chapter-6/select-clause.sql: -------------------------------------------------------------------------------- 1 | #select all columns from table 2 | SELECT * FROM lahmansbaseballdb.appearances; 3 | 4 | #select single column from table 5 | SELECT playerid FROM lahmansbaseballdb.appearances; 6 | 7 | #select multiple columns from table 8 | SELECT playerid, g_all, g_batting, g_defense FROM lahmansbaseballdb.appearances; 9 | 10 | #select one column that is distinct 11 | USE lahmansbaseballdb; 12 | SELECT distinct playerid FROM appearances; 13 | 14 | #select multiple columns that are distinct 15 | USE lahmansbaseballdb; 16 | SELECT DISTINCT teamid, playerid from appearances; 17 | 18 | #column alias 19 | SELECT playerid, 20 | G_defense AS GamesPlayingDefense 21 | FROM lahmansbaseballdb.appearances; 22 | 23 | #column alias with space 24 | SELECT playerid, 25 | G_defense AS 'Games Playing Defense' 26 | FROM lahmansbaseballdb.appearances; 27 | 28 | 29 | #limit and offset 30 | USE lahmansbaseballdb; 31 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 32 | LIMIT 500; 33 | 34 | /* in oracle */ 35 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 36 | OFFSET 0 ROWS FETCH NEXT 500 ROWS ONLY; 37 | 38 | /* in sql server */ 39 | SELECT TOP 500 playerid, g_all, g_batting, g_defense 40 | FROM appearances; 41 | 42 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 43 | ORDER BY playerid 44 | OFFSET 0 ROWS 45 | FETCH NEXT 500 ROWS ONLY; 46 | 47 | 48 | USE lahmansbaseballdb; 49 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 50 | LIMIT 500 OFFSET 1000; 51 | 52 | 53 | /* in oracle */ 54 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 55 | OFFSET 1000 ROWS FETCH NEXT 500 ROWS ONLY; 56 | 57 | 58 | /* in sql server */ 59 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 60 | ORDER BY playerid 61 | OFFSET 500 ROWS 62 | FETCH NEXT 1000 ROWS ONLY; -------------------------------------------------------------------------------- /chapter-12/views-insert-data-into.sql: -------------------------------------------------------------------------------- 1 | # create copy of parks table 2 | USE lahmansbaseballdb; 3 | CREATE TABLE parks_copy AS 4 | SELECT * FROM parks 5 | 6 | CREATE VIEW parksalias AS 7 | SELECT parkalias, parkkey, parkname, 8 | city, state, country 9 | FROM parks_copy 10 | WHERE parkalias IS NOT NULL; 11 | 12 | 13 | INSERT INTO parksalias 14 | VALUES (NULL, 15 | 'TST01', 16 | 'testing park name', 17 | 'Seattle', 18 | 'WA', 19 | 'US'); 20 | 21 | 22 | ALTER TABLE parks_copy 23 | CHANGE COLUMN ID ID SMALLINT NOT NULL AUTO_INCREMENT, 24 | ADD PRIMARY KEY (ID); 25 | 26 | #inserting into a view with multiple tables 27 | USE lahmansbaseballdb; 28 | DROP TABLE IF EXISTS collegeplaying_copy; 29 | CREATE TABLE collegeplaying_copy 30 | SELECT * FROM collegeplaying; 31 | 32 | USE lahmansbaseballdb; 33 | DROP VIEW IF EXISTS collegeplayingbyname; 34 | CREATE VIEW collegeplayingbyname AS 35 | SELECT namefirst, namelast, schoolid, yearid 36 | FROM collegeplaying_copy c 37 | INNER JOIN people p 38 | ON p.playerid = c.playerid; 39 | 40 | USE lahmansbaseballdb; 41 | SELECT * FROM collegeplayingbyname; 42 | 43 | #gives error 44 | USE lahmansbaseballdb; 45 | INSERT INTO collegeplayingbyname (namefirst, namelast, schoolid, yearid) 46 | VALUES ('David', 'Aardsma', 'rice', 2004); 47 | 48 | 49 | USE lahmansbaseballdb; 50 | DROP VIEW IF EXISTS collegeplayingbyname; 51 | CREATE VIEW collegeplayingbyname AS 52 | SELECT c.playerid, namefirst, namelast, schoolid, yearid 53 | FROM collegeplaying_copy c 54 | INNER JOIN people_copy p 55 | ON p.playerid = c.playerid; 56 | 57 | USE lahmansbaseballdb; 58 | SELECT * FROM collegeplayingbyname; 59 | 60 | INSERT INTO collegeplayingbyname (playerid, schoolid, yearid) 61 | VALUES ('aardsda01', 'rice', 2004); 62 | 63 | USE lahmansbaseballdb; 64 | SELECT * FROM collegeplayingbyname 65 | WHERE playerid = 'aardsda01'; 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /chapter-12/stored-proc-create-and-alter.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | DELIMITER $$ 3 | CREATE PROCEDURE getplayergameinfo() 4 | BEGIN 5 | SELECT p.playerid, birthyear, a.yearid, 6 | a.teamid, G_defense AS defensegames, 7 | H AS numberofhits 8 | FROM appearances AS a 9 | JOIN people AS p ON p.playerid = a.playerid 10 | JOIN batting AS b ON a.playerid = b.playerid 11 | AND a.yearid = b.yearid 12 | AND a.teamid = b.teamid 13 | WHERE b.yearid = 2017 AND H <> 0 14 | ORDER BY p.playerid, a.yearid, a.teamid, 15 | G_defense, H; 16 | END $$ 17 | DELIMITER ; 18 | 19 | CALL getplayergameinfo(); 20 | 21 | 22 | /* create stored procedure in sql server */ 23 | CREATE PROCEDURE getplayergameinfo 24 | AS 25 | SELECT p.playerid, birthyear, a.yearid, 26 | a.teamid, G_defense AS defensegames, 27 | H AS numberofhits 28 | FROM appearances AS a 29 | JOIN people AS p ON p.playerid = a.playerid 30 | JOIN batting AS b ON a.playerid = b.playerid 31 | AND a.yearid = b.yearid 32 | AND a.teamid = b.teamid 33 | WHERE b.yearid = 2017 AND H <> 0 34 | ORDER BY p.playerid, a.yearid, a.teamid, 35 | G_defense, H; 36 | 37 | 38 | /*call stored proc in sql server */ 39 | EXEC getplayergameinfo; 40 | 41 | /* create stored procedure in oracle */ 42 | CREATE OR REPLACE PROCEDURE getplayergameinfo(data OUT varchar2) 43 | IS 44 | BEGIN 45 | SELECT p.playerid 46 | INTO data 47 | FROM appearances a 48 | JOIN people p ON p.playerid = a.playerid 49 | JOIN batting b ON a.playerid = b.playerid 50 | AND a.yearid = b.yearid 51 | AND a.teamid = b.teamid 52 | WHERE b.yearid = 2017 AND H <> 0 53 | FETCH FIRST 1 ROWS ONLY; 54 | END; 55 | 56 | /*call a stored proc in oracle */ 57 | 58 | DECLARE 59 | results VARCHAR2(4000); 60 | BEGIN 61 | getplayergameinfo(results); 62 | DBMS_OUTPUT.PUT_LINE(results); 63 | END; 64 | 65 | 66 | DROP PROCEDURE getplayergameinfo; -------------------------------------------------------------------------------- /chapter-6/where-clause.sql: -------------------------------------------------------------------------------- 1 | #where clause 2 | USE lahmansbaseballdb; 3 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 4 | WHERE g_all > 40; 5 | 6 | #where clause with AND 7 | USE lahmansbaseballdb; 8 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 9 | WHERE g_all > 40 10 | AND g_all <> g_batting; 11 | 12 | #where clause with OR 13 | USE lahmansbaseballdb; 14 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 15 | WHERE g_all > 40 16 | OR g_defense > 30; 17 | 18 | #where clause with AND and OR 19 | USE lahmansbaseballdb; 20 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 21 | WHERE (g_all > 40 AND g_defense < 30) 22 | OR g_all > 60; 23 | 24 | #in example 25 | USE lahmansbaseballdb; 26 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 27 | WHERE g_all IN (40, 50, 60); 28 | 29 | #between example 30 | USE lahmansbaseballdb; 31 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 32 | WHERE g_all BETWEEN 40 and 60; 33 | 34 | #not between example 35 | USE lahmansbaseballdb; 36 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 37 | WHERE g_all NOT BETWEEN 40 and 60; 38 | 39 | #not in example 40 | USE lahmansbaseballdb; 41 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 42 | WHERE g_all NOT IN (40, 50, 60); 43 | 44 | #not in and not between example 45 | USE lahmansbaseballdb; 46 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 47 | WHERE g_all NOT IN (40, 50, 60) 48 | AND g_batting NOT BETWEEN 30 and 40; 49 | 50 | #not in or not between example 51 | USE lahmansbaseballdb; 52 | SELECT playerid, g_all, g_batting, g_defense FROM appearances 53 | WHERE g_all NOT IN (40, 50, 60) 54 | OR g_batting NOT BETWEEN 30 and 40; 55 | 56 | #returns null values for g_defense 57 | USE lahmansbaseballdb; 58 | SELECT playerid, g_all, g_batting, g_defense 59 | FROM appearances 60 | WHERE g_defense IS NULL; 61 | 62 | #returns not null values for g_defense 63 | USE lahmansbaseballdb; 64 | SELECT playerid, g_all, g_batting, g_defense 65 | FROM appearances 66 | WHERE g_defense IS NOT NULL; 67 | -------------------------------------------------------------------------------- /chapter-12/views-update-data-in.sql: -------------------------------------------------------------------------------- 1 | # create copy of parks table 2 | USE lahmansbaseballdb; 3 | CREATE TABLE parks_copy AS 4 | SELECT * FROM parks 5 | 6 | CREATE VIEW parksalias AS 7 | SELECT parkalias, parkkey, parkname, 8 | city, state, country 9 | FROM parks_copy 10 | WHERE parkalias IS NOT NULL 11 | WITH CHECK OPTION; 12 | 13 | SELECT * FROM parksalias; 14 | 15 | UPDATE parksalias 16 | SET parkalias = NULL 17 | WHERE parkkey = 'ANA01'; 18 | 19 | #update view with multiple tables 20 | USE lahmansbaseballdb; 21 | DROP TABLE IF EXISTS collegeplaying_copy; 22 | CREATE TABLE collegeplaying_copy 23 | SELECT * FROM collegeplaying; 24 | 25 | USE lahmansbaseballdb; 26 | DROP VIEW IF EXISTS collegeplayingbyname; 27 | CREATE VIEW collegeplayingbyname AS 28 | SELECT namefirst, namelast, schoolid, yearid 29 | FROM collegeplaying_copy c 30 | INNER JOIN people p 31 | ON p.playerid = c.playerid; 32 | 33 | USE lahmansbaseballdb; 34 | SELECT * FROM collegeplayingbyname; 35 | 36 | USE lahmansbaseballdb; 37 | UPDATE collegeplayingbyname 38 | SET schoolid = 'testing', yearid = 2004 39 | WHERE (namefirst = 'David' and namelast = 'Aardsma') 40 | and (schoolid = 'rice' and yearid = 2003); 41 | 42 | USE lahmansbaseballdb; 43 | SELECT * FROM collegeplayingbyname; 44 | 45 | USE lahmansbaseballdb; 46 | DROP TABLE IF EXISTS people_copy; 47 | CREATE TABLE people_copy 48 | SELECT * FROM people; 49 | 50 | USE lahmansbaseballdb; 51 | DROP VIEW IF EXISTS collegeplayingbyname; 52 | CREATE VIEW collegeplayingbyname AS 53 | SELECT namefirst, namelast, schoolid, yearid 54 | FROM collegeplaying_copy c 55 | INNER JOIN people_copy p 56 | ON p.playerid = c.playerid; 57 | 58 | USE lahmansbaseballdb; 59 | UPDATE collegeplayingbyname 60 | SET schoolid = 'testing', yearid = 2004 61 | WHERE (namefirst = 'David' and namelast = 'Aardsma') 62 | and (schoolid = 'rice' and yearid = 2003); 63 | 64 | USE lahmansbaseballdb; 65 | UPDATE collegeplayingbyname 66 | SET namefirst = 'Peter' 67 | WHERE (namefirst = 'David' and namelast = 'Aardsma') 68 | and (schoolid = 'rice' and yearid = 2003); 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /chapter-12/functions.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | DELIMITER $$ 3 | CREATE FUNCTION hittinglevel( 4 | g_all smallint 5 | ) 6 | RETURNS VARCHAR(10) 7 | DETERMINISTIC 8 | BEGIN 9 | DECLARE hitlevel VARCHAR(10); 10 | IF g_all BETWEEN 0 and 10 THEN 11 | SET hitlevel = 'barely any'; 12 | ELSEIF g_all BETWEEN 11 and 50 THEN 13 | SET hitlevel = 'some'; 14 | ELSEIF g_all BETWEEN 51 and 100 THEN 15 | SET hitlevel = 'many'; 16 | ELSEIF g_all > 100 THEN 17 | SET hitlevel = 'tons'; 18 | END IF; 19 | RETURN (hitlevel); 20 | END$$ 21 | DELIMITER ; 22 | 23 | /* create function in sql server */ 24 | CREATE FUNCTION hittinglevel(@g_all SMALLINT) 25 | RETURNS VARCHAR(10) 26 | AS 27 | BEGIN 28 | DECLARE @hitlevel varchar(10); 29 | IF @g_all BETWEEN 0 and 10 30 | SET @hitlevel = 'barely any' 31 | IF @g_all BETWEEN 11 and 50 32 | SET @hitlevel = 'some' 33 | IF @g_all BETWEEN 51 and 100 34 | SET @hitlevel = 'many' 35 | IF @g_all > 100 36 | SET @hitlevel = 'tons' 37 | RETURN @hitlevel; 38 | END; 39 | 40 | /* create function in postgres */ 41 | CREATE FUNCTION hittinglevel(g_all SMALLINT) 42 | RETURNS VARCHAR(10) 43 | AS $hitlevel$ 44 | DECLARE hitlevel varchar(10); 45 | BEGIN 46 | IF g_all BETWEEN 0 and 10 THEN 47 | SET hitlevel = 'barely any'; 48 | ELSEIF g_all BETWEEN 11 and 50 THEN 49 | SET hitlevel = 'some'; 50 | ELSEIF g_all BETWEEN 51 and 100 THEN 51 | SET hitlevel = 'many'; 52 | ELSEIF g_all > 100 THEN 53 | SET hitlevel = 'tons'; 54 | END IF; 55 | RETURN hitlevel; 56 | END; 57 | $hitlevel$ 58 | LANGUAGE plpgsql; 59 | 60 | /* create function in oracle */ 61 | CREATE OR REPLACE FUNCTION hittinglevel(g_all IN NUMBER) 62 | RETURN VARCHAR AS 63 | hitlevel VARCHAR(10); 64 | BEGIN 65 | hitlevel := CASE 66 | WHEN g_all BETWEEN 0 and 10 THEN 'barely any' 67 | WHEN g_all BETWEEN 11 and 50 THEN 'some' 68 | WHEN g_all BETWEEN 51 and 100 THEN 'many' 69 | ELSE 'tons' 70 | END; 71 | RETURN hitlevel; 72 | END; 73 | 74 | 75 | SELECT playerid, yearid, teamid, 76 | hittinglevel(ab) AS hits 77 | FROM batting 78 | WHERE yearid = 2017; 79 | 80 | DROP FUNCTION hittinglevel; 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /chapter-7/set-operators.sql: -------------------------------------------------------------------------------- 1 | #union 2 | SELECT am.playerid, namegiven, awardid, yearid FROM lahmansbaseballdb.awardsmanagers am 3 | INNER JOIN lahmansbaseballdb.people p 4 | ON p.playerid = am.playerid 5 | WHERE yearid = 1994 6 | UNION 7 | SELECT ap.playerid, namegiven, awardid, yearid FROM lahmansbaseballdb.awardsplayers ap 8 | INNER JOIN lahmansbaseballdb.people p 9 | ON p.playerid = ap.playerid 10 | WHERE yearid = 1994 11 | ORDER BY awardid; 12 | 13 | #union with static column 14 | SELECT am.playerid, namegiven, awardid, yearid, "Manager" as playeridType 15 | FROM lahmansbaseballdb.awardsmanagers am 16 | INNER JOIN lahmansbaseballdb.people p 17 | ON p.playerid = am.playerid 18 | WHERE yearid = 1994 19 | UNION 20 | SELECT ap.playerid, namegiven, awardid, yearid, "Player" 21 | FROM lahmansbaseballdb.awardsplayers ap 22 | INNER JOIN lahmansbaseballdb.people p 23 | ON p.playerid = ap.playerid 24 | WHERE yearid = 1994 25 | ORDER BY awardid; 26 | 27 | #union all 28 | SELECT playerid, yearid, teamid, G AS gamesbatted FROM lahmansbaseballdb.batting 29 | WHERE yearid = 2005 30 | UNION ALL 31 | SELECT playerid, yearid, teamid, g_batting FROM lahmansbaseballdb.appearances 32 | WHERE yearid = 2005 33 | ORDER BY yearid, playerid, gamesbatted; 34 | 35 | #intersect in mysql 36 | SELECT DISTINCT a.playerid 37 | FROM lahmansbaseballdb.batting b 38 | INNER JOIN lahmansbaseballdb.appearances a 39 | ON a.playerid = b.playerid 40 | ORDER BY a.playerid; 41 | 42 | #intersect in oracle, postgresql, and sql server 43 | USE lahmansbaseballdb 44 | SELECT playerid 45 | FROM batting 46 | INTERSECT 47 | SELECT playerid 48 | FROM appearances 49 | ORDER BY playerid; 50 | 51 | #except/minus in mysql 52 | SELECT p.playerid 53 | FROM lahmansbaseballdb.allstarfull asf 54 | RIGHT OUTER JOIN lahmansbaseballdb.people p 55 | ON p.playerid = asf.playerid 56 | WHERE asf.playerid IS NULL; 57 | 58 | #except in postgresql and sql server 59 | USE lahmansbaseballdb 60 | SELECT playerid 61 | FROM people 62 | EXCEPT 63 | SELECT playerid 64 | FROM allstarfull; 65 | 66 | #minus in oracle 67 | USE lahmansbaseballdb 68 | SELECT playerid 69 | FROM people 70 | MINUS 71 | SELECT playerid 72 | FROM allstarfull; 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /chapter-12/stored-proc-flow-control.sql: -------------------------------------------------------------------------------- 1 | # if statement 2 | USE lahmansbaseballdb; 3 | SELECT playerid, yearid, 4 | IF(g_all between 0 and 10, 'barely any', 'some more') as gamecount 5 | FROM appearances 6 | WHERE yearid = 1990; 7 | 8 | 9 | # case statement 10 | SELECT playerid, yearid, 11 | CASE 12 | WHEN g_all between 0 and 10 then 'barely any' 13 | WHEN g_all between 11 and 50 then 'some' 14 | WHEN g_all between 51 and 100 then 'many' 15 | ELSE 'tons' 16 | END 17 | FROM appearances 18 | WHERE yearid = 1990; 19 | 20 | # loop statement 21 | DELIMITER $$ 22 | CREATE PROCEDURE forloopexample() 23 | BEGIN 24 | DECLARE n INT; 25 | DECLARE loopreturn VARCHAR(25); 26 | SET n = 1; 27 | SET loopreturn = ''; 28 | 29 | looplabel: LOOP 30 | IF n > 14 THEN 31 | LEAVE looplabel; 32 | END IF; 33 | 34 | SET n = n + 1; 35 | IF (n mod 2) THEN 36 | ITERATE looplabel; 37 | ELSE 38 | SET loopreturn = CONCAT(loopreturn,n,','); 39 | END IF; 40 | END LOOP; 41 | SELECT loopreturn; 42 | END$$ 43 | DELIMITER ; 44 | 45 | 46 | CALL forloopexample(); 47 | 48 | 49 | # repeat statement 50 | USE lahmansbaseballdb; 51 | DELIMITER $$ 52 | CREATE PROCEDURE repeatexample() 53 | BEGIN 54 | DECLARE count INT DEFAULT 1; 55 | DECLARE result VARCHAR(30) DEFAULT ''; 56 | REPEAT 57 | SET result = CONCAT(result,count,','); 58 | SET count = count + 1; 59 | UNTIL count > 10 60 | END REPEAT; 61 | SELECT result; 62 | END$$ 63 | DELIMITER ; 64 | 65 | CALL repeatexample(); 66 | 67 | 68 | # while statement 69 | USE lahmansbaseballdb; 70 | DELIMITER $$ 71 | CREATE PROCEDURE whileexample() 72 | BEGIN 73 | DECLARE count INT; 74 | DECLARE whileresult Varchar(50); 75 | SET count = 1; 76 | SET whileresult = ''; 77 | WHILE count <=10 DO 78 | SET whileresult = CONCAT(whileresult, count, ','); 79 | SET count = count + 1; 80 | END WHILE; 81 | SELECT whileresult; 82 | END $$ 83 | DELIMITER ; 84 | 85 | CALL whileexample(); 86 | 87 | /*sql server while */ 88 | DECLARE @counter INT = 1; 89 | 90 | WHILE @counter <= 10 91 | BEGIN 92 | PRINT @counter; 93 | SET @counter = @counter + 1; 94 | end 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /chapter-14/queries-to-gather-data.sql: -------------------------------------------------------------------------------- 1 | #finding statistical identity of your data 2 | USE lahmansbaseballdb; 3 | SELECT f.pos, FORMAT(AVG(salary),0) as averagesalary 4 | FROM salaries s 5 | INNER JOIN fielding f 6 | ON f.playerid = s.playerid 7 | AND f.yearid = s.yearid 8 | GROUP BY pos 9 | ORDER BY averagesalary; 10 | 11 | #average salaries 12 | USE lahmansbaseballdb; 13 | SELECT f.pos as position, FORMAT(AVG(salary),0) as averagesalary 14 | FROM salaries s 15 | INNER JOIN fielding f 16 | ON f.playerid = s.playerid 17 | AND f.yearid = s.yearid 18 | GROUP BY position 19 | ORDER BY averagesalary; 20 | 21 | #batting averages 22 | USE lahmansbaseballdb; 23 | SELECT f.pos as position, avg(h/ab) as battingaverage 24 | FROM fielding f 25 | INNER JOIN batting b 26 | ON f.playerid = b.playerid 27 | AND f.yearid = b.yearid 28 | GROUP BY position 29 | ORDER BY battingaverage; 30 | 31 | #fielding skills 32 | USE lahmansbaseballdb; 33 | SELECT f.pos as position, avg(innouts) as inningouts, 34 | FROM fielding f 35 | WHERE f.pos IN ('2B', 'SS') 36 | GROUP BY position; 37 | 38 | #pitcher earned runs 39 | USE lahmansbaseballdb; 40 | SELECT format(avg(salary),0) as avgsalary, 41 | CASE WHEN round((er/(ipouts/3))*9, 2) < 4.6 42 | then 'ERA less than average runs scored per game' 43 | ELSE 'ERA more than average runs scored per game' 44 | END as eracalc 45 | FROM pitching p 46 | INNER JOIN salaries s 47 | ON p.playerid = s.playerid 48 | GROUP BY eracalc 49 | ORDER BY avgsalary; 50 | 51 | #average number of runs per game 52 | USE lahmansbaseballdb; 53 | SELECT avg(r/g) as avgrunspergame FROM teams; 54 | 55 | #managers average salary 56 | USE lahmansbaseballdb; 57 | SELECT CASE WHEN w/g > .5 then 'winning record' 58 | else 'losing record' 59 | END as winratio, 60 | FORMAT(AVG(salary), 0) as avgsalary 61 | FROM managers m 62 | INNER JOIN salaries s 63 | ON s.playerid = m.playerid 64 | GROUP BY winratio; 65 | 66 | #manager salary vs position player salaries 67 | USE lahmansbaseballdb; 68 | SELECT 'manager' as position, FORMAT(AVG(salary), 0) as averagesalary 69 | FROM managers m 70 | INNER JOIN salaries s 71 | ON s.playerid = m.playerid 72 | UNION 73 | SELECT f.pos as position, FORMAT(AVG(salary),0) as averagesalary 74 | FROM salaries s 75 | INNER JOIN fielding f 76 | ON f.playerid = s.playerid 77 | AND f.yearid = s.yearid 78 | GROUP BY position 79 | ORDER BY averagesalary; 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /baseballdatabank-csv/README.txt: -------------------------------------------------------------------------------- 1 | Baseball Databank is a compilation of historical baseball data in a 2 | convenient, tidy format, distributed under Open Data terms. 3 | 4 | This work is licensed under a Creative Commons Attribution-ShareAlike 5 | 3.0 Unported License. For details see: 6 | http://creativecommons.org/licenses/by-sa/3.0/ 7 | 8 | Organisation of the files 9 | ------------------------- 10 | 11 | There are two directories in the repository. 12 | 13 | * 'core' contains the databank itself. If you are a user of the data, these are the 14 | files you need. 15 | * 'upstream' contains files used to construct the databank. 16 | 17 | Most of the data in the Databank is provided by Chadwick Baseball Bureau 18 | (http://www.chadwick-bureau.com). The data differ from the data the Bureau provides 19 | to its clients in that it contains less detail, is updated less frequently, 20 | and is provided on an as-is basis. 21 | 22 | 23 | Other sources 24 | ------------- 25 | 26 | The Databank is historically based in part on the Lahman Baseball Database, 27 | version 2015-01-24, which is Copyright (C) 1996-2015 by Sean Lahman. 28 | 29 | The tables Parks.csv and HomeGames.csv are based on the game logs 30 | and park code table published by Retrosheet. 31 | This information is available free of charge from and is copyrighted 32 | by Retrosheet. Interested parties may contact Retrosheet at 33 | http://www.retrosheet.org. 34 | 35 | 36 | Queries and suggested revisions 37 | ------------------------------- 38 | 39 | Queries and suggested revisions to the data can be posted in the issue tracker at 40 | https://github.com/chadwickbureau/baseballdatabank/issues. 41 | 42 | Files in 'core' are all generated by scripts. As such they are not edited manually 43 | (and therefore pull requests should not be submitted against these files). 44 | 45 | Files in 'upstream' are manually-maintained files which contain information specific 46 | to constructing the Databank. As they are maintained manually, it is valid to submit 47 | pull requests containing corrections or additions to these files. 48 | 49 | Data which does not originate from the 'upstream' files is data maintained by 50 | Chadwick Baseball Bureau. While enquiries regarding these data are welcomed, 51 | remember that these data are updated with some lag, and therefore may differ from 52 | data which appear elsewhere on the Internet or other sources. 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /chapter-7/outer-join.sql: -------------------------------------------------------------------------------- 1 | #left outer join 2 | SELECT p.playerid, birthyear, schoolid, yearid 3 | FROM lahmansbaseballdb.people p 4 | LEFT OUTER JOIN lahmansbaseballdb.collegeplaying c 5 | ON p.playerid = c.playerid 6 | WHERE birthyear = 1985; 7 | 8 | #using left outer join without outer which will produce the same results 9 | SELECT p.playerid, birthyear, schoolid, yearid 10 | FROM lahmansbaseballdb.people p 11 | LEFT JOIN lahmansbaseballdb.collegeplaying c 12 | ON p.playerid = c.playerid 13 | WHERE birthyear = 1985; 14 | 15 | #left outer joining three tables 16 | SELECT p.playerid, birthyear, schoolid, asf.yearid, gameid 17 | FROM lahmansbaseballdb.people p 18 | LEFT OUTER JOIN lahmansbaseballdb.collegeplaying c 19 | ON p.playerid = c.playerid 20 | LEFT OUTER JOIN lahmansbaseballdb.allstarfull asf 21 | ON asf.playerid = p.playerid 22 | WHERE birthyear = 1985; 23 | 24 | #left excluding join 25 | SELECT p.playerid, birthyear, schoolid, yearid 26 | FROM lahmansbaseballdb.people p 27 | LEFT OUTER JOIN lahmansbaseballdb.collegeplaying c 28 | ON p.playerid = c.playerid 29 | WHERE birthyear = 1985 30 | AND c.playerid IS NULL; 31 | 32 | #right outer join 33 | SELECT p.playerid, asf.yearid, gameid, startingpos 34 | FROM lahmansbaseballdb.allstarfull asf 35 | RIGHT OUTER JOIN lahmansbaseballdb.people p 36 | ON p.playerid = asf.playerid; 37 | 38 | #using left outer join without outer which will produce the same results 39 | SELECT p.playerid, asf.yearid, gameid, startingpos 40 | FROM lahmansbaseballdb.allstarfull asf 41 | RIGHT JOIN lahmansbaseballdb.people p 42 | ON p.playerid = asf.playerid; 43 | 44 | #right outer joining three tables 45 | SELECT m.playerid, m.yearid, h.votedBy, s.salary 46 | FROM lahmansbaseballdb.managers m 47 | RIGHT OUTER JOIN lahmansbaseballdb.halloffame h 48 | ON m.playerid = h.playerid 49 | RIGHT OUTER JOIN lahmansbaseballdb.salaries s 50 | ON m.playerid = s.playerid; 51 | 52 | #right excluding join 53 | SELECT p.playerid, asf.yearid, gameid, startingpos 54 | FROM lahmansbaseballdb.allstarfull asf 55 | RIGHT OUTER JOIN lahmansbaseballdb.people p 56 | ON p.playerid = asf.playerid 57 | WHERE asf.playerid IS NULL; 58 | 59 | #full outer join in oracle, postgres, and sql server only 60 | USE lahmansbaseballdb; 61 | SELECT p.playerid, asf.yearid, gameid, startingpos 62 | FROM allstarfull asf 63 | FULL OUTER JOIN people p 64 | ON p.playerid = asf.playerid; 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /chapter-8/insert-from-existing-table.sql: -------------------------------------------------------------------------------- 1 | #the following query creates a new table and inserts all the rows from an existing table 2 | USE lahmansbaseballdb; 3 | CREATE TABLE managerscopy 4 | SELECT * FROM managers; 5 | 6 | #with oracle, postgresql, and sql server create new table and populate with data from existing table 7 | SELECT * INTO managerscopy 8 | FROM managers; 9 | 10 | 11 | #with oracle, postgresql, and sql server create new table and populate with data from existing table 12 | SELECT playerid, yearid, teamid, G 13 | INTO managerscopy 14 | FROM managers; 15 | 16 | 17 | #the following query creates a new table and inserts only some of the rows from an existing table 18 | USE lahmansbaseballdb; 19 | CREATE TABLE managers_plyrmgr 20 | SELECT * FROM managers 21 | WHERE plyrMgr = 'Y'; 22 | 23 | #the following query creates a blank table that matches the schema of an existing table 24 | USE lahmansbaseballdb; 25 | CREATE TABLE managerscopy 26 | SELECT * FROM managers 27 | WHERE 1=0; 28 | 29 | #with oracle, postgresql, and sql server create new table schema only 30 | SELECT * INTO managerscopy 31 | FROM managers 32 | WHERE 1 = 0; 33 | 34 | #the following query creates a blank table and populates it from two existing tables 35 | USE lahmansbaseballdb; 36 | CREATE TABLE awards 37 | SELECT am.playerid, namegiven, awardid, yearid, "Manager" as playertype 38 | FROM awardsmanagers am 39 | INNER JOIN people p 40 | ON p.playerid = am.playerid 41 | UNION 42 | SELECT ap.playerid, namegiven, awardid, yearid, "Player" 43 | FROM awardsplayers ap 44 | INNER JOIN people p 45 | ON p.playerid = ap.playerid 46 | ORDER BY awardid; 47 | 48 | #create new table and insert existing table data 49 | USE yourschema; 50 | CREATE TABLE allstarfull ( 51 | playerID varchar(9) NOT NULL, 52 | yearID smallint(6) NOT NULL, 53 | gameNum smallint(6) NOT NULL, 54 | gameID varchar(12) NULL, 55 | teamID varchar(3) NULL, 56 | lgID varchar(2) NULL, 57 | GP smallint(6) NULL, 58 | startingPos smallint(6) NULL 59 | ); 60 | 61 | INSERT INTO yourschema.allstarfull 62 | SELECT * FROM lahmansbaseballdb.allstarfull 63 | WHERE gameid LIKE 'NLS%' 64 | 65 | #create new table and insert existing table data for sql server, postgresql 66 | USE yourschema; 67 | CREATE TABLE allstarfull ( 68 | playerID varchar(9) NOT NULL, 69 | yearID smallint NOT NULL, 70 | gameNum smallint NOT NULL, 71 | gameID varchar(12) NULL, 72 | teamID varchar(3) NULL, 73 | lgID varchar(2) NULL, 74 | GP smallint NULL, 75 | startingPos smallint NULL 76 | ); 77 | 78 | INSERT INTO yourschema.dbo.allstarfull 79 | SELECT * FROM lahmansbaseballdb.dbo.allstarfull 80 | WHERE gameid LIKE 'NLS%' 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /chapter-12/stored-proc-parameters.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | DROP PROCEDURE IF EXISTS getplayergameinfo; 3 | 4 | # IN parameter 5 | DELIMITER $$ 6 | CREATE PROCEDURE getplayergameinfo 7 | ( 8 | IN yearid_in year, 9 | IN hits_in smallint 10 | ) 11 | BEGIN 12 | SELECT p.playerid, birthyear, a.yearid, 13 | a.teamid,G_defense AS defensegames, 14 | H AS numberofhits 15 | FROM appearances AS a 16 | JOIN people AS p ON p.playerid = a.playerid 17 | JOIN batting AS b ON a.playerid = b.playerid 18 | AND a.yearid = b.yearid 19 | AND a.teamid = b.teamid 20 | WHERE b.yearid = yearid_in AND h > hits_in 21 | ORDER BY p.playerid, a.yearid, 22 | a.teamid, G_defense, H; 23 | END $$ 24 | DELIMITER ; 25 | 26 | 27 | CALL getplayergameinfo(2016, 0); 28 | 29 | /*create and use stored proc in sql server with IN parameters */ 30 | CREATE or ALTER PROCEDURE getplayergameinfo 31 | @yearid_in smallint, 32 | @hits_in smallint 33 | AS 34 | SELECT p.playerid, birthyear, a.yearid, 35 | a.teamid, G_defense AS defensegames, 36 | H AS numberofhits 37 | FROM appearances AS a 38 | JOIN people AS p ON p.playerid = a.playerid 39 | JOIN batting AS b ON a.playerid = b.playerid 40 | AND a.yearid = b.yearid 41 | AND a.teamid = b.teamid 42 | WHERE b.yearid = @yearid_in AND H > @hits_in 43 | ORDER BY p.playerid, a.yearid, a.teamid, 44 | G_defense, H; 45 | 46 | EXEC getplayergameinfo @yearid_in = 2017, @hits_in = 0; 47 | 48 | 49 | # OUT parameter 50 | DROP PROCEDURE IF EXISTS getplayergameinfo; 51 | 52 | 53 | DELIMITER $$ 54 | CREATE PROCEDURE getplayergameinfo 55 | ( 56 | IN yearid_in year, 57 | IN h_in smallint, 58 | OUT countplayers smallint 59 | ) 60 | BEGIN 61 | SELECT COUNT(p.playerid) 62 | INTO countplayers 63 | FROM appearances AS a 64 | JOIN people AS p ON p.playerid = a.playerid 65 | JOIN batting AS b ON a.playerid = b.playerid 66 | AND a.yearid = b.yearid 67 | AND a.teamid = b.teamid 68 | WHERE b.yearid = yearid_in AND h > h_in 69 | ORDER BY p.playerid, a.yearid, a.teamid, G_defense, H; 70 | END $$ 71 | DELIMITER ; 72 | 73 | 74 | CALL getplayergameinfo(2015, 10, @countplayers); 75 | SELECT @countplayers; 76 | 77 | /*create and use stored proc in sql server with OUT parameters */ 78 | CREATE or ALTER PROCEDURE getplayergameinfo 79 | @yearid_in smallint, 80 | @hits_in smallint, 81 | @countplayers smallint OUT 82 | AS 83 | SELECT COUNT(p.playerid) 84 | FROM appearances AS a 85 | JOIN people AS p ON p.playerid = a.playerid 86 | JOIN batting AS b ON a.playerid = b.playerid 87 | AND a.yearid = b.yearid 88 | AND a.teamid = b.teamid 89 | WHERE b.yearid = @yearid_in AND H > @hits_in; 90 | 91 | 92 | DECLARE @countplayers smallint 93 | EXEC getplayergameinfo @yearid_in = 2017, @hits_in = 0, @countplayers = @countplayers OUT; 94 | SELECT @countplayers; 95 | 96 | -------------------------------------------------------------------------------- /chapter-8/modify-table.sql: -------------------------------------------------------------------------------- 1 | #create database and table to run scripts in this section of the chapter 2 | CREATE SCHEMA foraltering; 3 | 4 | USE foraltering; 5 | CREATE TABLE tableforaltering ( 6 | playerID varchar(9) NOT NULL, 7 | schoolID varchar(15) NULL, 8 | yearID smallint NULL 9 | ); 10 | 11 | #insert data into the table above 12 | USE foraltering; 13 | INSERT INTO tableforaltering 14 | VALUES ('aardsda01','pennst',2001), 15 | ('aardsda01',NULL,NULL), 16 | ('aardsda01','rice',2003), 17 | ('abadan01','gamiddl',1992), 18 | ('abadan01','gamiddl',1993), 19 | ('abbeybe01','vermont',1889), 20 | ('abbeybe01','vermont',1890), 21 | ('abbeybe01','vermont',1891), 22 | ('abbeybe01','vermont',1892), 23 | ('abbotje01','kentucky',1991), 24 | ('abbotje01','kentucky',1992), 25 | ('abbotje01','kentucky',1994); 26 | 27 | #add a column 28 | USE foraltering; 29 | ALTER TABLE tableforaltering 30 | ADD COLUMN atbats SMALLINT NULL AFTER yearID; 31 | 32 | ALTER TABLE tableforaltering 33 | ADD COLUMN hits SMALLINT NULL AFTER atbats; 34 | 35 | USE foraltering; 36 | ALTER TABLE tableforaltering 37 | ADD COLUMN atbats SMALLINT NULL AFTER yearID, 38 | ADD COLUMN hits SMALLINT NULL AFTER atbats; 39 | 40 | #drop a column 41 | USE foraltering; 42 | ALTER TABLE tableforaltering 43 | DROP COLUMN atbats; 44 | 45 | ALTER TABLE tableforaltering 46 | DROP COLUMN hits; 47 | 48 | USE foraltering; 49 | ALTER TABLE tableforaltering 50 | DROP COLUMN atbats, 51 | DROP COLUMN hits; 52 | 53 | #drop column 54 | USE yourschema; 55 | ALTER TABLE managers 56 | DROP COLUMN teamid; 57 | 58 | #drop column with foreign key 59 | USE yourschema; 60 | ALTER TABLE managers 61 | DROP FOREIGN KEY FK_teamid; 62 | ALTER TABLE managers 63 | DROP COLUMN teamid; 64 | 65 | 66 | #rename column 67 | USE foraltering; 68 | ALTER TABLE tableforaltering 69 | CHANGE COLUMN atbats numberofatbats SMALLINT; 70 | 71 | #change data type of column 72 | USE foraltering; 73 | ALTER TABLE tableforaltering 74 | CHANGE COLUMN schoolID schoolID VARCHAR(16); 75 | 76 | #gives error that it will truncate data 77 | USE foraltering; 78 | ALTER TABLE tableforaltering 79 | CHANGE COLUMN schoolID schoolID VARCHAR(7); 80 | 81 | #gives error that can't convert to int 82 | USE foraltering; 83 | ALTER TABLE tableforaltering 84 | CHANGE COLUMN schoolID schoolID INT; 85 | 86 | USE foraltering; 87 | ALTER TABLE tableforaltering 88 | CHANGE COLUMN yearID yearID SMALLINT; 89 | 90 | #add or change column constraint 91 | #add not null constraint 92 | USE foraltering; 93 | ALTER TABLE tableforaltering 94 | CHANGE COLUMN schoolID schoolID VARCHAR(8) NOT NULL, 95 | CHANGE COLUMN yearID yearID SMALLINT NOT NULL; 96 | 97 | #add check constraint 98 | USE foraltering; 99 | ALTER TABLE tableforaltering 100 | ADD CONSTRAINT check_yearid CHECK ((yearid >= 1871) and (yearid <= 2155)); 101 | 102 | #drop a constraint 103 | #drop check constraint 104 | USE foraltering; 105 | ALTER TABLE tableforaltering 106 | DROP CHECK check_yearid; 107 | 108 | #drop foreign key constraint 109 | ALTER TABLE tablename 110 | DROP FOREIGN KEY FK_keyname; 111 | 112 | #drop primary key 113 | ALTER TABLE tablename 114 | DROP PRIMARY KEY; 115 | 116 | #drop index 117 | USE yourschema; 118 | ALTER TABLE managers 119 | DROP INDEX playerid_yearid_teamid_UNIQUE; 120 | 121 | #drop check constraint in oracle, postresql, or sql server 122 | ALTER TABLE tableforaltering 123 | DROP CONSTRAINT check_yearid; 124 | 125 | #drop a table 126 | USE foraltering 127 | DROP TABLE tableforaltering; 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /chapter-12/triggers.sql: -------------------------------------------------------------------------------- 1 | USE lahmansbaseballdb; 2 | CREATE TABLE allstarfull_copy 3 | SELECT * FROM allstarfull; 4 | 5 | 6 | CREATE TABLE allstarfull_audit ( 7 | playerID varchar(9) NOT NULL, 8 | yearID smallint NOT NULL, 9 | gameNum smallint NOT NULL, 10 | gameID varchar(12) NULL, 11 | teamID varchar(3) NULL, 12 | lgID varchar(2) NULL, 13 | GP smallint NULL, 14 | startingPos smallint NULL, 15 | changedate DATETIME NOT NULL, /*timestamp in postgres */ 16 | actiontype VARCHAR(50) NOT NULL); 17 | 18 | # one statement in a trigger 19 | CREATE TRIGGER before_allstar_update 20 | BEFORE UPDATE ON allstarfull_copy 21 | FOR EACH ROW 22 | INSERT INTO allstarfull_audit 23 | SET actiontype = 'update', 24 | playerid = OLD.playerid, 25 | yearid = OLD.yearid, 26 | gamenum = OLD.gamenum, 27 | gameid = OLD.gameid, 28 | teamid = OLD.teamid, 29 | lgid = OLD.lgid, 30 | gp = OLD.gp, 31 | startingpos = OLD.startingpos, 32 | changedate = NOW(); 33 | 34 | 35 | /* use this to create a trigger in SQL Server */ 36 | CREATE TRIGGER after_allstar_update 37 | ON allstarfull_copy 38 | AFTER UPDATE 39 | AS 40 | BEGIN 41 | --SET NOCOUNT ON; 42 | INSERT INTO allstarfull_audit( 43 | playerid, 44 | yearid, 45 | gamenum, 46 | gameid, 47 | teamid, 48 | lgid, 49 | gp, 50 | startingpos, 51 | changedate, 52 | actiontype 53 | ) 54 | SELECT 55 | playerid, 56 | yearid, 57 | gamenum, 58 | gameid, 59 | teamid, 60 | lgid, 61 | gp, 62 | startingpos, 63 | GETDATE(), 64 | 'update' 65 | FROM 66 | inserted i 67 | UNION ALL 68 | SELECT 69 | playerid, 70 | yearid, 71 | gamenum, 72 | gameid, 73 | teamid, 74 | lgid, 75 | gp, 76 | startingpos, 77 | GETDATE(), 78 | 'delete' 79 | FROM 80 | deleted d; 81 | END 82 | 83 | 84 | UPDATE allstarfull_copy 85 | SET 86 | yearID = 2015, 87 | gameNum = 1, 88 | gameID = 'NLS201507170', 89 | teamID = 'CHI', 90 | lgID = 'AL', 91 | GP = 1, 92 | startingPos = 9 93 | WHERE playerid = 'arrieja01'; 94 | 95 | 96 | SELECT * FROM allstarfull_copy 97 | WHERE playerid = 'arrieja01'; 98 | 99 | SELECT * FROM allstarfull_audit; 100 | 101 | # multiple statements in one trigger 102 | DELIMITER $$ 103 | 104 | CREATE TRIGGER before_allstar_update 105 | BEFORE UPDATE ON allstarfull_copy 106 | FOR EACH ROW 107 | BEGIN 108 | IF OLD.playerid <> NEW.playerid THEN 109 | INSERT INTO allstarfull_audit 110 | SET actiontype = 'update', 111 | playerid = OLD.playerid, 112 | yearid = OLD.yearid, 113 | gamenum = OLD.gamenum, 114 | gameid = OLD.gameid, 115 | teamid = OLD.teamid, 116 | lgid = OLD.lgid, 117 | gp = OLD.gp, 118 | startingpos = OLD.startingpos, 119 | changedate = NOW(); 120 | END IF; 121 | END$$ 122 | DELIMITER ; 123 | 124 | # multiple triggers on one table 125 | CREATE TRIGGER before_allstar_update2 126 | BEFORE UPDATE ON allstarfull_copy 127 | FOR EACH ROW 128 | FOLLOWS before_allstar_update 129 | INSERT INTO allstarfull_audit 130 | SET actiontype = 'update', 131 | playerid = OLD.playerid, 132 | yearid = OLD.yearid, 133 | gamenum = OLD.gamenum, 134 | gameid = OLD.gameid, 135 | teamid = OLD.teamid, 136 | lgid = OLD.lgid, 137 | gp = OLD.gp, 138 | startingpos = OLD.startingpos, 139 | changedate = NOW(); 140 | 141 | # deleting a trigger 142 | 143 | DROP TRIGGER before_allstar_update; 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /chapter-11/non-correlated-subqueries.sql: -------------------------------------------------------------------------------- 1 | #using in 2 | USE lahmansbaseballdb; 3 | SELECT playerid, yearid, g as GamesBatted 4 | FROM batting 5 | WHERE playerid IN (SELECT playerid FROM people WHERE birthcity = 'Boston'); 6 | 7 | #using not in 8 | USE lahmansbaseballdb; 9 | SELECT playerid, yearid, g as GamesBatted 10 | FROM batting 11 | WHERE playerid NOT IN (SELECT playerid FROM people WHERE birthcity = 'Boston'); 12 | 13 | #using >= 14 | USE lahmansbaseballdb; 15 | SELECT playerid, yearid, salary 16 | FROM salaries 17 | WHERE salary >= 18 | (SELECT AVG(salary) 19 | FROM salaries 20 | WHERE teamid = 'DET' 21 | GROUP BY teamid) 22 | ORDER BY playerid, yearid; 23 | 24 | #using any 25 | USE lahmansbaseballdb; 26 | SELECT playerid, yearid, salary 27 | FROM salaries 28 | WHERE salary >= ANY 29 | (SELECT AVG(salary) 30 | FROM salaries 31 | GROUP BY teamid) 32 | ORDER BY playerid, yearid; 33 | 34 | #using all 35 | USE lahmansbaseballdb; 36 | SELECT playerid, yearid, salary 37 | FROM salaries 38 | WHERE salary >= ALL 39 | (SELECT AVG(salary) 40 | FROM salaries 41 | GROUP BY teamid) 42 | ORDER BY playerid, yearid; 43 | 44 | #using in select clause 45 | USE lahmansbaseballdb; 46 | SELECT playerid, yearid, salary, 47 | (SELECT ROUND(AVG(salary), 0) /* use ROUND(AVG(salary)) in PostgreSQL */ 48 | FROM salaries) AS average_salary, 49 | salary - (SELECT ROUND(AVG(salary), 0) /* use ROUND(AVG(salary)) in PostgreSQL */ 50 | FROM salaries) AS difference, 51 | (SELECT MAX(salary) 52 | FROM salaries) AS max_salary 53 | FROM salaries 54 | ORDER BY playerid, yearid; 55 | 56 | #using in from clause 57 | USE lahmansbaseballdb; 58 | SELECT ROUND(AVG(average_salary), 0) AS average_of_all_teams_salaries /* use ROUND(AVG(salary)) in PostgreSQL */ 59 | FROM 60 | (SELECT AVG(salary) average_salary 61 | FROM salaries 62 | GROUP BY teamid) AS team_salary; /* remove AS in Oracle */ 63 | 64 | USE lahmansbaseballdb; 65 | SELECT ROUND(AVG(average_salary), 0) AS average_of_all_teams_salaries /* use ROUND(AVG(salary)) in PostgreSQL */ 66 | FROM 67 | (SELECT AVG(salary) average_salary 68 | FROM salaries 69 | GROUP BY teamid) AS team_salary /* remove AS in Oracle */ 70 | WHERE team_salary.average_salary > 2000000; 71 | 72 | #using in insert update and delete 73 | USE lahmansbaseballdb; 74 | CREATE TABLE salaries_avg ( 75 | teamID varchar(3) NOT NULL, 76 | salaryavg double NOT NULL /* use float type in sql server and use real type in postgresql */ 77 | ); 78 | 79 | USE lahmansbaseballdb; 80 | INSERT INTO salaries_avg 81 | SELECT teamid, average_salary 82 | FROM 83 | (SELECT teamid, AVG(salary) average_salary 84 | FROM salaries 85 | GROUP BY teamid) AS team_salary 86 | WHERE team_salary.average_salary > 2000000; 87 | 88 | USE lahmansbaseballdb; 89 | UPDATE salaries_avg 90 | SET 91 | teamid = (SELECT teamid 92 | FROM 93 | (SELECT teamid, AVG(salary) average_salary 94 | FROM salaries 95 | GROUP BY teamid) AS team_salary 96 | WHERE team_salary.average_salary > 2000000 97 | LIMIT 1); /* use TOP in sql server instead of LIMIT */ 98 | 99 | 100 | USE lahmansbaseballdb; 101 | DELETE FROM salaries_avg 102 | WHERE teamid IN (SELECT teamid 103 | FROM 104 | (SELECT teamid, AVG(salary) avgsalary 105 | FROM salaries 106 | GROUP BY teamid) AS team_salary 107 | WHERE team_salary.avgsalary > 2000000 108 | AND teamid = 'ATL'); 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /baseballdatabank-csv/csv-files/TeamsFranchises.csv: -------------------------------------------------------------------------------- 1 | franchID,franchName,active,NAassoc 2 | ALT,Altoona Mountain City,N, 3 | ANA,Los Angeles Angels of Anaheim,Y, 4 | ARI,Arizona Diamondbacks,Y, 5 | ATH,Philadelphia Athletics,N,PNA 6 | ATL,Atlanta Braves,Y,BNA 7 | BAL,Baltimore Orioles,Y, 8 | BFB,Buffalo Bisons,N, 9 | BFL,Buffalo Bisons,N, 10 | BLC,Baltimore Canaries,NA, 11 | BLO,Baltimore Orioles,N, 12 | BLT,Baltimore Terrapins,N, 13 | BLU,Baltimore Monumentals,N, 14 | BNA,Boston Red Stockings,NA,ATL 15 | BOS,Boston Red Sox,Y, 16 | BRA,Brooklyn Atlantics,NA, 17 | BRD,Boston Reds,N, 18 | BRG,Brooklyn Gladiators,N, 19 | BRS,Boston Reds,N, 20 | BTT,Brooklyn Tip-Tops,N, 21 | BUF,Buffalo Bisons,N, 22 | BWW,Brooklyn Ward's Wonders,N, 23 | CBK,Columbus Buckeyes,N, 24 | CBL,Cleveland Blues,N, 25 | CEN,Philadelphia Centennials,NA, 26 | CFC,Cleveland Forest Citys,NA, 27 | CHC,Chicago Cubs,Y,CNA 28 | CHH,Chicago Whales,N, 29 | CHP,Chicago Pirates,N, 30 | CHW,Chicago White Sox,Y, 31 | CIN,Cincinnati Reds,Y, 32 | CKK,Cincinnati Kelly's Killers,N, 33 | CLE,Cleveland Indians,Y, 34 | CLI,Cleveland Infants,N, 35 | CLS,Columbus Solons,N, 36 | CLV,Cleveland Spiders,N, 37 | CNA,Chicago White Stockings,NA,CHC 38 | CNR,Cincinnati Reds,N, 39 | COL,Colorado Rockies,Y, 40 | COR,Cincinnati Outlaw Reds,N, 41 | CPI,Chicago/Pittsburgh (Union League),N, 42 | DET,Detroit Tigers,Y, 43 | DTN,Detroit Wolverines,N, 44 | ECK,Brooklyn Eckfords,NA, 45 | FLA,Florida Marlins,Y, 46 | HAR,Hartford Dark Blues,N,HNA 47 | HNA,Hartford Dark Blues,NA,HAR 48 | HOU,Houston Astros,Y, 49 | IBL,Indianapolis Blues,N, 50 | IHO,Indianapolis Hoosiers,N, 51 | IND,Indianapolis Hoosiers,N, 52 | KCC,Kansas City Cowboys,N, 53 | KCN,Kansas City Cowboys,N, 54 | KCP,Kansas City Packers,N, 55 | KCR,Kansas City Royals,Y, 56 | KCU,Kansas City Cowboys,N, 57 | KEK,Fort Wayne Kekiongas,NA, 58 | LAD,Los Angeles Dodgers,Y, 59 | LGR,Louisville Grays,N, 60 | LOU,Louisville Colonels,N, 61 | MAN,Middletown Mansfields,NA, 62 | MAR,Baltimore Marylands,NA, 63 | MIL,Milwaukee Brewers,Y, 64 | MIN,Minnesota Twins,Y, 65 | MLA,Milwaukee Brewers,N, 66 | MLG,Milwaukee Grays,N, 67 | MLU,Milwaukee Brewers,N, 68 | NAT,Washington Nationals,NA, 69 | NEW,Newark Pepper,N, 70 | NHV,New Haven Elm Citys,NA, 71 | NNA,New York Mutuals,NA,NYU 72 | NYI,New York Giants,N, 73 | NYM,New York Mets,Y, 74 | NYP,New York Metropolitans,N, 75 | NYU,New York Mutuals,N,NNA 76 | NYY,New York Yankees,Y, 77 | OAK,Oakland Athletics,Y, 78 | OLY,Washington Olympics,NA, 79 | PBB,Pittsburgh Burghers,N, 80 | PBS,Pittsburgh Rebels,N, 81 | PHA,Philadelphia Athletics,N, 82 | PHI,Philadelphia Phillies,Y, 83 | PHK,Philadelphia Keystones,N, 84 | PHQ,Philadelphia Athletics,N, 85 | PIT,Pittsburgh Pirates,Y, 86 | PNA,Philadelphia Athletics,NA,ATH 87 | PRO,Providence Grays,N, 88 | PWS,Philadelphia White Stockings,NA, 89 | RES,Elizabeth Resolutes,NA, 90 | RIC,Richmond Virginians,N, 91 | ROC,Rochester Broncos,N, 92 | ROK,Rockford Forest Citys,NA, 93 | SBS,St. Louis Brown Stockings,N,SNA 94 | SDP,San Diego Padres,Y, 95 | SEA,Seattle Mariners,Y, 96 | SFG,San Francisco Giants,Y, 97 | SLI,St. Louis Terriers,N, 98 | SLM,St. Louis Maroons,N, 99 | SLR,St. Louis Red Stockings,NA, 100 | SNA,St. Louis Brown Stockings,NA,SBS 101 | STL,St. Louis Cardinals,Y, 102 | STP,St. Paul Apostles,N, 103 | SYR,Syracuse Stars,N, 104 | SYS,Syracuse Stars,N, 105 | TBD,Tampa Bay Rays,Y, 106 | TEX,Texas Rangers,Y, 107 | TLM,Toledo Maumees,N, 108 | TOL,Toledo Blue Stockings,N, 109 | TOR,Toronto Blue Jays,Y, 110 | TRO,Troy Haymakers,NA, 111 | TRT,Troy Trojans,N, 112 | WAS,Washington Senators,N, 113 | WBL,Washington Blue Legs,NA, 114 | WES,Keokuk Westerns,NA, 115 | WIL,Wilmington Quicksteps,N, 116 | WNA,Washington Nationals,N, 117 | WNL,Washington Nationals,N, 118 | WNT,Washington Nationals,NA, 119 | WOR,Worcester Ruby Legs,N, 120 | WSN,Washington Nationals,Y, 121 | WST,Washington Statesmen,N, 122 | -------------------------------------------------------------------------------- /chapter-13/mysql-workbench-plugin-doc-generating.py: -------------------------------------------------------------------------------- 1 | # MySQL Workbench Plugin 2 | # 3 | # Written in MySQL Workbench 6.3.4 4 | 5 | from wb import * 6 | import grt 7 | import mforms 8 | 9 | ModuleInfo = DefineModule("ModelDocumentation", author="Hieu Le", version="1.0.0", description="Generate Markdown documentation from a model") 10 | 11 | # This plugin takes no arguments 12 | @ModuleInfo.plugin("info.hieule.wb.documentation", caption="Generate documentation (Markdown)", description="description", input=[wbinputs.currentDiagram()], pluginMenu="Utilities") 13 | @ModuleInfo.export(grt.INT, grt.classes.db_Catalog) 14 | def documentation(diagram): 15 | 16 | text = "# Schema documentation\n\n" 17 | text += "Generated by MySQL Workbench Model Documentation v1.0.0 - Copyright (c) 2015 Hieu Le\n\n"; 18 | 19 | 20 | for figure in diagram.figures: 21 | if hasattr(figure, "table") and figure.table: 22 | text += writeTableDoc(figure.table) 23 | 24 | mforms.Utilities.set_clipboard_text(text) 25 | mforms.App.get().set_status_text("Documentation generated into the clipboard. Paste it to your editor.") 26 | 27 | print "Documentation is copied to the clipboard." 28 | return 0 29 | 30 | def writeTableDoc(table): 31 | text = "## Table: `" + table.name + "`\n\n" 32 | 33 | text += "### Description: \n\n" 34 | 35 | text += table.comment + "\n\n" 36 | 37 | text += "### Columns: \n\n" 38 | 39 | text += "| Column | Data type | Attributes | Default | Description |\n| --- | --- | --- | --- | --- |\n" 40 | 41 | for column in table.columns: 42 | text += writeColumnDoc(column, table) 43 | 44 | text += "\n\n" 45 | 46 | if (len(table.indices)): 47 | text += "### Indices: \n\n" 48 | 49 | text += "| Name | Columns | Type | Description |\n| --- | --- | --- | --- |\n" 50 | 51 | for index in table.indices: 52 | text += writeIndexDoc(index) 53 | 54 | text += "\n\n" 55 | 56 | return text 57 | 58 | 59 | def writeColumnDoc(column, table): 60 | # column name 61 | text = "| `" + column.name + "`" 62 | 63 | # column type name 64 | if column.simpleType: 65 | text += " | " + column.simpleType.name 66 | # column max lenght if any 67 | if column.length != -1: 68 | text += "(" + str(column.length) + ")" 69 | else: 70 | text += " | " 71 | 72 | 73 | 74 | text += " | " 75 | 76 | # column attributes 77 | attribs = []; 78 | 79 | isPrimary = False; 80 | isUnique = False; 81 | for index in table.indices: 82 | if index.indexType == "PRIMARY": 83 | for c in index.columns: 84 | if c.referencedColumn.name == column.name: 85 | isPrimary = True 86 | break 87 | if index.indexType == "UNIQUE": 88 | for c in index.columns: 89 | if c.referencedColumn.name == column.name: 90 | isUnique = True 91 | break 92 | 93 | # primary? 94 | if isPrimary: 95 | attribs.append("PRIMARY") 96 | 97 | # auto increment? 98 | if column.autoIncrement == 1: 99 | attribs.append("Auto increments") 100 | 101 | # not null? 102 | if column.isNotNull == 1: 103 | attribs.append("Not null") 104 | 105 | # unique? 106 | if isUnique: 107 | attribs.append("Unique") 108 | 109 | text += ", ".join(attribs) 110 | 111 | # column default value 112 | text += " | " + (("`" + column.defaultValue + "`") if column.defaultValue else " ") 113 | 114 | # column description 115 | text += " | " + (nl2br(column.comment) if column.comment else " ") 116 | 117 | # foreign key 118 | for fk in table.foreignKeys: 119 | if fk.columns[0].name == column.name: 120 | text += ("

" if column.comment else "") + "**foreign key** to column `" + fk.referencedColumns[0].name + "` on table `" + fk.referencedColumns[0].owner.name + "`." 121 | break 122 | 123 | 124 | # finish 125 | text += " |" + "\n" 126 | return text 127 | 128 | def writeIndexDoc(index): 129 | 130 | # index name 131 | text = "| " + index.name 132 | 133 | # index columns 134 | text += " | " + ", ".join(map(lambda x: "`" + x.referencedColumn.name + "`", index.columns)) 135 | 136 | # index type 137 | text += " | " + index.indexType 138 | 139 | # index description 140 | text += " | " + (nl2br(index.comment) if index.comment else " ") 141 | 142 | # finish 143 | text += " |\n" 144 | 145 | return text 146 | 147 | def nl2br(text): 148 | return "
".join(map(lambda x: x.strip(), text.split("\n"))) 149 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # Learn SQL Database Programming 5 | 6 | Learn SQL Database Programming 7 | 8 | This is the code repository for [Learn SQL Database Programming](https://www.packtpub.com/in/data/learn-sql-database-programming?utm_source=github&utm_medium=repository&utm_campaign=9781838984762), published by Packt. 9 | 10 | **Query and manipulate databases from popular relational database servers using SQL** 11 | 12 | ## What is this book about? 13 | SQL is a powerful querying language that's used to store, manipulate, and retrieve data, and it is one of the most popular languages used by developers to query and analyze data efficiently. If you're looking for a comprehensive introduction to SQL, Learn SQL Database Programming will help you to get up to speed with using SQL to streamline your work in no time. Starting with an overview of relational database management systems, this book will show you how to set up and use MySQL Workbench and design a database using practical examples. You'll also discover how to query and manipulate data with SQL programming using MySQL Workbench. As you advance, you’ll create a database, query single and multiple tables, and modify data using SQL querying. This SQL book covers advanced SQL techniques, including aggregate functions, flow control statements, error handling, and subqueries, and helps you process your data to present your findings. Finally, you’ll implement best practices for writing SQL and designing indexes and tables. By the end of this SQL programming book, you’ll have gained the confidence to use SQL queries to retrieve and manipulate data. 14 | 15 | This book covers the following exciting features: 16 | * Install, configure, and use MySQL Workbench to restore a database 17 | * Explore different data types such as string, numeric, and date and time 18 | * Query a single table using the basic SQL SELECT statement and the FROM, WHERE, and ORDER BY clauses 19 | * Query multiple tables by understanding various types of table relationships 20 | * Modify data in tables using the INSERT, UPDATE, and DELETE statements 21 | 22 | If you feel this book is for you, get your [copy](https://www.amazon.com/dp/1838984763) today! 23 | 24 | https://www.packtpub.com/ 25 | 26 | ## Instructions and Navigations 27 | All of the code is organized into folders. For example, Chapter02. 28 | 29 | The code will look like the following: 30 | ``` 31 | 32 | 33 | Learn SQL Programming 34 | Josephine Bush 35 | 36 | 37 | ``` 38 | 39 | **Following is what you need for this book:** 40 | This book is for business analysts, SQL developers, database administrators, and students learning SQL. If you want to learn how to query and manipulate SQL data for database administration tasks or simply extract and organize relevant data for analysis, you’ll find this book useful. No prior SQL experience is required. 41 | 42 | 43 | ### Software and Hardware List 44 | 45 | | Chapter | Software required | OS required | 46 | | -------- | ------------------------------------| -----------------------------------| 47 | | 4-13 | MySQL Workbench 8.0.20 | Windows, Mac OS X, and Linux (Any) | 48 | 49 | 50 | We also provide a PDF file that has color images of the screenshots/diagrams used in this book. [Click here to download it](https://static.packt-cdn.com/downloads/9781838984762_ColorImages.pdf). 51 | 52 | 53 | ## Get to Know the Author 54 | **Josephine Bush** 55 | has over 10 years of experience as a Database Administrator. Her experience is extensive and broad-based, including in financial, businss, and energy data systems using MySQL, SQL Server, Oracle, and PostgreSQL. She is a Microsoft Certified Solutions Expert: Data Management and Analytics. She holds a BS in Information Technology, an MBA in IT Management, and an MS in Data Analytics. 56 | 57 | 58 | ## Other books by the authors 59 | * [SQL for Data Analytics](https://www.packtpub.com/in/big-data-and-business-intelligence/sql-data-analysis?utm_source=github&utm_medium=repository&utm_campaign=9781789807356) 60 | * [Advanced MySQL 8](https://www.packtpub.com/in/big-data-and-business-intelligence/mastering-mysql-8?utm_source=github&utm_medium=repository&utm_campaign=9781788834445) 61 | 62 | ### Suggestions and Feedback 63 | [Click here](https://docs.google.com/forms/d/e/1FAIpQLSdy7dATC6QmEL81FIUuymZ0Wy9vH1jHkvpY57OiMeKGqib_Ow/viewform) if you have any feedback or suggestions. 64 | ### Download a free PDF 65 | 66 | If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.
67 |

https://packt.link/free-ebook/9781838984762

-------------------------------------------------------------------------------- /baseball-database/lahmansbaseballdb-backup/lahmansbaseballdb_teamsfranchises.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `lahmansbaseballdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; 2 | USE `lahmansbaseballdb`; 3 | -- MySQL dump 10.13 Distrib 8.0.17, for Win64 (x86_64) 4 | -- 5 | -- Host: localhost Database: lahmansbaseballdb 6 | -- ------------------------------------------------------ 7 | -- Server version 8.0.17 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!50503 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Table structure for table `teamsfranchises` 22 | -- 23 | 24 | DROP TABLE IF EXISTS `teamsfranchises`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | /*!50503 SET character_set_client = utf8mb4 */; 27 | CREATE TABLE `teamsfranchises` ( 28 | `franchID` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, 29 | `franchName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 30 | `active` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 31 | `NAassoc` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 32 | PRIMARY KEY (`franchID`) 33 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 34 | /*!40101 SET character_set_client = @saved_cs_client */; 35 | 36 | -- 37 | -- Dumping data for table `teamsfranchises` 38 | -- 39 | 40 | LOCK TABLES `teamsfranchises` WRITE; 41 | /*!40000 ALTER TABLE `teamsfranchises` DISABLE KEYS */; 42 | INSERT INTO `teamsfranchises` VALUES ('ALT','Altoona Mountain City','N',NULL),('ANA','Los Angeles Angels of Anaheim','Y',NULL),('ARI','Arizona Diamondbacks','Y',NULL),('ATH','Philadelphia Athletics','N','PNA'),('ATL','Atlanta Braves','Y','BNA'),('BAL','Baltimore Orioles','Y',NULL),('BFB','Buffalo Bisons','N',NULL),('BFL','Buffalo Bisons','N',NULL),('BLC','Baltimore Canaries','NA',NULL),('BLO','Baltimore Orioles','N',NULL),('BLT','Baltimore Terrapins','N',NULL),('BLU','Baltimore Monumentals','N',NULL),('BNA','Boston Red Stockings','NA','ATL'),('BOS','Boston Red Sox','Y',NULL),('BRA','Brooklyn Atlantics','NA',NULL),('BRD','Boston Reds','N',NULL),('BRG','Brooklyn Gladiators','N',NULL),('BRS','Boston Reds','N',NULL),('BTT','Brooklyn Tip-Tops','N',NULL),('BUF','Buffalo Bisons','N',NULL),('BWW','Brooklyn Ward\'s Wonders','N',NULL),('CBK','Columbus Buckeyes','N',NULL),('CBL','Cleveland Blues','N',NULL),('CEN','Philadelphia Centennials','NA',NULL),('CFC','Cleveland Forest Citys','NA',NULL),('CHC','Chicago Cubs','Y','CNA'),('CHH','Chicago Whales','N',NULL),('CHP','Chicago Pirates','N',NULL),('CHW','Chicago White Sox','Y',NULL),('CIN','Cincinnati Reds','Y',NULL),('CKK','Cincinnati Kelly\'s Killers','N',NULL),('CLE','Cleveland Indians','Y',NULL),('CLI','Cleveland Infants','N',NULL),('CLS','Columbus Solons','N',NULL),('CLV','Cleveland Spiders','N',NULL),('CNA','Chicago White Stockings','NA','CHC'),('CNR','Cincinnati Reds','N',NULL),('COL','Colorado Rockies','Y',NULL),('COR','Cincinnati Outlaw Reds','N',NULL),('CPI','Chicago/Pittsburgh (Union League)','N',NULL),('DET','Detroit Tigers','Y',NULL),('DTN','Detroit Wolverines','N',NULL),('ECK','Brooklyn Eckfords','NA',NULL),('FLA','Florida Marlins','Y',NULL),('HAR','Hartford Dark Blues','N','HNA'),('HNA','Hartford Dark Blues','NA','HAR'),('HOU','Houston Astros','Y',NULL),('IBL','Indianapolis Blues','N',NULL),('IHO','Indianapolis Hoosiers','N',NULL),('IND','Indianapolis Hoosiers','N',NULL),('KCC','Kansas City Cowboys','N',NULL),('KCN','Kansas City Cowboys','N',NULL),('KCP','Kansas City Packers','N',NULL),('KCR','Kansas City Royals','Y',NULL),('KCU','Kansas City Cowboys','N',NULL),('KEK','Fort Wayne Kekiongas','NA',NULL),('LAD','Los Angeles Dodgers','Y',NULL),('LGR','Louisville Grays','N',NULL),('LOU','Louisville Colonels','N',NULL),('MAN','Middletown Mansfields','NA',NULL),('MAR','Baltimore Marylands','NA',NULL),('MIL','Milwaukee Brewers','Y',NULL),('MIN','Minnesota Twins','Y',NULL),('MLA','Milwaukee Brewers','N',NULL),('MLG','Milwaukee Grays','N',NULL),('MLU','Milwaukee Brewers','N',NULL),('NAT','Washington Nationals','NA',NULL),('NEW','Newark Pepper','N',NULL),('NHV','New Haven Elm Citys','NA',NULL),('NNA','New York Mutuals','NA','NYU'),('NYI','New York Giants','N',NULL),('NYM','New York Mets','Y',NULL),('NYP','New York Metropolitans','N',NULL),('NYU','New York Mutuals','N','NNA'),('NYY','New York Yankees','Y',NULL),('OAK','Oakland Athletics','Y',NULL),('OLY','Washington Olympics','NA',NULL),('PBB','Pittsburgh Burghers','N',NULL),('PBS','Pittsburgh Rebels','N',NULL),('PHA','Philadelphia Athletics','N',NULL),('PHI','Philadelphia Phillies','Y',NULL),('PHK','Philadelphia Keystones','N',NULL),('PHQ','Philadelphia Athletics','N',NULL),('PIT','Pittsburgh Pirates','Y',NULL),('PNA','Philadelphia Athletics','NA','ATH'),('PRO','Providence Grays','N',NULL),('PWS','Philadelphia White Stockings','NA',NULL),('RES','Elizabeth Resolutes','NA',NULL),('RIC','Richmond Virginians','N',NULL),('ROC','Rochester Broncos','N',NULL),('ROK','Rockford Forest Citys','NA',NULL),('SBS','St. Louis Brown Stockings','N','SNA'),('SDP','San Diego Padres','Y',NULL),('SEA','Seattle Mariners','Y',NULL),('SFG','San Francisco Giants','Y',NULL),('SLI','St. Louis Terriers','N',NULL),('SLM','St. Louis Maroons','N',NULL),('SLR','St. Louis Red Stockings','NA',NULL),('SNA','St. Louis Brown Stockings','NA','SBS'),('STL','St. Louis Cardinals','Y',NULL),('STP','St. Paul Apostles','N',NULL),('SYR','Syracuse Stars','N',NULL),('SYS','Syracuse Stars','N',NULL),('TBD','Tampa Bay Rays','Y',NULL),('TEX','Texas Rangers','Y',NULL),('TLM','Toledo Maumees','N',NULL),('TOL','Toledo Blue Stockings','N',NULL),('TOR','Toronto Blue Jays','Y',NULL),('TRO','Troy Haymakers','NA',NULL),('TRT','Troy Trojans','N',NULL),('WAS','Washington Senators','N',NULL),('WBL','Washington Blue Legs','NA',NULL),('WES','Keokuk Westerns','NA',NULL),('WIL','Wilmington Quicksteps','N',NULL),('WNA','Washington Nationals','N',NULL),('WNL','Washington Nationals','N',NULL),('WNT','Washington Nationals','NA',NULL),('WOR','Worcester Ruby Legs','N',NULL),('WSN','Washington Nationals','Y',NULL),('WST','Washington Statesmen','N',NULL); 43 | /*!40000 ALTER TABLE `teamsfranchises` ENABLE KEYS */; 44 | UNLOCK TABLES; 45 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 46 | 47 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 48 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 49 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 50 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 51 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 52 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 53 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 54 | 55 | -- Dump completed on 2019-09-20 18:01:58 56 | -------------------------------------------------------------------------------- /baseballdatabank-csv/csv-files/AwardsManagers.csv: -------------------------------------------------------------------------------- 1 | playerID,awardID,yearID,lgID,tie,notes 2 | larusto01,BBWAA Manager of the Year,1983,AL,, 3 | lasorto01,BBWAA Manager of the Year,1983,NL,, 4 | andersp01,BBWAA Manager of the Year,1984,AL,, 5 | freyji99,BBWAA Manager of the Year,1984,NL,, 6 | coxbo01,BBWAA Manager of the Year,1985,AL,, 7 | herzowh01,BBWAA Manager of the Year,1985,NL,, 8 | mcnamjo99,BBWAA Manager of the Year,1986,AL,, 9 | lanieha01,BBWAA Manager of the Year,1986,NL,, 10 | andersp01,BBWAA Manager of the Year,1987,AL,, 11 | rodgebu01,BBWAA Manager of the Year,1987,NL,, 12 | larusto01,BBWAA Manager of the Year,1988,AL,, 13 | lasorto01,BBWAA Manager of the Year,1988,NL,, 14 | robinfr02,BBWAA Manager of the Year,1989,AL,, 15 | zimmedo01,BBWAA Manager of the Year,1989,NL,, 16 | torboje01,BBWAA Manager of the Year,1990,AL,, 17 | leylaji99,BBWAA Manager of the Year,1990,NL,, 18 | kellyto01,BBWAA Manager of the Year,1991,AL,, 19 | coxbo01,BBWAA Manager of the Year,1991,NL,, 20 | larusto01,BBWAA Manager of the Year,1992,AL,, 21 | leylaji99,BBWAA Manager of the Year,1992,NL,, 22 | lamonge01,BBWAA Manager of the Year,1993,AL,, 23 | bakerdu01,BBWAA Manager of the Year,1993,NL,, 24 | showabu99,BBWAA Manager of the Year,1994,AL,, 25 | aloufe01,BBWAA Manager of the Year,1994,NL,, 26 | pinielo01,BBWAA Manager of the Year,1995,AL,, 27 | baylodo01,BBWAA Manager of the Year,1995,NL,, 28 | oatesjo01,BBWAA Manager of the Year,1996,AL,Y, 29 | torrejo01,BBWAA Manager of the Year,1996,AL,Y, 30 | bochybr01,BBWAA Manager of the Year,1996,NL,, 31 | johnsda02,BBWAA Manager of the Year,1997,AL,, 32 | bakerdu01,BBWAA Manager of the Year,1997,NL,, 33 | torrejo01,BBWAA Manager of the Year,1998,AL,, 34 | dierkla01,BBWAA Manager of the Year,1998,NL,, 35 | williji03,BBWAA Manager of the Year,1999,AL,, 36 | mckeoja99,BBWAA Manager of the Year,1999,NL,, 37 | manueje01,BBWAA Manager of the Year,2000,AL,, 38 | bakerdu01,BBWAA Manager of the Year,2000,NL,, 39 | pinielo01,BBWAA Manager of the Year,2001,AL,, 40 | bowala01,BBWAA Manager of the Year,2001,NL,, 41 | sciosmi01,BBWAA Manager of the Year,2002,AL,, 42 | larusto01,BBWAA Manager of the Year,2002,NL,, 43 | penato01,BBWAA Manager of the Year,2003,AL,, 44 | mckeoja99,BBWAA Manager of the Year,2003,NL,, 45 | showabu99,BBWAA Manager of the Year,2004,AL,, 46 | coxbo01,BBWAA Manager of the Year,2004,NL,, 47 | guilloz01,BBWAA Manager of the Year,2005,AL,, 48 | coxbo01,BBWAA Manager of the Year,2005,NL,, 49 | leylaji99,BBWAA Manager of the Year,2006,AL,, 50 | girarjo01,BBWAA Manager of the Year,2006,NL,, 51 | wedgeer01,BBWAA Manager of the Year,2007,AL,, 52 | melvibo01,BBWAA Manager of the Year,2007,NL,, 53 | maddojo99,BBWAA Manager of the Year,2008,AL,, 54 | pinielo01,BBWAA Manager of the Year,2008,NL,, 55 | sciosmi01,BBWAA Manager of the Year,2009,AL,, 56 | tracyji01,BBWAA Manager of the Year,2009,NL,, 57 | gardero01,BBWAA Manager of the Year,2010,AL,, 58 | blackbu02,BBWAA Manager of the Year,2010,NL,, 59 | maddojo99,BBWAA Manager of the Year,2011,AL,, 60 | gibsoki01,BBWAA Manager of the Year,2011,NL,, 61 | melvibo01,BBWAA Manager of the Year,2012,AL,, 62 | johnsda02,BBWAA Manager of the Year,2012,NL,, 63 | francte01,BBWAA Manager of the Year,2013,AL,, 64 | hurdlcl01,BBWAA Manager of the Year,2013,NL,, 65 | mccarjo99,TSN Manager of the Year,1936,ML,, 66 | mckecbi01,TSN Manager of the Year,1937,ML,, 67 | mccarjo99,TSN Manager of the Year,1938,ML,, 68 | durocle01,TSN Manager of the Year,1939,ML,, 69 | mckecbi01,TSN Manager of the Year,1940,ML,, 70 | southbi01,TSN Manager of the Year,1941,ML,, 71 | southbi01,TSN Manager of the Year,1942,ML,, 72 | mccarjo99,TSN Manager of the Year,1943,ML,, 73 | sewellu01,TSN Manager of the Year,1944,ML,, 74 | bluegos01,TSN Manager of the Year,1945,ML,, 75 | dyered01,TSN Manager of the Year,1946,ML,, 76 | harribu01,TSN Manager of the Year,1947,ML,, 77 | meyerbi01,TSN Manager of the Year,1948,ML,, 78 | stengca01,TSN Manager of the Year,1949,ML,, 79 | rolfere01,TSN Manager of the Year,1950,ML,, 80 | durocle01,TSN Manager of the Year,1951,ML,, 81 | stanked01,TSN Manager of the Year,1952,ML,, 82 | stengca01,TSN Manager of the Year,1953,ML,, 83 | durocle01,TSN Manager of the Year,1954,ML,, 84 | alstowa01,TSN Manager of the Year,1955,ML,, 85 | tebbebi01,TSN Manager of the Year,1956,ML,, 86 | hutchfr01,TSN Manager of the Year,1957,ML,, 87 | stengca01,TSN Manager of the Year,1958,ML,, 88 | alstowa01,TSN Manager of the Year,1959,ML,, 89 | murtada01,TSN Manager of the Year,1960,ML,, 90 | houkra01,TSN Manager of the Year,1961,ML,, 91 | rignebi01,TSN Manager of the Year,1962,ML,, 92 | alstowa01,TSN Manager of the Year,1963,ML,, 93 | keanejo99,TSN Manager of the Year,1964,ML,, 94 | melesa01,TSN Manager of the Year,1965,ML,, 95 | bauerha01,TSN Manager of the Year,1966,ML,, 96 | willidi02,TSN Manager of the Year,1967,ML,, 97 | smithma01,TSN Manager of the Year,1968,ML,, 98 | hodgegi01,TSN Manager of the Year,1969,ML,, 99 | murtada01,TSN Manager of the Year,1970,ML,, 100 | foxch01,TSN Manager of the Year,1971,ML,, 101 | tannech01,TSN Manager of the Year,1972,ML,, 102 | mauchge01,TSN Manager of the Year,1973,ML,, 103 | virdobi01,TSN Manager of the Year,1974,ML,, 104 | johnsda01,TSN Manager of the Year,1975,ML,, 105 | ozarkda99,TSN Manager of the Year,1976,ML,, 106 | weaveea99,TSN Manager of the Year,1977,ML,, 107 | bambege01,TSN Manager of the Year,1978,ML,, 108 | weaveea99,TSN Manager of the Year,1979,ML,, 109 | virdobi01,TSN Manager of the Year,1980,ML,, 110 | martibi02,TSN Manager of the Year,1981,ML,, 111 | herzowh01,TSN Manager of the Year,1982,ML,, 112 | larusto01,TSN Manager of the Year,1983,ML,, 113 | freyji99,TSN Manager of the Year,1984,ML,, 114 | coxbo01,TSN Manager of the Year,1985,ML,, 115 | lanieha01,TSN Manager of the Year,1986,NL,, 116 | mcnamjo99,TSN Manager of the Year,1986,AL,, 117 | andersp01,TSN Manager of the Year,1987,AL,, 118 | rodgebu01,TSN Manager of the Year,1987,NL,, 119 | larusto01,TSN Manager of the Year,1988,AL,, 120 | leylaji99,TSN Manager of the Year,1988,NL,, 121 | robinfr02,TSN Manager of the Year,1989,AL,, 122 | zimmedo01,TSN Manager of the Year,1989,NL,, 123 | leylaji99,TSN Manager of the Year,1990,NL,, 124 | torboje01,TSN Manager of the Year,1990,AL,, 125 | coxbo01,TSN Manager of the Year,1991,NL,, 126 | kellyto01,TSN Manager of the Year,1991,AL,, 127 | larusto01,TSN Manager of the Year,1992,AL,, 128 | leylaji99,TSN Manager of the Year,1992,NL,, 129 | coxbo01,TSN Manager of the Year,1993,NL,, 130 | oatesjo01,TSN Manager of the Year,1993,AL,, 131 | aloufe01,TSN Manager of the Year,1994,NL,, 132 | showabu99,TSN Manager of the Year,1994,AL,, 133 | baylodo01,TSN Manager of the Year,1995,NL,, 134 | hargrmi01,TSN Manager of the Year,1995,AL,, 135 | bochybr01,TSN Manager of the Year,1996,NL,, 136 | oatesjo01,TSN Manager of the Year,1996,AL,, 137 | bakerdu01,TSN Manager of the Year,1997,NL,, 138 | johnsda02,TSN Manager of the Year,1997,AL,, 139 | bochybr01,TSN Manager of the Year,1998,NL,, 140 | torrejo01,TSN Manager of the Year,1998,AL,, 141 | coxbo01,TSN Manager of the Year,1999,NL,, 142 | williji03,TSN Manager of the Year,1999,AL,, 143 | bakerdu01,TSN Manager of the Year,2000,NL,, 144 | manueje01,TSN Manager of the Year,2000,AL,, 145 | bowala01,TSN Manager of the Year,2001,NL,, 146 | pinielo01,TSN Manager of the Year,2001,AL,, 147 | coxbo01,TSN Manager of the Year,2002,NL,, 148 | sciosmi01,TSN Manager of the Year,2002,AL,, 149 | coxbo01,TSN Manager of the Year,2003,NL,, 150 | penato01,TSN Manager of the Year,2003,AL,, 151 | coxbo01,TSN Manager of the Year,2004,NL,, 152 | gardero01,TSN Manager of the Year,2004,AL,, 153 | coxbo01,TSN Manager of the Year,2005,NL,, 154 | guilloz01,TSN Manager of the Year,2005,AL,, 155 | girarjo01,TSN Manager of the Year,2006,NL,, 156 | leylaji99,TSN Manager of the Year,2006,AL,, 157 | melvibo01,TSN Manager of the Year,2007,NL,, 158 | wedgeer01,TSN Manager of the Year,2007,AL,, 159 | maddojo99,TSN Manager of the Year,2008,AL,, 160 | gonzafr99,TSN Manager of the Year,2008,NL,, 161 | sciosmi01,TSN Manager of the Year,2009,AL,, 162 | tracyji01,TSN Manager of the Year,2009,NL,, 163 | gardero01,TSN Manager of the Year,2010,AL,, 164 | blackbu02,TSN Manager of the Year,2010,NL,, 165 | maddojo99,TSN Manager of the Year,2011,AL,, 166 | gibsoki01,TSN Manager of the Year,2011,NL,, 167 | showabu99,TSN Manager of the Year,2012,AL,, 168 | johnsda02,TSN Manager of the Year,2012,NL,, 169 | farrejo03,TSN Manager of the Year,2013,AL,, 170 | hurdlcl01,TSN Manager of the Year,2013,NL,, 171 | showabu99,TSN Manager of the Year,2014,AL,, 172 | willima04,TSN Manager of the Year,2014,NL,, 173 | molitpa01,TSN Manager of the Year,2015,AL,, 174 | collite99,TSN Manager of the Year,2015,NL,, 175 | showabu99,BBWAA Manager of the Year,2014,AL,, 176 | willima04,BBWAA Manager of the Year,2014,NL,, 177 | banisje01,BBWAA Manager of the Year,2015,AL,, 178 | maddojo99,BBWAA Manager of the Year,2015,NL,, 179 | francte01,BBWAA Manager of the Year,2016,AL,, 180 | roberda07,BBWAA Manager of the Year,2016,NL,, 181 | -------------------------------------------------------------------------------- /baseballdatabank-csv/csv-files/SeriesPost.csv: -------------------------------------------------------------------------------- 1 | yearID,round,teamIDwinner,lgIDwinner,teamIDloser,lgIDloser,wins,losses,ties 2 | 1884,WS,PRO,NL,NY4,AA,3,0,0 3 | 1885,WS,CHN,NL,SL4,AA,3,3,1 4 | 1886,WS,SL4,AA,CHN,NL,4,2,0 5 | 1887,WS,DTN,NL,SL4,AA,10,5,0 6 | 1888,WS,NY1,NL,SL4,AA,6,4,0 7 | 1889,WS,NY1,NL,BR3,AA,6,3,0 8 | 1890,WS,BRO,NL,LS2,AA,3,3,1 9 | 1892,CS,BSN,NL,CL4,NL,5,0,1 10 | 1903,WS,BOS,AL,PIT,NL,5,3,0 11 | 1905,WS,NY1,NL,PHA,AL,4,1,0 12 | 1906,WS,CHA,AL,CHN,NL,4,2,0 13 | 1907,WS,CHN,NL,DET,AL,4,0,0 14 | 1908,WS,CHN,NL,DET,AL,4,1,0 15 | 1909,WS,PIT,NL,DET,AL,4,3,0 16 | 1910,WS,PHA,AL,CHN,NL,4,1,0 17 | 1911,WS,PHA,AL,NY1,NL,4,2,0 18 | 1912,WS,BOS,AL,NY1,NL,4,3,0 19 | 1913,WS,PHA,AL,NY1,NL,4,1,0 20 | 1914,WS,BSN,NL,PHA,AL,4,0,0 21 | 1915,WS,BOS,AL,PHI,NL,4,1,0 22 | 1916,WS,BOS,AL,BRO,NL,4,1,0 23 | 1917,WS,CHA,AL,NY1,NL,4,2,0 24 | 1918,WS,BOS,AL,CHN,NL,4,2,0 25 | 1919,WS,CIN,NL,CHA,AL,5,3,0 26 | 1920,WS,CLE,AL,BRO,NL,5,2,0 27 | 1921,WS,NY1,NL,NYA,AL,5,3,0 28 | 1922,WS,NY1,NL,NYA,AL,4,0,0 29 | 1923,WS,NYA,AL,NY1,NL,4,2,0 30 | 1924,WS,WS1,AL,NY1,NL,4,3,0 31 | 1925,WS,PIT,NL,WS1,AL,4,3,0 32 | 1926,WS,SLN,NL,NYA,AL,4,3,0 33 | 1927,WS,NYA,AL,PIT,NL,4,0,0 34 | 1928,WS,NYA,AL,SLN,NL,4,0,0 35 | 1929,WS,PHA,AL,CHN,NL,4,1,0 36 | 1930,WS,PHA,AL,SLN,NL,4,2,0 37 | 1931,WS,SLN,NL,PHA,AL,4,3,0 38 | 1932,WS,NYA,AL,CHN,NL,4,0,0 39 | 1933,WS,NY1,NL,WS1,AL,4,1,0 40 | 1934,WS,SLN,NL,DET,AL,4,3,0 41 | 1935,WS,DET,AL,CHN,NL,4,2,0 42 | 1936,WS,NYA,AL,NY1,NL,4,2,0 43 | 1937,WS,NYA,AL,NY1,NL,4,1,0 44 | 1938,WS,NYA,AL,CHN,NL,4,0,0 45 | 1939,WS,NYA,AL,CIN,NL,4,0,0 46 | 1940,WS,CIN,NL,DET,AL,4,3,0 47 | 1941,WS,NYA,AL,BRO,NL,4,1,0 48 | 1942,WS,SLN,NL,NYA,AL,4,1,0 49 | 1943,WS,NYA,AL,SLN,NL,4,1,0 50 | 1944,WS,SLN,NL,SLA,AL,4,2,0 51 | 1945,WS,DET,AL,CHN,NL,4,3,0 52 | 1946,WS,SLN,NL,BOS,AL,4,3,0 53 | 1947,WS,NYA,AL,BRO,NL,4,3,0 54 | 1948,WS,CLE,AL,BSN,NL,4,2,0 55 | 1949,WS,NYA,AL,BRO,NL,4,1,0 56 | 1950,WS,NYA,AL,PHI,NL,4,0,0 57 | 1951,WS,NYA,AL,NY1,NL,4,2,0 58 | 1952,WS,NYA,AL,BRO,NL,4,3,0 59 | 1953,WS,NYA,AL,BRO,NL,4,2,0 60 | 1954,WS,NY1,NL,CLE,AL,4,0,0 61 | 1955,WS,BRO,NL,NYA,AL,4,3,0 62 | 1956,WS,NYA,AL,BRO,NL,4,3,0 63 | 1957,WS,ML1,NL,NYA,AL,4,3,0 64 | 1958,WS,NYA,AL,ML1,NL,4,3,0 65 | 1959,WS,LAN,NL,CHA,AL,4,2,0 66 | 1960,WS,PIT,NL,NYA,AL,4,3,0 67 | 1961,WS,NYA,AL,CIN,NL,4,1,0 68 | 1962,WS,NYA,AL,SFN,NL,4,3,0 69 | 1963,WS,LAN,NL,NYA,AL,4,0,0 70 | 1964,WS,SLN,NL,NYA,AL,4,3,0 71 | 1965,WS,LAN,NL,MIN,AL,4,3,0 72 | 1966,WS,BAL,AL,LAN,NL,4,0,0 73 | 1967,WS,SLN,NL,BOS,AL,4,3,0 74 | 1968,WS,DET,AL,SLN,NL,4,3,0 75 | 1969,ALCS,BAL,AL,MIN,AL,3,0,0 76 | 1969,NLCS,NYN,NL,ATL,NL,3,0,0 77 | 1969,WS,NYN,NL,BAL,AL,4,1,0 78 | 1970,ALCS,BAL,AL,MIN,AL,3,0,0 79 | 1970,NLCS,CIN,NL,PIT,NL,3,0,0 80 | 1970,WS,BAL,AL,CIN,NL,4,1,0 81 | 1971,ALCS,BAL,AL,OAK,AL,3,0,0 82 | 1971,NLCS,PIT,NL,SFN,NL,3,1,0 83 | 1971,WS,PIT,NL,BAL,AL,4,3,0 84 | 1972,ALCS,OAK,AL,DET,AL,3,2,0 85 | 1972,NLCS,CIN,NL,PIT,NL,3,2,0 86 | 1972,WS,OAK,AL,CIN,NL,4,3,0 87 | 1973,ALCS,OAK,AL,BAL,AL,3,2,0 88 | 1973,NLCS,NYN,NL,CIN,NL,3,2,0 89 | 1973,WS,OAK,AL,NYN,NL,4,3,0 90 | 1974,ALCS,OAK,AL,BAL,AL,3,1,0 91 | 1974,NLCS,LAN,NL,PIT,NL,3,1,0 92 | 1974,WS,OAK,AL,LAN,NL,4,1,0 93 | 1975,ALCS,BOS,AL,OAK,AL,3,0,0 94 | 1975,NLCS,CIN,NL,PIT,NL,3,0,0 95 | 1975,WS,CIN,NL,BOS,AL,4,3,0 96 | 1976,ALCS,NYA,AL,KCA,AL,3,2,0 97 | 1976,NLCS,CIN,NL,PHI,NL,3,0,0 98 | 1976,WS,CIN,NL,NYA,AL,4,0,0 99 | 1977,ALCS,NYA,AL,KCA,AL,3,2,0 100 | 1977,NLCS,LAN,NL,PHI,NL,3,1,0 101 | 1977,WS,NYA,AL,LAN,NL,4,2,0 102 | 1978,ALCS,NYA,AL,KCA,AL,3,1,0 103 | 1978,NLCS,LAN,NL,PHI,NL,3,1,0 104 | 1978,WS,NYA,AL,LAN,NL,4,2,0 105 | 1979,ALCS,BAL,AL,CAL,AL,3,1,0 106 | 1979,NLCS,PIT,NL,CIN,NL,3,0,0 107 | 1979,WS,PIT,NL,BAL,AL,4,3,0 108 | 1980,ALCS,KCA,AL,NYA,AL,3,0,0 109 | 1980,NLCS,PHI,NL,HOU,NL,3,2,0 110 | 1980,WS,PHI,NL,KCA,AL,4,2,0 111 | 1981,AEDIV,NYA,AL,ML4,AL,3,2,0 112 | 1981,ALCS,NYA,AL,OAK,AL,3,0,0 113 | 1981,AWDIV,OAK,AL,KCA,AL,3,0,0 114 | 1981,NEDIV,MON,NL,PHI,NL,3,2,0 115 | 1981,NLCS,LAN,NL,MON,NL,3,2,0 116 | 1981,NWDIV,LAN,NL,HOU,NL,3,2,0 117 | 1981,WS,LAN,NL,NYA,AL,4,2,0 118 | 1982,ALCS,ML4,AL,CAL,AL,3,2,0 119 | 1982,NLCS,SLN,NL,ATL,NL,3,0,0 120 | 1982,WS,SLN,NL,ML4,AL,4,3,0 121 | 1983,ALCS,BAL,AL,CHA,AL,3,1,0 122 | 1983,NLCS,PHI,NL,LAN,NL,3,1,0 123 | 1983,WS,BAL,AL,PHI,NL,4,1,0 124 | 1984,ALCS,DET,AL,KCA,AL,3,0,0 125 | 1984,NLCS,SDN,NL,CHN,NL,3,2,0 126 | 1984,WS,DET,AL,SDN,NL,4,1,0 127 | 1985,ALCS,KCA,AL,TOR,AL,4,3,0 128 | 1985,NLCS,SLN,NL,LAN,NL,4,2,0 129 | 1985,WS,KCA,AL,SLN,NL,4,3,0 130 | 1986,ALCS,BOS,AL,CAL,AL,4,3,0 131 | 1986,NLCS,NYN,NL,HOU,NL,4,2,0 132 | 1986,WS,NYN,NL,BOS,AL,4,3,0 133 | 1987,ALCS,MIN,AL,DET,AL,4,1,0 134 | 1987,NLCS,SLN,NL,SFN,NL,4,3,0 135 | 1987,WS,MIN,AL,SLN,NL,4,3,0 136 | 1988,ALCS,OAK,AL,BOS,AL,4,0,0 137 | 1988,NLCS,LAN,NL,NYN,NL,4,3,0 138 | 1988,WS,LAN,NL,OAK,AL,4,1,0 139 | 1989,ALCS,OAK,AL,TOR,AL,4,1,0 140 | 1989,NLCS,SFN,NL,CHN,NL,4,1,0 141 | 1989,WS,OAK,AL,SFN,NL,4,0,0 142 | 1990,ALCS,OAK,AL,BOS,AL,4,0,0 143 | 1990,NLCS,CIN,NL,PIT,NL,4,2,0 144 | 1990,WS,CIN,NL,OAK,AL,4,0,0 145 | 1991,ALCS,MIN,AL,TOR,AL,4,1,0 146 | 1991,NLCS,ATL,NL,PIT,NL,4,3,0 147 | 1991,WS,MIN,AL,ATL,NL,4,3,0 148 | 1992,ALCS,TOR,AL,OAK,AL,4,2,0 149 | 1992,NLCS,ATL,NL,PIT,NL,4,3,0 150 | 1992,WS,TOR,AL,ATL,NL,4,2,0 151 | 1993,ALCS,TOR,AL,CHA,AL,4,2,0 152 | 1993,NLCS,PHI,NL,ATL,NL,4,2,0 153 | 1993,WS,TOR,AL,PHI,NL,4,2,0 154 | 1995,ALCS,CLE,AL,SEA,AL,4,2,0 155 | 1995,ALDS1,CLE,AL,BOS,AL,3,0,0 156 | 1995,ALDS2,SEA,AL,NYA,AL,3,2,0 157 | 1995,NLCS,ATL,NL,CIN,NL,4,0,0 158 | 1995,NLDS1,ATL,NL,COL,NL,3,1,0 159 | 1995,NLDS2,CIN,NL,LAN,NL,3,0,0 160 | 1995,WS,ATL,NL,CLE,AL,4,2,0 161 | 1996,ALCS,NYA,AL,BAL,AL,4,1,0 162 | 1996,ALDS1,BAL,AL,CLE,AL,3,1,0 163 | 1996,ALDS2,NYA,AL,TEX,AL,3,1,0 164 | 1996,NLCS,ATL,NL,SLN,NL,4,3,0 165 | 1996,NLDS1,ATL,NL,LAN,NL,3,0,0 166 | 1996,NLDS2,SLN,NL,SDN,NL,3,0,0 167 | 1996,WS,NYA,AL,ATL,NL,4,2,0 168 | 1997,ALCS,CLE,AL,BAL,AL,4,2,0 169 | 1997,ALDS1,CLE,AL,NYA,AL,3,2,0 170 | 1997,ALDS2,BAL,AL,SEA,AL,3,1,0 171 | 1997,NLCS,FLO,NL,ATL,NL,4,2,0 172 | 1997,NLDS1,FLO,NL,SFN,NL,3,0,0 173 | 1997,NLDS2,ATL,NL,HOU,NL,3,0,0 174 | 1997,WS,FLO,NL,CLE,AL,4,3,0 175 | 1998,ALCS,NYA,AL,CLE,AL,4,2,0 176 | 1998,ALDS1,CLE,AL,BOS,AL,3,1,0 177 | 1998,ALDS2,NYA,AL,TEX,AL,3,0,0 178 | 1998,NLCS,SDN,NL,ATL,NL,4,2,0 179 | 1998,NLDS1,ATL,NL,CHN,NL,3,0,0 180 | 1998,NLDS2,SDN,NL,HOU,NL,3,1,0 181 | 1998,WS,NYA,AL,SDN,NL,4,0,0 182 | 1999,ALCS,NYA,AL,BOS,AL,4,1,0 183 | 1999,ALDS1,BOS,AL,CLE,AL,3,2,0 184 | 1999,ALDS2,NYA,AL,TEX,AL,3,0,0 185 | 1999,NLCS,ATL,NL,NYN,NL,4,2,0 186 | 1999,NLDS1,ATL,NL,HOU,NL,3,1,0 187 | 1999,NLDS2,NYN,NL,ARI,NL,3,1,0 188 | 1999,WS,NYA,AL,ATL,NL,4,0,0 189 | 2000,ALCS,NYA,AL,SEA,AL,4,2,0 190 | 2000,ALDS1,NYA,AL,OAK,AL,3,2,0 191 | 2000,ALDS2,SEA,AL,CHA,AL,3,0,0 192 | 2000,NLCS,NYN,NL,SLN,NL,4,1,0 193 | 2000,NLDS1,SLN,NL,ATL,NL,3,0,0 194 | 2000,NLDS2,NYN,NL,SFN,NL,3,1,0 195 | 2000,WS,NYA,AL,NYN,NL,4,1,0 196 | 2001,ALCS,NYA,AL,SEA,AL,4,1,0 197 | 2001,ALDS1,SEA,AL,CLE,AL,3,2,0 198 | 2001,ALDS2,NYA,AL,OAK,AL,3,2,0 199 | 2001,NLCS,ARI,NL,ATL,NL,4,1,0 200 | 2001,NLDS1,ATL,NL,HOU,NL,3,0,0 201 | 2001,NLDS2,ARI,NL,SLN,NL,3,2,0 202 | 2001,WS,ARI,NL,NYA,AL,4,3,0 203 | 2002,ALCS,ANA,AL,MIN,AL,4,1,0 204 | 2002,ALDS1,ANA,AL,NYA,AL,3,1,0 205 | 2002,ALDS2,MIN,AL,OAK,AL,3,2,0 206 | 2002,NLCS,SFN,NL,SLN,NL,4,1,0 207 | 2002,NLDS1,SFN,NL,ATL,NL,3,2,0 208 | 2002,NLDS2,SLN,NL,ARI,NL,3,0,0 209 | 2002,WS,ANA,AL,SFN,NL,4,3,0 210 | 2003,ALCS,NYA,AL,BOS,AL,4,3,0 211 | 2003,ALDS1,NYA,AL,MIN,AL,3,1,0 212 | 2003,ALDS2,BOS,AL,OAK,AL,3,2,0 213 | 2003,NLCS,FLO,NL,CHN,NL,4,3,0 214 | 2003,NLDS1,FLO,NL,SFN,NL,3,1,0 215 | 2003,NLDS2,CHN,NL,ATL,NL,3,2,0 216 | 2003,WS,FLO,NL,NYA,AL,4,2,0 217 | 2004,ALCS,BOS,AL,NYA,AL,4,3,0 218 | 2004,ALDS1,BOS,AL,ANA,AL,3,0,0 219 | 2004,ALDS2,NYA,AL,MIN,AL,3,1,0 220 | 2004,NLCS,SLN,NL,HOU,NL,4,3,0 221 | 2004,NLDS1,SLN,NL,LAN,NL,3,1,0 222 | 2004,NLDS2,HOU,NL,ATL,NL,3,2,0 223 | 2004,WS,BOS,AL,SLN,NL,4,0,0 224 | 2005,ALCS,CHA,AL,LAA,AL,4,1,0 225 | 2005,ALDS1,CHA,AL,BOS,AL,3,0,0 226 | 2005,ALDS2,LAA,AL,NYA,AL,3,2,0 227 | 2005,NLCS,HOU,NL,SLN,NL,4,2,0 228 | 2005,NLDS1,SLN,NL,SDN,NL,3,0,0 229 | 2005,NLDS2,HOU,NL,ATL,NL,3,1,0 230 | 2005,WS,CHA,AL,HOU,NL,4,0,0 231 | 2006,ALCS,DET,AL,OAK,AL,4,0,0 232 | 2006,ALDS1,DET,AL,NYA,AL,3,1,0 233 | 2006,ALDS2,OAK,AL,MIN,AL,3,0,0 234 | 2006,NLCS,SLN,NL,NYN,NL,4,3,0 235 | 2006,NLDS1,NYN,NL,LAN,NL,3,0,0 236 | 2006,NLDS2,SLN,NL,SDN,NL,3,1,0 237 | 2006,WS,SLN,NL,DET,AL,4,1,0 238 | 2007,ALCS,BOS,AL,CLE,AL,4,3,0 239 | 2007,ALDS1,BOS,AL,LAA,AL,3,0,0 240 | 2007,ALDS2,CLE,AL,NYA,AL,3,1,0 241 | 2007,NLCS,COL,NL,ARI,NL,4,0,0 242 | 2007,NLDS1,ARI,NL,CHN,NL,3,0,0 243 | 2007,NLDS2,COL,NL,PHI,NL,3,0,0 244 | 2007,WS,BOS,AL,COL,NL,4,0,0 245 | 2008,ALCS,TBA,AL,BOS,AL,4,3,0 246 | 2008,ALDS1,BOS,AL,LAA,AL,3,1,0 247 | 2008,ALDS2,TBA,AL,CHA,AL,3,1,0 248 | 2008,NLCS,PHI,NL,LAN,NL,4,1,0 249 | 2008,NLDS1,LAN,NL,CHN,NL,3,0,0 250 | 2008,NLDS2,PHI,NL,MIL,NL,3,1,0 251 | 2008,WS,PHI,NL,TBA,AL,4,1,0 252 | 2009,ALCS,NYA,AL,LAA,AL,4,2,0 253 | 2009,ALDS1,NYA,AL,MIN,AL,3,0,0 254 | 2009,ALDS2,LAA,AL,BOS,AL,3,0,0 255 | 2009,NLCS,PHI,NL,LAN,NL,4,1,0 256 | 2009,NLDS1,LAN,NL,SLN,NL,3,0,0 257 | 2009,NLDS2,PHI,NL,COL,NL,3,1,0 258 | 2009,WS,NYA,AL,PHI,NL,4,2,0 259 | 2010,ALCS,TEX,AL,NYA,AL,4,2,0 260 | 2010,ALDS1,TEX,AL,TBA,AL,3,2,0 261 | 2010,ALDS2,NYA,AL,MIN,AL,3,0,0 262 | 2010,NLCS,SFN,NL,PHI,NL,4,2,0 263 | 2010,NLDS1,PHI,NL,CIN,NL,3,0,0 264 | 2010,NLDS2,SFN,NL,ATL,NL,3,1,0 265 | 2010,WS,SFN,NL,TEX,AL,4,1,0 266 | 2011,ALCS,TEX,AL,DET,AL,4,2,0 267 | 2011,ALDS1,DET,AL,NYA,AL,3,2,0 268 | 2011,ALDS2,TEX,AL,TBA,AL,3,1,0 269 | 2011,NLCS,SLN,NL,MIL,NL,4,2,0 270 | 2011,NLDS1,SLN,NL,PHI,NL,3,2,0 271 | 2011,NLDS2,MIL,NL,ARI,NL,3,2,0 272 | 2011,WS,SLN,NL,TEX,AL,4,3,0 273 | 2012,ALWC,BAL,AL,TEX,AL,1,0,0 274 | 2012,ALCS,DET,AL,NYA,AL,4,0,0 275 | 2012,ALDS1,NYA,AL,BAL,AL,3,2,0 276 | 2012,ALDS2,DET,AL,OAK,AL,3,2,0 277 | 2012,NLWC,SLN,NL,ATL,NL,1,0,0 278 | 2012,NLCS,SFN,NL,SLN,NL,4,3,0 279 | 2012,NLDS1,SLN,NL,WAS,NL,3,2,0 280 | 2012,NLDS2,SFN,NL,CIN,NL,3,2,0 281 | 2012,WS,SFN,NL,DET,AL,4,0,0 282 | 2013,ALWC,TBA,AL,CLE,AL,1,0,0 283 | 2013,ALCS,BOS,AL,DET,AL,4,2,0 284 | 2013,ALDS1,BOS,AL,TBA,AL,3,1,0 285 | 2013,ALDS2,DET,AL,OAK,AL,3,2,0 286 | 2013,NLWC,PIT,NL,CIN,NL,1,0,0 287 | 2013,NLCS,SLN,NL,LAN,NL,4,2,0 288 | 2013,NLDS1,SLN,NL,PIT,NL,3,2,0 289 | 2013,NLDS2,LAN,NL,ATL,NL,3,1,0 290 | 2013,WS,BOS,AL,SLN,NL,4,3,0 291 | 2014,ALWC,KCA,AL,OAK,AL,1,0,0 292 | 2014,ALCS,KCA,AL,BAL,AL,4,0,0 293 | 2014,ALDS1,KCA,AL,LAA,AL,3,0,0 294 | 2014,ALDS2,BAL,AL,DET,AL,3,0,0 295 | 2014,NLWC,SFN,NL,PIT,NL,1,0,0 296 | 2014,NLCS,SFN,NL,SLN,NL,4,1,0 297 | 2014,NLDS1,SFN,NL,WAS,NL,3,1,0 298 | 2014,NLDS2,SLN,NL,LAN,NL,3,1,0 299 | 2014,WS,SFN,NL,KCA,AL,4,3,0 300 | 2015,ALWC,HOU,AL,NYA,AL,1,0,0 301 | 2015,ALCS,KCA,AL,TOR,AL,4,2,0 302 | 2015,ALDS1,KCA,AL,HOU,AL,3,2,0 303 | 2015,ALDS2,TOR,AL,TEX,AL,3,2,0 304 | 2015,NLWC,CHN,NL,PIT,NL,1,0,0 305 | 2015,NLCS,NYN,NL,CHN,NL,4,0,0 306 | 2015,NLDS1,CHN,NL,SLN,NL,3,1,0 307 | 2015,NLDS2,NYN,NL,LAN,NL,3,2,0 308 | 2015,WS,KCA,AL,NYN,NL,4,1,0 309 | 2016,ALWC,TOR,AL,BAL,AL,1,0,0 310 | 2016,ALCS,CLE,AL,TOR,AL,4,1,0 311 | 2016,ALDS1,TOR,AL,TEX,AL,3,0,0 312 | 2016,ALDS2,CLE,AL,BOS,AL,3,0,0 313 | 2016,NLWC,SFN,NL,NYN,NL,1,0,0 314 | 2016,NLCS,CHN,NL,LAN,NL,4,2,0 315 | 2016,NLDS1,CHN,NL,SFN,NL,3,1,0 316 | 2016,NLDS2,LAN,NL,WAS,NL,3,2,0 317 | 2016,WS,CHN,NL,CLE,AL,4,3,0 318 | 2017,ALWC,NYA,AL,MIN,AL,1,0,0 319 | 2017,ALCS,HOU,AL,NYA,AL,4,3,0 320 | 2017,ALDS1,NYA,AL,CLE,AL,3,2,0 321 | 2017,ALDS2,HOU,AL,BOS,AL,3,1,0 322 | 2017,NLWC,ARI,NL,COL,NL,1,0,0 323 | 2017,NLCS,LAN,NL,CHN,NL,4,1,0 324 | 2017,NLDS1,LAN,NL,ARI,NL,3,0,0 325 | 2017,NLDS2,CHN,NL,WAS,NL,3,2,0 326 | 2017,WS,HOU,AL,LAN,NL,4,3,0 327 | 2018,ALWC,NYA,AL,OAK,AL,1,0,0 328 | 2018,ALCS,BOS,AL,HOU,AL,4,1,0 329 | 2018,ALDS1,BOS,AL,NYA,AL,3,1,0 330 | 2018,ALDS2,HOU,AL,CLE,AL,3,0,0 331 | 2018,NLWC,COL,NL,CHN,NL,1,0,0 332 | 2018,NLCS,LAN,NL,MIL,NL,4,3,0 333 | 2018,NLDS1,MIL,NL,COL,NL,3,0,0 334 | 2018,NLDS2,LAN,NL,ATL,NL,3,1,0 335 | 2018,WS,BOS,AL,LAN,NL,4,1,0 336 | -------------------------------------------------------------------------------- /baseballdatabank-csv/csv-files/Parks.csv: -------------------------------------------------------------------------------- 1 | park.key,park.name,park.alias,city,state,country 2 | ALB01,Riverside Park,,Albany,NY,US 3 | ALT01,Columbia Park,,Altoona,PA,US 4 | ANA01,Angel Stadium of Anaheim,Edison Field; Anaheim Stadium,Anaheim,CA,US 5 | ARL01,Arlington Stadium,,Arlington,TX,US 6 | ARL02,Rangers Ballpark in Arlington,The Ballpark in Arlington; Ameriquest Fl,Arlington,TX,US 7 | ATL01,Atlanta-Fulton County Stadium,,Atlanta,GA,US 8 | ATL02,Turner Field,,Atlanta,GA,US 9 | ATL03,Suntrust Park,,Atlanta,GA,US 10 | BAL01,Madison Avenue Grounds,,Baltimore,MD,US 11 | BAL02,Newington Park,,Baltimore,MD,US 12 | BAL03,Oriole Park I,,Baltimore,MD,US 13 | BAL04,Belair Lot,,Baltimore,MD,US 14 | BAL05,Monumental Park,,Baltimore,MD,US 15 | BAL06,Oriole Park II,,Baltimore,MD,US 16 | BAL07,Oriole Park III,,Baltimore,MD,US 17 | BAL09,Oriole Park IV,American League Park,Baltimore,MD,US 18 | BAL10,Terrapin Park,Oriole Park V,Baltimore,MD,US 19 | BAL11,Memorial Stadium,,Baltimore,MD,US 20 | BAL12,Oriole Park at Camden Yards,,Baltimore,MD,US 21 | BOS01,South End Grounds I,Walpole Street Grounds,Boston,MA,US 22 | BOS02,Dartmouth Grounds,Union Park,Boston,MA,US 23 | BOS03,South End Grounds II,,Boston,MA,US 24 | BOS04,Congress Street Grounds,,Boston,MA,US 25 | BOS05,South End Grounds III,,Boston,MA,US 26 | BOS06,Huntington Avenue Baseball Grounds,,Boston,MA,US 27 | BOS07,Fenway Park,,Boston,MA,US 28 | BOS08,Braves Field,Bee Hive,Boston,MA,US 29 | BUF01,Riverside Grounds,,Buffalo,NY,US 30 | BUF02,Olympic Park I,,Buffalo,NY,US 31 | BUF03,Olympic Park II,,Buffalo,NY,US 32 | BUF04,International Fair Association Grounds,Federal League Park,Buffalo,NY,US 33 | CAN01,Mahaffey Park,Pastime Park,Canton,OH,US 34 | CAN02,Pastime Park,,Canton,OH,US 35 | CHI01,Lake Front Park I,Union Base-ball Grounds,Chicago,IL,US 36 | CHI02,23rd Street Park,,Chicago,IL,US 37 | CHI03,Lake Front Park II,,Chicago,IL,US 38 | CHI05,South Side Park I,Cricket Club Grounds; Union Grounds,Chicago,IL,US 39 | CHI06,West Side Park,,Chicago,IL,US 40 | CHI07,South Side Park II,,Chicago,IL,US 41 | CHI08,West Side Grounds,,Chicago,IL,US 42 | CHI09,South Side Park III,,Chicago,IL,US 43 | CHI10,Comiskey Park I,White Sox Park,Chicago,IL,US 44 | CHI11,Wrigley Field,Weeghman Park; Cubs Park,Chicago,IL,US 45 | CHI12,U.S. Cellular Field,White Sox Park; Comiskey Park II,Chicago,IL,US 46 | CIN01,Lincoln Park Grounds,Union Cricket Club Grounds,Cincinnati,OH,US 47 | CIN02,Avenue Grounds,,Cincinnati,OH,US 48 | CIN03,Bank Street Grounds,,Cincinnati,OH,US 49 | CIN04,League Park I,,Cincinnati,OH,US 50 | CIN05,League Park II,,Cincinnati,OH,US 51 | CIN06,Palace of the Fans,League Park III,Cincinnati,OH,US 52 | CIN07,Crosley Field,Redland Field,Cincinnati,OH,US 53 | CIN08,Cinergy Field,Riverfront Stadium,Cincinnati,OH,US 54 | CIN09,Great American Ballpark,,Cincinnati,OH,US 55 | CLE01,National Association Grounds,,Cleveland,OH,US 56 | CLE02,League Park I,Kennard Street Park,Cleveland,OH,US 57 | CLE03,League Park II,American Association Park,Cleveland,OH,US 58 | CLE04,Brotherhood Park,Players League Park,Cleveland,OH,US 59 | CLE05,League Park III,National League Park III,Cleveland,OH,US 60 | CLE06,League Park IV,Dunn Field,Cleveland,OH,US 61 | CLE07,Cleveland Stadium,Municipal Stadium,Cleveland,OH,US 62 | CLE08,Progressive Field,Jacobs Field,Cleveland,OH,US 63 | CLE09,Cedar Avenue Driving Park,,Cleveland,OH,US 64 | CLL01,Euclid Beach Park,,Collinwood,OH,US 65 | COL01,Recreation Park I,,Columbus,OH,US 66 | COL02,Recreation Park II,,Columbus,OH,US 67 | COL03,Neil Park I,,Columbus,OH,US 68 | COL04,Neil Park II,,Columbus,OH,US 69 | COV01,Star Baseball Park,,Covington,KY,US 70 | DAY01,Fairview Park,,Dayton,OH,US 71 | DEN01,Mile High Stadium,,Denver,CO,US 72 | DEN02,Coors Field,,Denver,CO,US 73 | DET01,Recreation Park,,Detroit,MI,US 74 | DET02,Bennett Park,,Detroit,MI,US 75 | DET03,Burns Park,West End Park,Detroit,MI,US 76 | DET04,Tiger Stadium,Navin Field; Briggs Stadium,Detroit,MI,US 77 | DET05,Comerica Park,,Detroit,MI,US 78 | DOV01,Fairview Park Fair Grounds,,Dover,DE,US 79 | ELM01,Maple Avenue Driving Park,,Elmira,NY,US 80 | FOR01,Grand Duchess,Hamilton Field,Fort Wayne,IN,US 81 | FOR03,Jailhouse Flats,,Fort Wayne,IN,US 82 | FTB01,Fort Bragg Field,,Fort Bragg,NC,US 83 | GEA01,Geauga Lake Grounds,Beyerle's Park,Geauga Lake,OH,US 84 | GLO01,Gloucester Point Grounds,,Gloucester City,NJ,US 85 | GRA01,Ramona Park,,Grand Rapids,MI,US 86 | HAR01,Harrison Field,,Harrison,NJ,US 87 | HOB01,Elysian Field,,Hoboken,NJ,US 88 | HON01,Aloha Stadium,,Honolulu,HI,US 89 | HOU01,Colt Stadium,,Houston,TX,US 90 | HOU02,Astrodome,,Houston,TX,US 91 | HOU03,Minute Maid Park,Enron Field; Astros Field,Houston,TX,US 92 | HRT01,Hartford Ball Club Grounds,,Hartford,CT,US 93 | HRT02,Hartford Trotting Park,,Hartford,CT,US 94 | IND01,South Street Park,,Indianapolis,IN,US 95 | IND02,Seventh Street Park I,,Indianapolis,IN,US 96 | IND03,Bruce Grounds,,Indianapolis,IN,US 97 | IND04,Seventh Street Park II,,Indianapolis,IN,US 98 | IND05,Seventh Street Park III,,Indianapolis,IN,US 99 | IND06,Indianapolis Park,,Indianapolis,IN,US 100 | IND07,Federal League Park,Washington Park,Indianapolis,IN,US 101 | IRO01,Windsor Beach,,Irondequoit,NY,US 102 | JER01,Oakdale Park,,Jersey City,NJ,US 103 | JER02,Roosevelt Stadium,,Jersey City,NJ,US 104 | KAN01,Athletic Park,,Kansas City,MO,US 105 | KAN02,Association Park,,Kansas City,MO,US 106 | KAN03,Exposition Park,,Kansas City,MO,US 107 | KAN04,Gordon and Koppel Field,,Kansas City,MO,US 108 | KAN05,Municipal Stadium,,Kansas City,MO,US 109 | KAN06,Kauffman Stadium,Royals Stadium,Kansas City,MO,US 110 | KEO01,Perry Park,Walte's Pasture,Keokuk,IA,US 111 | LAS01,Cashman Field,,Las Vegas,NV,US 112 | LBV01,The Ballpark at Disney's Wide World,,Lake Buena Vista,FL,US 113 | LOS01,Los Angeles Memorial Coliseum,,Los Angeles,CA,US 114 | LOS02,Wrigley Field,,Los Angeles,CA,US 115 | LOS03,Dodger Stadium,Chavez Ravine,Los Angeles,CA,US 116 | LOU01,Louisville Baseball Park,,Louisville,KY,US 117 | LOU02,Eclipse Park I,,Louisville,KY,US 118 | LOU03,Eclipse Park II,,Louisville,KY,US 119 | LOU04,Eclipse Park III,,Louisville,KY,US 120 | LUD01,Ludlow Baseball Park,,Ludlow,KY,US 121 | MAS01,Long Island Grounds,,Maspeth,NY,US 122 | MIA01,Sun Life Stadium,JoeRobbie; ProPlayer; Dolphin; LandShark,Miami,FL,US 123 | MIA02,Marlins Park,,Miami,FL,US 124 | MID01,Mansfield Club Grounds,,Middletown,CT,US 125 | MIL01,Milwaukee Base-Ball Grounds,,Milwaukee,WI,US 126 | MIL02,Wright Street Grounds,,Milwaukee,WI,US 127 | MIL03,Athletic Park,,Milwaukee,WI,US 128 | MIL04,Lloyd Street Grounds,,Milwaukee,WI,US 129 | MIL05,County Stadium,,Milwaukee,WI,US 130 | MIL06,Miller Park,,Milwaukee,WI,US 131 | MIN01,Athletic Park,,Minneapolis,MN,US 132 | MIN02,Metropolitan Stadium,,Bloomington,MN,US 133 | MIN03,Hubert H. Humphrey Metrodome,,Minneapolis,MN,US 134 | MIN04,Target Field,,Minneapolis,MN,US 135 | MNT01,Estadio Monterrey,,Monterrey,Nuevo Leon,MX 136 | MON01,Parc Jarry,Jarry Park,Montreal,QC,CA 137 | MON02,Stade Olympique,Olympic Stadium,Montreal,QC,CA 138 | NEW01,Howard Avenue Grounds,Brewster Park,New Haven,CT,US 139 | NEW02,Hamilton Park,,New Haven,CT,US 140 | NEW03,Geauga Lake Grounds,Beyerle's Park,Geauga Lake,OH,US 141 | NWK01,Wiedenmeyer's Park,,Newark,NJ,US 142 | NYC01,Union Grounds,,Brooklyn,NY,US 143 | NYC02,Capitoline Grounds,,Brooklyn,NY,US 144 | NYC03,Polo Grounds I (Southeast Diamond),,New York,NY,US 145 | NYC04,Polo Grounds II (Southwest Diamond),,New York,NY,US 146 | NYC05,Washington Park I,,Brooklyn,NY,US 147 | NYC06,Metropolitan Park,,New York,NY,US 148 | NYC07,Grauer's Ridgewood Park,Ridgewood Park I,Queens,NY,US 149 | NYC08,Washington Park II,,Brooklyn,NY,US 150 | NYC09,Polo Grounds III,,New York,NY,US 151 | NYC10,Polo Grounds IV,,New York,NY,US 152 | NYC11,Eastern Park,,Brooklyn,NY,US 153 | NYC12,Washington Park III,,Brooklyn,NY,US 154 | NYC13,Hilltop Park,,New York,NY,US 155 | NYC14,Polo Grounds V,,New York,NY,US 156 | NYC15,Ebbets Field,,Brooklyn,NY,US 157 | NYC16,Yankee Stadium I,,New York,NY,US 158 | NYC17,Shea Stadium,William A. Shea Stadium,New York,NY,US 159 | NYC18,Wallace's Ridgewood Park,Ridgewood Park II,Queens,NY,US 160 | NYC19,Washington Park IV,,Brooklyn,NY,US 161 | NYC20,Citi Field,,New York,NY,US 162 | NYC21,Yankee Stadium II,,New York,NY,US 163 | OAK01,Oakland-Alameda County Coliseum,Network Associates Coliseum,Oakland,CA,US 164 | PEN01,East End Park,Pendleton Park,Cincinnati,OH,US 165 | PHI01,Jefferson Street Grounds,Athletics Park,Philadelphia,PA,US 166 | PHI02,Centennial Park,,Philadelphia,PA,US 167 | PHI03,Oakdale Park,,Philadelphia,PA,US 168 | PHI04,Recreation Park,,Philadelphia,PA,US 169 | PHI05,Keystone Park,,Philadelphia,PA,US 170 | PHI06,Huntingdon Grounds I,,Philadelphia,PA,US 171 | PHI07,Forepaugh Park,,Philadelphia,PA,US 172 | PHI08,University of Penn. Athletic Field,,Philadelphia,PA,US 173 | PHI09,Baker Bowl,,Philadelphia,PA,US 174 | PHI10,Columbia Park,,Philadelphia,PA,US 175 | PHI11,Shibe Park,Connie Mack Stadium,Philadelphia,PA,US 176 | PHI12,Veterans Stadium,,Philadelphia,PA,US 177 | PHI13,Citizens Bank Park,,Philadelphia,PA,US 178 | PHI14,Huntingdon Grounds II,,Philadelphia,PA,US 179 | PHO01,Chase Field,Bank One Ballpark,Phoenix,AZ,US 180 | PIT01,Union Park,,Pittsburgh,PA,US 181 | PIT02,Exposition Park I,Lower Field,Pittsburgh,PA,US 182 | PIT03,Exposition Park II,Upper Field,Pittsburgh,PA,US 183 | PIT04,Recreation Park,,Pittsburgh,PA,US 184 | PIT05,Exposition Park III,,Pittsburgh,PA,US 185 | PIT06,Forbes Field,,Pittsburgh,PA,US 186 | PIT07,Three Rivers Stadium,,Pittsburgh,PA,US 187 | PIT08,PNC Park,,Pittsburgh,PA,US 188 | PRO01,Adelaide Avenue Grounds,,Providence,RI,US 189 | PRO02,Messer Street Grounds,,Providence,RI,US 190 | RCK01,Agricultural Society Fair Grounds,,Rockford,IL,US 191 | RIC01,Richmond Fair Grounds,,Richmond,VA,US 192 | RIC02,Allens Pasture,,Richmond,VA,US 193 | ROC01,Culver Field I,,Rochester,NY,US 194 | ROC02,Culver Field II,,Rochester,NY,US 195 | ROC03,Ontario Beach Grounds,,Rochester,NY,US 196 | SAI01,St. George Cricket Grounds,,New York,NY,US 197 | SAN01,Qualcomm Stadium,San Diego/Jack Murphy Stadium,San Diego,CA,US 198 | SAN02,PETCO Park,,San Diego,CA,US 199 | SEA01,Sick's Stadium,,Seattle,WA,US 200 | SEA02,Kingdome,,Seattle,WA,US 201 | SEA03,Safeco Field,,Seattle,WA,US 202 | SFO01,Seals Stadium,,San Francisco,CA,US 203 | SFO02,Candlestick Park,3Com Park,San Francisco,CA,US 204 | SFO03,AT&T Park,Pacific Bell Park; SBC Park,San Francisco,CA,US 205 | SJU01,Estadio Hiram Bithorn,,San Juan,,PR 206 | SPR01,Hampden Park Race Track,Springfield Track,Springfield,MA,US 207 | STL01,Red Stockings Base Ball Park,,St. Louis,MO,US 208 | STL02,Grand Avenue Park,,St. Louis,MO,US 209 | STL03,Sportsman's Park I,,St. Louis,MO,US 210 | STL04,Union Grounds,,St. Louis,MO,US 211 | STL05,Robison Field,,St. Louis,MO,US 212 | STL06,Sportsman's Park II,,St. Louis,MO,US 213 | STL07,Sportsman's Park III,Busch Stadium I,St. Louis,MO,US 214 | STL08,Handlan's Park,Federal League Park,St. Louis,MO,US 215 | STL09,Busch Stadium II,,St. Louis,MO,US 216 | STL10,Busch Stadium III,,St. Louis,MO,US 217 | STP01,Tropicana Field,,St. Petersburg,FL,US 218 | SYD01,Sydney Cricket Ground,,Sydney,New South Wales,AU 219 | SYR01,Star Park I,Newell Park,Syracuse,NY,US 220 | SYR02,Star Park II,,Syracuse,NY,US 221 | SYR03,Iron Pier,,Syracuse,NY,US 222 | THR01,Three Rivers Park,,Three Rivers,NY,US 223 | TOK01,Tokyo Dome,,Tokyo,Tokyo,JP 224 | TOL01,League Park,,Toledo,OH,US 225 | TOL02,Tri-State Fair Grounds,,Toledo,OH,US 226 | TOL03,Speranza Park,,Toledo,OH,US 227 | TOL04,Armory Park,,Toledo,OH,US 228 | TOR01,Exhibition Stadium,,Toronto,ON,CA 229 | TOR02,Rogers Centre,Skydome,Toronto,ON,CA 230 | TRO01,Haymakers' Grounds,,Troy,NY,US 231 | TRO02,Putnam Grounds,,Troy,NY,US 232 | WAR01,Rocky Point Park,,Warwick,RI,US 233 | WAS01,Olympic Grounds,,Washington,DC,US 234 | WAS02,National Grounds,,Washington,DC,US 235 | WAS03,Capitol Grounds,,Washington,DC,US 236 | WAS04,Athletic Park,,Washington,DC,US 237 | WAS05,Swampoodle Grounds,,Washington,DC,US 238 | WAS06,Boundary Field,,Washington,DC,US 239 | WAS07,American League Park I,,Washington,DC,US 240 | WAS08,American League Park II,,Washington,DC,US 241 | WAS09,Griffith Stadium,,Washington,DC,US 242 | WAS10,Robert F. Kennedy Stadium,D.C. Stadium,Washington,DC,US 243 | WAS11,Nationals Park,,Washington,DC,US 244 | WAT01,Troy Ball Club Grounds,,Watervliet,NY,US 245 | WAV01,Waverly Fairgrounds,,Waverly,NJ,US 246 | WEE01,Monitor Grounds,,Weehawken,NJ,US 247 | WHE01,Island Grounds,,Wheeling,WV,US 248 | WIL01,Union Street Park,,Wilmington,DE,US 249 | WIL02,BB&T Ballpark at Bowman Field,,Williamsport,PA,US 250 | WNY01,West New York Field Club Grounds,,West New York,NJ,US 251 | WOR01,Agricultural County Fair Grounds I,,Worcester,MA,US 252 | WOR02,Agricultural County Fair Grounds II,,Worcester,MA,US 253 | WOR03,Worcester Driving Park Grounds,,Worcester,MA,US 254 | -------------------------------------------------------------------------------- /baseball-database/lahmansbaseballdb-backup/lahmansbaseballdb_awardsmanagers.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `lahmansbaseballdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; 2 | USE `lahmansbaseballdb`; 3 | -- MySQL dump 10.13 Distrib 8.0.17, for Win64 (x86_64) 4 | -- 5 | -- Host: localhost Database: lahmansbaseballdb 6 | -- ------------------------------------------------------ 7 | -- Server version 8.0.17 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!50503 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Table structure for table `awardsmanagers` 22 | -- 23 | 24 | DROP TABLE IF EXISTS `awardsmanagers`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | /*!50503 SET character_set_client = utf8mb4 */; 27 | CREATE TABLE `awardsmanagers` ( 28 | `playerID` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, 29 | `awardID` varchar(75) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, 30 | `yearID` smallint(6) NOT NULL, 31 | `lgID` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, 32 | `tie` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 33 | `notes` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 34 | PRIMARY KEY (`playerID`,`awardID`,`yearID`,`lgID`) 35 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 36 | /*!40101 SET character_set_client = @saved_cs_client */; 37 | 38 | -- 39 | -- Dumping data for table `awardsmanagers` 40 | -- 41 | 42 | LOCK TABLES `awardsmanagers` WRITE; 43 | /*!40000 ALTER TABLE `awardsmanagers` DISABLE KEYS */; 44 | INSERT INTO `awardsmanagers` VALUES ('aloufe01','BBWAA Manager of the Year',1994,'NL',NULL,NULL),('aloufe01','TSN Manager of the Year',1994,'NL',NULL,NULL),('alstowa01','TSN Manager of the Year',1955,'ML',NULL,NULL),('alstowa01','TSN Manager of the Year',1959,'ML',NULL,NULL),('alstowa01','TSN Manager of the Year',1963,'ML',NULL,NULL),('andersp01','BBWAA Manager of the Year',1984,'AL',NULL,NULL),('andersp01','BBWAA Manager of the Year',1987,'AL',NULL,NULL),('andersp01','TSN Manager of the Year',1987,'AL',NULL,NULL),('bakerdu01','BBWAA Manager of the Year',1993,'NL',NULL,NULL),('bakerdu01','BBWAA Manager of the Year',1997,'NL',NULL,NULL),('bakerdu01','BBWAA Manager of the Year',2000,'NL',NULL,NULL),('bakerdu01','TSN Manager of the Year',1997,'NL',NULL,NULL),('bakerdu01','TSN Manager of the Year',2000,'NL',NULL,NULL),('bambege01','TSN Manager of the Year',1978,'ML',NULL,NULL),('banisje01','BBWAA Manager of the Year',2015,'AL',NULL,NULL),('bauerha01','TSN Manager of the Year',1966,'ML',NULL,NULL),('baylodo01','BBWAA Manager of the Year',1995,'NL',NULL,NULL),('baylodo01','TSN Manager of the Year',1995,'NL',NULL,NULL),('blackbu02','BBWAA Manager of the Year',2010,'NL',NULL,NULL),('blackbu02','TSN Manager of the Year',2010,'NL',NULL,NULL),('bluegos01','TSN Manager of the Year',1945,'ML',NULL,NULL),('bochybr01','BBWAA Manager of the Year',1996,'NL',NULL,NULL),('bochybr01','TSN Manager of the Year',1996,'NL',NULL,NULL),('bochybr01','TSN Manager of the Year',1998,'NL',NULL,NULL),('bowala01','BBWAA Manager of the Year',2001,'NL',NULL,NULL),('bowala01','TSN Manager of the Year',2001,'NL',NULL,NULL),('collite99','TSN Manager of the Year',2015,'NL',NULL,NULL),('coxbo01','BBWAA Manager of the Year',1985,'AL',NULL,NULL),('coxbo01','BBWAA Manager of the Year',1991,'NL',NULL,NULL),('coxbo01','BBWAA Manager of the Year',2004,'NL',NULL,NULL),('coxbo01','BBWAA Manager of the Year',2005,'NL',NULL,NULL),('coxbo01','TSN Manager of the Year',1985,'ML',NULL,NULL),('coxbo01','TSN Manager of the Year',1991,'NL',NULL,NULL),('coxbo01','TSN Manager of the Year',1993,'NL',NULL,NULL),('coxbo01','TSN Manager of the Year',1999,'NL',NULL,NULL),('coxbo01','TSN Manager of the Year',2002,'NL',NULL,NULL),('coxbo01','TSN Manager of the Year',2003,'NL',NULL,NULL),('coxbo01','TSN Manager of the Year',2004,'NL',NULL,NULL),('coxbo01','TSN Manager of the Year',2005,'NL',NULL,NULL),('dierkla01','BBWAA Manager of the Year',1998,'NL',NULL,NULL),('durocle01','TSN Manager of the Year',1939,'ML',NULL,NULL),('durocle01','TSN Manager of the Year',1951,'ML',NULL,NULL),('durocle01','TSN Manager of the Year',1954,'ML',NULL,NULL),('dyered01','TSN Manager of the Year',1946,'ML',NULL,NULL),('farrejo03','TSN Manager of the Year',2013,'AL',NULL,NULL),('foxch01','TSN Manager of the Year',1971,'ML',NULL,NULL),('francte01','BBWAA Manager of the Year',2013,'AL',NULL,NULL),('francte01','BBWAA Manager of the Year',2016,'AL',NULL,' '),('freyji99','BBWAA Manager of the Year',1984,'NL',NULL,NULL),('freyji99','TSN Manager of the Year',1984,'ML',NULL,NULL),('gardero01','BBWAA Manager of the Year',2010,'AL',NULL,NULL),('gardero01','TSN Manager of the Year',2004,'AL',NULL,NULL),('gardero01','TSN Manager of the Year',2010,'AL',NULL,NULL),('gibsoki01','BBWAA Manager of the Year',2011,'NL',NULL,NULL),('gibsoki01','TSN Manager of the Year',2011,'NL',NULL,NULL),('girarjo01','BBWAA Manager of the Year',2006,'NL',NULL,NULL),('girarjo01','TSN Manager of the Year',2006,'NL',NULL,NULL),('gonzafr99','TSN Manager of the Year',2008,'NL',NULL,NULL),('guilloz01','BBWAA Manager of the Year',2005,'AL',NULL,NULL),('guilloz01','TSN Manager of the Year',2005,'AL',NULL,NULL),('hargrmi01','TSN Manager of the Year',1995,'AL',NULL,NULL),('harribu01','TSN Manager of the Year',1947,'ML',NULL,NULL),('herzowh01','BBWAA Manager of the Year',1985,'NL',NULL,NULL),('herzowh01','TSN Manager of the Year',1982,'ML',NULL,NULL),('hodgegi01','TSN Manager of the Year',1969,'ML',NULL,NULL),('houkra01','TSN Manager of the Year',1961,'ML',NULL,NULL),('hurdlcl01','BBWAA Manager of the Year',2013,'NL',NULL,NULL),('hurdlcl01','TSN Manager of the Year',2013,'NL',NULL,NULL),('hutchfr01','TSN Manager of the Year',1957,'ML',NULL,NULL),('johnsda01','TSN Manager of the Year',1975,'ML',NULL,NULL),('johnsda02','BBWAA Manager of the Year',1997,'AL',NULL,NULL),('johnsda02','BBWAA Manager of the Year',2012,'NL',NULL,NULL),('johnsda02','TSN Manager of the Year',1997,'AL',NULL,NULL),('johnsda02','TSN Manager of the Year',2012,'NL',NULL,NULL),('keanejo99','TSN Manager of the Year',1964,'ML',NULL,NULL),('kellyto01','BBWAA Manager of the Year',1991,'AL',NULL,NULL),('kellyto01','TSN Manager of the Year',1991,'AL',NULL,NULL),('lamonge01','BBWAA Manager of the Year',1993,'AL',NULL,NULL),('lanieha01','BBWAA Manager of the Year',1986,'NL',NULL,NULL),('lanieha01','TSN Manager of the Year',1986,'NL',NULL,NULL),('larusto01','BBWAA Manager of the Year',1983,'AL',NULL,NULL),('larusto01','BBWAA Manager of the Year',1988,'AL',NULL,NULL),('larusto01','BBWAA Manager of the Year',1992,'AL',NULL,NULL),('larusto01','BBWAA Manager of the Year',2002,'NL',NULL,NULL),('larusto01','TSN Manager of the Year',1983,'ML',NULL,NULL),('larusto01','TSN Manager of the Year',1988,'AL',NULL,NULL),('larusto01','TSN Manager of the Year',1992,'AL',NULL,NULL),('lasorto01','BBWAA Manager of the Year',1983,'NL',NULL,NULL),('lasorto01','BBWAA Manager of the Year',1988,'NL',NULL,NULL),('leylaji99','BBWAA Manager of the Year',1990,'NL',NULL,NULL),('leylaji99','BBWAA Manager of the Year',1992,'NL',NULL,NULL),('leylaji99','BBWAA Manager of the Year',2006,'AL',NULL,NULL),('leylaji99','TSN Manager of the Year',1988,'NL',NULL,NULL),('leylaji99','TSN Manager of the Year',1990,'NL',NULL,NULL),('leylaji99','TSN Manager of the Year',1992,'NL',NULL,NULL),('leylaji99','TSN Manager of the Year',2006,'AL',NULL,NULL),('maddojo99','BBWAA Manager of the Year',2008,'AL',NULL,NULL),('maddojo99','BBWAA Manager of the Year',2011,'AL',NULL,NULL),('maddojo99','BBWAA Manager of the Year',2015,'NL',NULL,NULL),('maddojo99','TSN Manager of the Year',2008,'AL',NULL,NULL),('maddojo99','TSN Manager of the Year',2011,'AL',NULL,NULL),('manueje01','BBWAA Manager of the Year',2000,'AL',NULL,NULL),('manueje01','TSN Manager of the Year',2000,'AL',NULL,NULL),('martibi02','TSN Manager of the Year',1981,'ML',NULL,NULL),('mauchge01','TSN Manager of the Year',1973,'ML',NULL,NULL),('mccarjo99','TSN Manager of the Year',1936,'ML',NULL,NULL),('mccarjo99','TSN Manager of the Year',1938,'ML',NULL,NULL),('mccarjo99','TSN Manager of the Year',1943,'ML',NULL,NULL),('mckecbi01','TSN Manager of the Year',1937,'ML',NULL,NULL),('mckecbi01','TSN Manager of the Year',1940,'ML',NULL,NULL),('mckeoja99','BBWAA Manager of the Year',1999,'NL',NULL,NULL),('mckeoja99','BBWAA Manager of the Year',2003,'NL',NULL,NULL),('mcnamjo99','BBWAA Manager of the Year',1986,'AL',NULL,NULL),('mcnamjo99','TSN Manager of the Year',1986,'AL',NULL,NULL),('melesa01','TSN Manager of the Year',1965,'ML',NULL,NULL),('melvibo01','BBWAA Manager of the Year',2007,'NL',NULL,NULL),('melvibo01','BBWAA Manager of the Year',2012,'AL',NULL,NULL),('melvibo01','TSN Manager of the Year',2007,'NL',NULL,NULL),('meyerbi01','TSN Manager of the Year',1948,'ML',NULL,NULL),('molitpa01','TSN Manager of the Year',2015,'AL',NULL,NULL),('murtada01','TSN Manager of the Year',1960,'ML',NULL,NULL),('murtada01','TSN Manager of the Year',1970,'ML',NULL,NULL),('oatesjo01','BBWAA Manager of the Year',1996,'AL','Y',NULL),('oatesjo01','TSN Manager of the Year',1993,'AL',NULL,NULL),('oatesjo01','TSN Manager of the Year',1996,'AL',NULL,NULL),('ozarkda99','TSN Manager of the Year',1976,'ML',NULL,NULL),('penato01','BBWAA Manager of the Year',2003,'AL',NULL,NULL),('penato01','TSN Manager of the Year',2003,'AL',NULL,NULL),('pinielo01','BBWAA Manager of the Year',1995,'AL',NULL,NULL),('pinielo01','BBWAA Manager of the Year',2001,'AL',NULL,NULL),('pinielo01','BBWAA Manager of the Year',2008,'NL',NULL,NULL),('pinielo01','TSN Manager of the Year',2001,'AL',NULL,NULL),('rignebi01','TSN Manager of the Year',1962,'ML',NULL,NULL),('roberda07','BBWAA Manager of the Year',2016,'NL',NULL,NULL),('robinfr02','BBWAA Manager of the Year',1989,'AL',NULL,NULL),('robinfr02','TSN Manager of the Year',1989,'AL',NULL,NULL),('rodgebu01','BBWAA Manager of the Year',1987,'NL',NULL,NULL),('rodgebu01','TSN Manager of the Year',1987,'NL',NULL,NULL),('rolfere01','TSN Manager of the Year',1950,'ML',NULL,NULL),('sciosmi01','BBWAA Manager of the Year',2002,'AL',NULL,NULL),('sciosmi01','BBWAA Manager of the Year',2009,'AL',NULL,NULL),('sciosmi01','TSN Manager of the Year',2002,'AL',NULL,NULL),('sciosmi01','TSN Manager of the Year',2009,'AL',NULL,NULL),('sewellu01','TSN Manager of the Year',1944,'ML',NULL,NULL),('showabu99','BBWAA Manager of the Year',1994,'AL',NULL,NULL),('showabu99','BBWAA Manager of the Year',2004,'AL',NULL,NULL),('showabu99','BBWAA Manager of the Year',2014,'AL',NULL,NULL),('showabu99','TSN Manager of the Year',1994,'AL',NULL,NULL),('showabu99','TSN Manager of the Year',2012,'AL',NULL,NULL),('showabu99','TSN Manager of the Year',2014,'AL',NULL,NULL),('smithma01','TSN Manager of the Year',1968,'ML',NULL,NULL),('southbi01','TSN Manager of the Year',1941,'ML',NULL,NULL),('southbi01','TSN Manager of the Year',1942,'ML',NULL,NULL),('stanked01','TSN Manager of the Year',1952,'ML',NULL,NULL),('stengca01','TSN Manager of the Year',1949,'ML',NULL,NULL),('stengca01','TSN Manager of the Year',1953,'ML',NULL,NULL),('stengca01','TSN Manager of the Year',1958,'ML',NULL,NULL),('tannech01','TSN Manager of the Year',1972,'ML',NULL,NULL),('tebbebi01','TSN Manager of the Year',1956,'ML',NULL,NULL),('torboje01','BBWAA Manager of the Year',1990,'AL',NULL,NULL),('torboje01','TSN Manager of the Year',1990,'AL',NULL,NULL),('torrejo01','BBWAA Manager of the Year',1996,'AL','Y',NULL),('torrejo01','BBWAA Manager of the Year',1998,'AL',NULL,NULL),('torrejo01','TSN Manager of the Year',1998,'AL',NULL,NULL),('tracyji01','BBWAA Manager of the Year',2009,'NL',NULL,NULL),('tracyji01','TSN Manager of the Year',2009,'NL',NULL,NULL),('virdobi01','TSN Manager of the Year',1974,'ML',NULL,NULL),('virdobi01','TSN Manager of the Year',1980,'ML',NULL,NULL),('weaveea99','TSN Manager of the Year',1977,'ML',NULL,NULL),('weaveea99','TSN Manager of the Year',1979,'ML',NULL,NULL),('wedgeer01','BBWAA Manager of the Year',2007,'AL',NULL,NULL),('wedgeer01','TSN Manager of the Year',2007,'AL',NULL,NULL),('willidi02','TSN Manager of the Year',1967,'ML',NULL,NULL),('williji03','BBWAA Manager of the Year',1999,'AL',NULL,NULL),('williji03','TSN Manager of the Year',1999,'AL',NULL,NULL),('willima04','BBWAA Manager of the Year',2014,'NL',NULL,NULL),('willima04','TSN Manager of the Year',2014,'NL',NULL,NULL),('zimmedo01','BBWAA Manager of the Year',1989,'NL',NULL,NULL),('zimmedo01','TSN Manager of the Year',1989,'NL',NULL,NULL); 45 | /*!40000 ALTER TABLE `awardsmanagers` ENABLE KEYS */; 46 | UNLOCK TABLES; 47 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 48 | 49 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 50 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 51 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 52 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 53 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 54 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 55 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 56 | 57 | -- Dump completed on 2019-09-20 18:01:51 58 | -------------------------------------------------------------------------------- /baseball-database/lahmansbaseballdb-backup/lahmansbaseballdb_seriespost.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `lahmansbaseballdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; 2 | USE `lahmansbaseballdb`; 3 | -- MySQL dump 10.13 Distrib 8.0.17, for Win64 (x86_64) 4 | -- 5 | -- Host: localhost Database: lahmansbaseballdb 6 | -- ------------------------------------------------------ 7 | -- Server version 8.0.17 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!50503 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Table structure for table `seriespost` 22 | -- 23 | 24 | DROP TABLE IF EXISTS `seriespost`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | /*!50503 SET character_set_client = utf8mb4 */; 27 | CREATE TABLE `seriespost` ( 28 | `yearID` smallint(6) NOT NULL, 29 | `round` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, 30 | `teamIDwinner` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 31 | `lgIDwinner` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 32 | `teamIDloser` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 33 | `lgIDloser` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 34 | `wins` smallint(6) DEFAULT NULL, 35 | `losses` smallint(6) DEFAULT NULL, 36 | `ties` smallint(6) DEFAULT NULL, 37 | PRIMARY KEY (`yearID`,`round`) 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 39 | /*!40101 SET character_set_client = @saved_cs_client */; 40 | 41 | -- 42 | -- Dumping data for table `seriespost` 43 | -- 44 | 45 | LOCK TABLES `seriespost` WRITE; 46 | /*!40000 ALTER TABLE `seriespost` DISABLE KEYS */; 47 | INSERT INTO `seriespost` VALUES (1884,'WS','PRO','NL','NY4','AA',3,0,0),(1885,'WS','CHN','NL','SL4','AA',3,3,1),(1886,'WS','SL4','AA','CHN','NL',4,2,0),(1887,'WS','DTN','NL','SL4','AA',10,5,0),(1888,'WS','NY1','NL','SL4','AA',6,4,0),(1889,'WS','NY1','NL','BR3','AA',6,3,0),(1890,'WS','BRO','NL','LS2','AA',3,3,1),(1892,'CS','BSN','NL','CL4','NL',5,0,1),(1903,'WS','BOS','AL','PIT','NL',5,3,0),(1905,'WS','NY1','NL','PHA','AL',4,1,0),(1906,'WS','CHA','AL','CHN','NL',4,2,0),(1907,'WS','CHN','NL','DET','AL',4,0,0),(1908,'WS','CHN','NL','DET','AL',4,1,0),(1909,'WS','PIT','NL','DET','AL',4,3,0),(1910,'WS','PHA','AL','CHN','NL',4,1,0),(1911,'WS','PHA','AL','NY1','NL',4,2,0),(1912,'WS','BOS','AL','NY1','NL',4,3,0),(1913,'WS','PHA','AL','NY1','NL',4,1,0),(1914,'WS','BSN','NL','PHA','AL',4,0,0),(1915,'WS','BOS','AL','PHI','NL',4,1,0),(1916,'WS','BOS','AL','BRO','NL',4,1,0),(1917,'WS','CHA','AL','NY1','NL',4,2,0),(1918,'WS','BOS','AL','CHN','NL',4,2,0),(1919,'WS','CIN','NL','CHA','AL',5,3,0),(1920,'WS','CLE','AL','BRO','NL',5,2,0),(1921,'WS','NY1','NL','NYA','AL',5,3,0),(1922,'WS','NY1','NL','NYA','AL',4,0,0),(1923,'WS','NYA','AL','NY1','NL',4,2,0),(1924,'WS','WS1','AL','NY1','NL',4,3,0),(1925,'WS','PIT','NL','WS1','AL',4,3,0),(1926,'WS','SLN','NL','NYA','AL',4,3,0),(1927,'WS','NYA','AL','PIT','NL',4,0,0),(1928,'WS','NYA','AL','SLN','NL',4,0,0),(1929,'WS','PHA','AL','CHN','NL',4,1,0),(1930,'WS','PHA','AL','SLN','NL',4,2,0),(1931,'WS','SLN','NL','PHA','AL',4,3,0),(1932,'WS','NYA','AL','CHN','NL',4,0,0),(1933,'WS','NY1','NL','WS1','AL',4,1,0),(1934,'WS','SLN','NL','DET','AL',4,3,0),(1935,'WS','DET','AL','CHN','NL',4,2,0),(1936,'WS','NYA','AL','NY1','NL',4,2,0),(1937,'WS','NYA','AL','NY1','NL',4,1,0),(1938,'WS','NYA','AL','CHN','NL',4,0,0),(1939,'WS','NYA','AL','CIN','NL',4,0,0),(1940,'WS','CIN','NL','DET','AL',4,3,0),(1941,'WS','NYA','AL','BRO','NL',4,1,0),(1942,'WS','SLN','NL','NYA','AL',4,1,0),(1943,'WS','NYA','AL','SLN','NL',4,1,0),(1944,'WS','SLN','NL','SLA','AL',4,2,0),(1945,'WS','DET','AL','CHN','NL',4,3,0),(1946,'WS','SLN','NL','BOS','AL',4,3,0),(1947,'WS','NYA','AL','BRO','NL',4,3,0),(1948,'WS','CLE','AL','BSN','NL',4,2,0),(1949,'WS','NYA','AL','BRO','NL',4,1,0),(1950,'WS','NYA','AL','PHI','NL',4,0,0),(1951,'WS','NYA','AL','NY1','NL',4,2,0),(1952,'WS','NYA','AL','BRO','NL',4,3,0),(1953,'WS','NYA','AL','BRO','NL',4,2,0),(1954,'WS','NY1','NL','CLE','AL',4,0,0),(1955,'WS','BRO','NL','NYA','AL',4,3,0),(1956,'WS','NYA','AL','BRO','NL',4,3,0),(1957,'WS','ML1','NL','NYA','AL',4,3,0),(1958,'WS','NYA','AL','ML1','NL',4,3,0),(1959,'WS','LAN','NL','CHA','AL',4,2,0),(1960,'WS','PIT','NL','NYA','AL',4,3,0),(1961,'WS','NYA','AL','CIN','NL',4,1,0),(1962,'WS','NYA','AL','SFN','NL',4,3,0),(1963,'WS','LAN','NL','NYA','AL',4,0,0),(1964,'WS','SLN','NL','NYA','AL',4,3,0),(1965,'WS','LAN','NL','MIN','AL',4,3,0),(1966,'WS','BAL','AL','LAN','NL',4,0,0),(1967,'WS','SLN','NL','BOS','AL',4,3,0),(1968,'WS','DET','AL','SLN','NL',4,3,0),(1969,'ALCS','BAL','AL','MIN','AL',3,0,0),(1969,'NLCS','NYN','NL','ATL','NL',3,0,0),(1969,'WS','NYN','NL','BAL','AL',4,1,0),(1970,'ALCS','BAL','AL','MIN','AL',3,0,0),(1970,'NLCS','CIN','NL','PIT','NL',3,0,0),(1970,'WS','BAL','AL','CIN','NL',4,1,0),(1971,'ALCS','BAL','AL','OAK','AL',3,0,0),(1971,'NLCS','PIT','NL','SFN','NL',3,1,0),(1971,'WS','PIT','NL','BAL','AL',4,3,0),(1972,'ALCS','OAK','AL','DET','AL',3,2,0),(1972,'NLCS','CIN','NL','PIT','NL',3,2,0),(1972,'WS','OAK','AL','CIN','NL',4,3,0),(1973,'ALCS','OAK','AL','BAL','AL',3,2,0),(1973,'NLCS','NYN','NL','CIN','NL',3,2,0),(1973,'WS','OAK','AL','NYN','NL',4,3,0),(1974,'ALCS','OAK','AL','BAL','AL',3,1,0),(1974,'NLCS','LAN','NL','PIT','NL',3,1,0),(1974,'WS','OAK','AL','LAN','NL',4,1,0),(1975,'ALCS','BOS','AL','OAK','AL',3,0,0),(1975,'NLCS','CIN','NL','PIT','NL',3,0,0),(1975,'WS','CIN','NL','BOS','AL',4,3,0),(1976,'ALCS','NYA','AL','KCA','AL',3,2,0),(1976,'NLCS','CIN','NL','PHI','NL',3,0,0),(1976,'WS','CIN','NL','NYA','AL',4,0,0),(1977,'ALCS','NYA','AL','KCA','AL',3,2,0),(1977,'NLCS','LAN','NL','PHI','NL',3,1,0),(1977,'WS','NYA','AL','LAN','NL',4,2,0),(1978,'ALCS','NYA','AL','KCA','AL',3,1,0),(1978,'NLCS','LAN','NL','PHI','NL',3,1,0),(1978,'WS','NYA','AL','LAN','NL',4,2,0),(1979,'ALCS','BAL','AL','CAL','AL',3,1,0),(1979,'NLCS','PIT','NL','CIN','NL',3,0,0),(1979,'WS','PIT','NL','BAL','AL',4,3,0),(1980,'ALCS','KCA','AL','NYA','AL',3,0,0),(1980,'NLCS','PHI','NL','HOU','NL',3,2,0),(1980,'WS','PHI','NL','KCA','AL',4,2,0),(1981,'AEDIV','NYA','AL','ML4','AL',3,2,0),(1981,'ALCS','NYA','AL','OAK','AL',3,0,0),(1981,'AWDIV','OAK','AL','KCA','AL',3,0,0),(1981,'NEDIV','MON','NL','PHI','NL',3,2,0),(1981,'NLCS','LAN','NL','MON','NL',3,2,0),(1981,'NWDIV','LAN','NL','HOU','NL',3,2,0),(1981,'WS','LAN','NL','NYA','AL',4,2,0),(1982,'ALCS','ML4','AL','CAL','AL',3,2,0),(1982,'NLCS','SLN','NL','ATL','NL',3,0,0),(1982,'WS','SLN','NL','ML4','AL',4,3,0),(1983,'ALCS','BAL','AL','CHA','AL',3,1,0),(1983,'NLCS','PHI','NL','LAN','NL',3,1,0),(1983,'WS','BAL','AL','PHI','NL',4,1,0),(1984,'ALCS','DET','AL','KCA','AL',3,0,0),(1984,'NLCS','SDN','NL','CHN','NL',3,2,0),(1984,'WS','DET','AL','SDN','NL',4,1,0),(1985,'ALCS','KCA','AL','TOR','AL',4,3,0),(1985,'NLCS','SLN','NL','LAN','NL',4,2,0),(1985,'WS','KCA','AL','SLN','NL',4,3,0),(1986,'ALCS','BOS','AL','CAL','AL',4,3,0),(1986,'NLCS','NYN','NL','HOU','NL',4,2,0),(1986,'WS','NYN','NL','BOS','AL',4,3,0),(1987,'ALCS','MIN','AL','DET','AL',4,1,0),(1987,'NLCS','SLN','NL','SFN','NL',4,3,0),(1987,'WS','MIN','AL','SLN','NL',4,3,0),(1988,'ALCS','OAK','AL','BOS','AL',4,0,0),(1988,'NLCS','LAN','NL','NYN','NL',4,3,0),(1988,'WS','LAN','NL','OAK','AL',4,1,0),(1989,'ALCS','OAK','AL','TOR','AL',4,1,0),(1989,'NLCS','SFN','NL','CHN','NL',4,1,0),(1989,'WS','OAK','AL','SFN','NL',4,0,0),(1990,'ALCS','OAK','AL','BOS','AL',4,0,0),(1990,'NLCS','CIN','NL','PIT','NL',4,2,0),(1990,'WS','CIN','NL','OAK','AL',4,0,0),(1991,'ALCS','MIN','AL','TOR','AL',4,1,0),(1991,'NLCS','ATL','NL','PIT','NL',4,3,0),(1991,'WS','MIN','AL','ATL','NL',4,3,0),(1992,'ALCS','TOR','AL','OAK','AL',4,2,0),(1992,'NLCS','ATL','NL','PIT','NL',4,3,0),(1992,'WS','TOR','AL','ATL','NL',4,2,0),(1993,'ALCS','TOR','AL','CHA','AL',4,2,0),(1993,'NLCS','PHI','NL','ATL','NL',4,2,0),(1993,'WS','TOR','AL','PHI','NL',4,2,0),(1995,'ALCS','CLE','AL','SEA','AL',4,2,0),(1995,'ALDS1','CLE','AL','BOS','AL',3,0,0),(1995,'ALDS2','SEA','AL','NYA','AL',3,2,0),(1995,'NLCS','ATL','NL','CIN','NL',4,0,0),(1995,'NLDS1','ATL','NL','COL','NL',3,1,0),(1995,'NLDS2','CIN','NL','LAN','NL',3,0,0),(1995,'WS','ATL','NL','CLE','AL',4,2,0),(1996,'ALCS','NYA','AL','BAL','AL',4,1,0),(1996,'ALDS1','BAL','AL','CLE','AL',3,1,0),(1996,'ALDS2','NYA','AL','TEX','AL',3,1,0),(1996,'NLCS','ATL','NL','SLN','NL',4,3,0),(1996,'NLDS1','ATL','NL','LAN','NL',3,0,0),(1996,'NLDS2','SLN','NL','SDN','NL',3,0,0),(1996,'WS','NYA','AL','ATL','NL',4,2,0),(1997,'ALCS','CLE','AL','BAL','AL',4,2,0),(1997,'ALDS1','CLE','AL','NYA','AL',3,2,0),(1997,'ALDS2','BAL','AL','SEA','AL',3,1,0),(1997,'NLCS','FLO','NL','ATL','NL',4,2,0),(1997,'NLDS1','FLO','NL','SFN','NL',3,0,0),(1997,'NLDS2','ATL','NL','HOU','NL',3,0,0),(1997,'WS','FLO','NL','CLE','AL',4,3,0),(1998,'ALCS','NYA','AL','CLE','AL',4,2,0),(1998,'ALDS1','CLE','AL','BOS','AL',3,1,0),(1998,'ALDS2','NYA','AL','TEX','AL',3,0,0),(1998,'NLCS','SDN','NL','ATL','NL',4,2,0),(1998,'NLDS1','ATL','NL','CHN','NL',3,0,0),(1998,'NLDS2','SDN','NL','HOU','NL',3,1,0),(1998,'WS','NYA','AL','SDN','NL',4,0,0),(1999,'ALCS','NYA','AL','BOS','AL',4,1,0),(1999,'ALDS1','BOS','AL','CLE','AL',3,2,0),(1999,'ALDS2','NYA','AL','TEX','AL',3,0,0),(1999,'NLCS','ATL','NL','NYN','NL',4,2,0),(1999,'NLDS1','ATL','NL','HOU','NL',3,1,0),(1999,'NLDS2','NYN','NL','ARI','NL',3,1,0),(1999,'WS','NYA','AL','ATL','NL',4,0,0),(2000,'ALCS','NYA','AL','SEA','AL',4,2,0),(2000,'ALDS1','NYA','AL','OAK','AL',3,2,0),(2000,'ALDS2','SEA','AL','CHA','AL',3,0,0),(2000,'NLCS','NYN','NL','SLN','NL',4,1,0),(2000,'NLDS1','SLN','NL','ATL','NL',3,0,0),(2000,'NLDS2','NYN','NL','SFN','NL',3,1,0),(2000,'WS','NYA','AL','NYN','NL',4,1,0),(2001,'ALCS','NYA','AL','SEA','AL',4,1,0),(2001,'ALDS1','SEA','AL','CLE','AL',3,2,0),(2001,'ALDS2','NYA','AL','OAK','AL',3,2,0),(2001,'NLCS','ARI','NL','ATL','NL',4,1,0),(2001,'NLDS1','ATL','NL','HOU','NL',3,0,0),(2001,'NLDS2','ARI','NL','SLN','NL',3,2,0),(2001,'WS','ARI','NL','NYA','AL',4,3,0),(2002,'ALCS','ANA','AL','MIN','AL',4,1,0),(2002,'ALDS1','ANA','AL','NYA','AL',3,1,0),(2002,'ALDS2','MIN','AL','OAK','AL',3,2,0),(2002,'NLCS','SFN','NL','SLN','NL',4,1,0),(2002,'NLDS1','SFN','NL','ATL','NL',3,2,0),(2002,'NLDS2','SLN','NL','ARI','NL',3,0,0),(2002,'WS','ANA','AL','SFN','NL',4,3,0),(2003,'ALCS','NYA','AL','BOS','AL',4,3,0),(2003,'ALDS1','NYA','AL','MIN','AL',3,1,0),(2003,'ALDS2','BOS','AL','OAK','AL',3,2,0),(2003,'NLCS','FLO','NL','CHN','NL',4,3,0),(2003,'NLDS1','FLO','NL','SFN','NL',3,1,0),(2003,'NLDS2','CHN','NL','ATL','NL',3,2,0),(2003,'WS','FLO','NL','NYA','AL',4,2,0),(2004,'ALCS','BOS','AL','NYA','AL',4,3,0),(2004,'ALDS1','BOS','AL','ANA','AL',3,0,0),(2004,'ALDS2','NYA','AL','MIN','AL',3,1,0),(2004,'NLCS','SLN','NL','HOU','NL',4,3,0),(2004,'NLDS1','SLN','NL','LAN','NL',3,1,0),(2004,'NLDS2','HOU','NL','ATL','NL',3,2,0),(2004,'WS','BOS','AL','SLN','NL',4,0,0),(2005,'ALCS','CHA','AL','LAA','AL',4,1,0),(2005,'ALDS1','CHA','AL','BOS','AL',3,0,0),(2005,'ALDS2','LAA','AL','NYA','AL',3,2,0),(2005,'NLCS','HOU','NL','SLN','NL',4,2,0),(2005,'NLDS1','SLN','NL','SDN','NL',3,0,0),(2005,'NLDS2','HOU','NL','ATL','NL',3,1,0),(2005,'WS','CHA','AL','HOU','NL',4,0,0),(2006,'ALCS','DET','AL','OAK','AL',4,0,0),(2006,'ALDS1','DET','AL','NYA','AL',3,1,0),(2006,'ALDS2','OAK','AL','MIN','AL',3,0,0),(2006,'NLCS','SLN','NL','NYN','NL',4,3,0),(2006,'NLDS1','NYN','NL','LAN','NL',3,0,0),(2006,'NLDS2','SLN','NL','SDN','NL',3,1,0),(2006,'WS','SLN','NL','DET','AL',4,1,0),(2007,'ALCS','BOS','AL','CLE','AL',4,3,0),(2007,'ALDS1','BOS','AL','LAA','AL',3,0,0),(2007,'ALDS2','CLE','AL','NYA','AL',3,1,0),(2007,'NLCS','COL','NL','ARI','NL',4,0,0),(2007,'NLDS1','ARI','NL','CHN','NL',3,0,0),(2007,'NLDS2','COL','NL','PHI','NL',3,0,0),(2007,'WS','BOS','AL','COL','NL',4,0,0),(2008,'ALCS','TBA','AL','BOS','AL',4,3,0),(2008,'ALDS1','BOS','AL','LAA','AL',3,1,0),(2008,'ALDS2','TBA','AL','CHA','AL',3,1,0),(2008,'NLCS','PHI','NL','LAN','NL',4,1,0),(2008,'NLDS1','LAN','NL','CHN','NL',3,0,0),(2008,'NLDS2','PHI','NL','MIL','NL',3,1,0),(2008,'WS','PHI','NL','TBA','AL',4,1,0),(2009,'ALCS','NYA','AL','LAA','AL',4,2,0),(2009,'ALDS1','NYA','AL','MIN','AL',3,0,0),(2009,'ALDS2','LAA','AL','BOS','AL',3,0,0),(2009,'NLCS','PHI','NL','LAN','NL',4,1,0),(2009,'NLDS1','LAN','NL','SLN','NL',3,0,0),(2009,'NLDS2','PHI','NL','COL','NL',3,1,0),(2009,'WS','NYA','AL','PHI','NL',4,2,0),(2010,'ALCS','TEX','AL','NYA','AL',4,2,0),(2010,'ALDS1','TEX','AL','TBA','AL',3,2,0),(2010,'ALDS2','NYA','AL','MIN','AL',3,0,0),(2010,'NLCS','SFN','NL','PHI','NL',4,2,0),(2010,'NLDS1','PHI','NL','CIN','NL',3,0,0),(2010,'NLDS2','SFN','NL','ATL','NL',3,1,0),(2010,'WS','SFN','NL','TEX','AL',4,1,0),(2011,'ALCS','TEX','AL','DET','AL',4,2,0),(2011,'ALDS1','DET','AL','NYA','AL',3,2,0),(2011,'ALDS2','TEX','AL','TBA','AL',3,1,0),(2011,'NLCS','SLN','NL','MIL','NL',4,2,0),(2011,'NLDS1','SLN','NL','PHI','NL',3,2,0),(2011,'NLDS2','MIL','NL','ARI','NL',3,2,0),(2011,'WS','SLN','NL','TEX','AL',4,3,0),(2012,'ALCS','DET','AL','NYA','AL',4,0,0),(2012,'ALDS1','NYA','AL','BAL','AL',3,2,0),(2012,'ALDS2','DET','AL','OAK','AL',3,2,0),(2012,'ALWC','BAL','AL','TEX','AL',1,0,0),(2012,'NLCS','SFN','NL','SLN','NL',4,3,0),(2012,'NLDS1','SLN','NL','WAS','NL',3,2,0),(2012,'NLDS2','SFN','NL','CIN','NL',3,2,0),(2012,'NLWC','SLN','NL','ATL','NL',1,0,0),(2012,'WS','SFN','NL','DET','AL',4,0,0),(2013,'ALCS','BOS','AL','DET','AL',4,2,0),(2013,'ALDS1','BOS','AL','TBA','AL',3,1,0),(2013,'ALDS2','DET','AL','OAK','AL',3,2,0),(2013,'ALWC','TBA','AL','CLE','AL',1,0,0),(2013,'NLCS','SLN','NL','LAN','NL',4,2,0),(2013,'NLDS1','SLN','NL','PIT','NL',3,2,0),(2013,'NLDS2','LAN','NL','ATL','NL',3,1,0),(2013,'NLWC','PIT','NL','CIN','NL',1,0,0),(2013,'WS','BOS','AL','SLN','NL',4,3,0),(2014,'ALCS','KCA','AL','BAL','AL',4,0,0),(2014,'ALDS1','KCA','AL','LAA','AL',3,0,0),(2014,'ALDS2','BAL','AL','DET','AL',3,0,0),(2014,'ALWC','KCA','AL','OAK','AL',1,0,0),(2014,'NLCS','SFN','NL','SLN','NL',4,1,0),(2014,'NLDS1','SFN','NL','WAS','NL',3,1,0),(2014,'NLDS2','SLN','NL','LAN','NL',3,1,0),(2014,'NLWC','SFN','NL','PIT','NL',1,0,0),(2014,'WS','SFN','NL','KCA','AL',4,3,0),(2015,'ALCS','KCA','AL','TOR','AL',4,2,0),(2015,'ALDS1','KCA','AL','HOU','AL',3,2,0),(2015,'ALDS2','TOR','AL','TEX','AL',3,2,0),(2015,'ALWC','HOU','AL','NYA','AL',1,0,0),(2015,'NLCS','NYN','NL','CHN','NL',4,0,0),(2015,'NLDS1','CHN','NL','SLN','NL',3,1,0),(2015,'NLDS2','NYN','NL','LAN','NL',3,2,0),(2015,'NLWC','CHN','NL','PIT','NL',1,0,0),(2015,'WS','KCA','AL','NYN','NL',4,1,0),(2016,'ALCS','CLE','AL','TOR','AL',4,1,0),(2016,'ALDS1','TOR','AL','TEX','AL',3,0,0),(2016,'ALDS2','CLE','AL','BOS','AL',3,0,0),(2016,'ALWC','TOR','AL','BAL','AL',1,0,0),(2016,'NLCS','CHN','NL','LAN','NL',4,2,0),(2016,'NLDS1','CHN','NL','SFN','NL',3,1,0),(2016,'NLDS2','LAN','NL','WAS','NL',3,2,0),(2016,'NLWC','SFN','NL','NYN','NL',1,0,0),(2016,'WS','CHN','NL','CLE','AL',4,3,0),(2017,'ALCS','HOU','AL','NYA','AL',4,3,0),(2017,'ALDS1','NYA','AL','CLE','AL',3,2,0),(2017,'ALDS2','HOU','AL','BOS','AL',3,1,0),(2017,'ALWC','NYA','AL','MIN','AL',1,0,0),(2017,'NLCS','LAN','NL','CHN','NL',4,1,0),(2017,'NLDS1','LAN','NL','ARI','NL',3,0,0),(2017,'NLDS2','CHN','NL','WAS','NL',3,2,0),(2017,'NLWC','ARI','NL','COL','NL',1,0,0),(2017,'WS','HOU','AL','LAN','NL',4,3,0),(2018,'ALCS','BOS','AL','HOU','AL',4,1,0),(2018,'ALDS1','BOS','AL','NYA','AL',3,1,0),(2018,'ALDS2','HOU','AL','CLE','AL',3,0,0),(2018,'ALWC','NYA','AL','OAK','AL',1,0,0),(2018,'NLCS','LAN','NL','MIL','NL',4,3,0),(2018,'NLDS1','MIL','NL','COL','NL',3,0,0),(2018,'NLDS2','LAN','NL','ATL','NL',3,1,0),(2018,'NLWC','COL','NL','CHN','NL',1,0,0),(2018,'WS','BOS','AL','LAN','NL',4,1,0); 48 | /*!40000 ALTER TABLE `seriespost` ENABLE KEYS */; 49 | UNLOCK TABLES; 50 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 51 | 52 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 53 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 54 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 55 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 56 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 57 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 58 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 59 | 60 | -- Dump completed on 2019-09-20 18:01:56 61 | -------------------------------------------------------------------------------- /baseball-database/lahmansbaseballdb-backup/lahmansbaseballdb_parks.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `lahmansbaseballdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; 2 | USE `lahmansbaseballdb`; 3 | -- MySQL dump 10.13 Distrib 8.0.17, for Win64 (x86_64) 4 | -- 5 | -- Host: localhost Database: lahmansbaseballdb 6 | -- ------------------------------------------------------ 7 | -- Server version 8.0.17 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!50503 SET NAMES utf8 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Table structure for table `parks` 22 | -- 23 | 24 | DROP TABLE IF EXISTS `parks`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | /*!50503 SET character_set_client = utf8mb4 */; 27 | CREATE TABLE `parks` ( 28 | `ID` int(11) NOT NULL, 29 | `parkalias` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 30 | `parkkey` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 31 | `parkname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 32 | `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 33 | `state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 34 | `country` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, 35 | PRIMARY KEY (`ID`) 36 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 37 | /*!40101 SET character_set_client = @saved_cs_client */; 38 | 39 | -- 40 | -- Dumping data for table `parks` 41 | -- 42 | 43 | LOCK TABLES `parks` WRITE; 44 | /*!40000 ALTER TABLE `parks` DISABLE KEYS */; 45 | INSERT INTO `parks` VALUES (1,NULL,'ALB01','Riverside Park','Albany','NY','US'),(2,NULL,'ALT01','Columbia Park','Altoona','PA','US'),(3,'Edison Field; Anaheim Stadium','ANA01','Angel Stadium of Anaheim','Anaheim','CA','US'),(4,NULL,'ARL01','Arlington Stadium','Arlington','TX','US'),(5,'The Ballpark in Arlington; Ameriquest Fl','ARL02','Rangers Ballpark in Arlington','Arlington','TX','US'),(6,NULL,'ATL01','Atlanta-Fulton County Stadium','Atlanta','GA','US'),(7,NULL,'ATL02','Turner Field','Atlanta','GA','US'),(8,NULL,'ATL03','Suntrust Park','Atlanta','GA','US'),(9,NULL,'BAL01','Madison Avenue Grounds','Baltimore','MD','US'),(10,NULL,'BAL02','Newington Park','Baltimore','MD','US'),(11,NULL,'BAL03','Oriole Park I','Baltimore','MD','US'),(12,NULL,'BAL04','Belair Lot','Baltimore','MD','US'),(13,NULL,'BAL05','Monumental Park','Baltimore','MD','US'),(14,NULL,'BAL06','Oriole Park II','Baltimore','MD','US'),(15,NULL,'BAL07','Oriole Park III','Baltimore','MD','US'),(16,'American League Park','BAL09','Oriole Park IV','Baltimore','MD','US'),(17,'Oriole Park V','BAL10','Terrapin Park','Baltimore','MD','US'),(18,NULL,'BAL11','Memorial Stadium','Baltimore','MD','US'),(19,NULL,'BAL12','Oriole Park at Camden Yards','Baltimore','MD','US'),(20,'Walpole Street Grounds','BOS01','South End Grounds I','Boston','MA','US'),(21,'Union Park','BOS02','Dartmouth Grounds','Boston','MA','US'),(22,NULL,'BOS03','South End Grounds II','Boston','MA','US'),(23,NULL,'BOS04','Congress Street Grounds','Boston','MA','US'),(24,NULL,'BOS05','South End Grounds III','Boston','MA','US'),(25,NULL,'BOS06','Huntington Avenue Baseball Grounds','Boston','MA','US'),(26,NULL,'BOS07','Fenway Park','Boston','MA','US'),(27,'Bee Hive','BOS08','Braves Field','Boston','MA','US'),(28,NULL,'BUF01','Riverside Grounds','Buffalo','NY','US'),(29,NULL,'BUF02','Olympic Park I','Buffalo','NY','US'),(30,NULL,'BUF03','Olympic Park II','Buffalo','NY','US'),(31,'Federal League Park','BUF04','International Fair Association Grounds','Buffalo','NY','US'),(32,'Pastime Park','CAN01','Mahaffey Park','Canton','OH','US'),(33,NULL,'CAN02','Pastime Park','Canton','OH','US'),(34,'Union Base-ball Grounds','CHI01','Lake Front Park I','Chicago','IL','US'),(35,NULL,'CHI02','23rd Street Park','Chicago','IL','US'),(36,NULL,'CHI03','Lake Front Park II','Chicago','IL','US'),(37,'Cricket Club Grounds; Union Grounds','CHI05','South Side Park I','Chicago','IL','US'),(38,NULL,'CHI06','West Side Park','Chicago','IL','US'),(39,NULL,'CHI07','South Side Park II','Chicago','IL','US'),(40,NULL,'CHI08','West Side Grounds','Chicago','IL','US'),(41,NULL,'CHI09','South Side Park III','Chicago','IL','US'),(42,'White Sox Park','CHI10','Comiskey Park I','Chicago','IL','US'),(43,'Weeghman Park; Cubs Park','CHI11','Wrigley Field','Chicago','IL','US'),(44,'White Sox Park; Comiskey Park II','CHI12','U.S. Cellular Field','Chicago','IL','US'),(45,'Union Cricket Club Grounds','CIN01','Lincoln Park Grounds','Cincinnati','OH','US'),(46,NULL,'CIN02','Avenue Grounds','Cincinnati','OH','US'),(47,NULL,'CIN03','Bank Street Grounds','Cincinnati','OH','US'),(48,NULL,'CIN04','League Park I','Cincinnati','OH','US'),(49,NULL,'CIN05','League Park II','Cincinnati','OH','US'),(50,'League Park III','CIN06','Palace of the Fans','Cincinnati','OH','US'),(51,'Redland Field','CIN07','Crosley Field','Cincinnati','OH','US'),(52,'Riverfront Stadium','CIN08','Cinergy Field','Cincinnati','OH','US'),(53,NULL,'CIN09','Great American Ballpark','Cincinnati','OH','US'),(54,NULL,'CLE01','National Association Grounds','Cleveland','OH','US'),(55,'Kennard Street Park','CLE02','League Park I','Cleveland','OH','US'),(56,'American Association Park','CLE03','League Park II','Cleveland','OH','US'),(57,'Players League Park','CLE04','Brotherhood Park','Cleveland','OH','US'),(58,'National League Park III','CLE05','League Park III','Cleveland','OH','US'),(59,'Dunn Field','CLE06','League Park IV','Cleveland','OH','US'),(60,'Municipal Stadium','CLE07','Cleveland Stadium','Cleveland','OH','US'),(61,'Jacobs Field','CLE08','Progressive Field','Cleveland','OH','US'),(62,NULL,'CLE09','Cedar Avenue Driving Park','Cleveland','OH','US'),(63,NULL,'CLL01','Euclid Beach Park','Collinwood','OH','US'),(64,NULL,'COL01','Recreation Park I','Columbus','OH','US'),(65,NULL,'COL02','Recreation Park II','Columbus','OH','US'),(66,NULL,'COL03','Neil Park I','Columbus','OH','US'),(67,NULL,'COL04','Neil Park II','Columbus','OH','US'),(68,NULL,'COV01','Star Baseball Park','Covington','KY','US'),(69,NULL,'DAY01','Fairview Park','Dayton','OH','US'),(70,NULL,'DEN01','Mile High Stadium','Denver','CO','US'),(71,NULL,'DEN02','Coors Field','Denver','CO','US'),(72,NULL,'DET01','Recreation Park','Detroit','MI','US'),(73,NULL,'DET02','Bennett Park','Detroit','MI','US'),(74,'West End Park','DET03','Burns Park','Detroit','MI','US'),(75,'Navin Field; Briggs Stadium','DET04','Tiger Stadium','Detroit','MI','US'),(76,NULL,'DET05','Comerica Park','Detroit','MI','US'),(77,NULL,'DOV01','Fairview Park Fair Grounds','Dover','DE','US'),(78,NULL,'ELM01','Maple Avenue Driving Park','Elmira','NY','US'),(79,'Hamilton Field','FOR01','Grand Duchess','Fort Wayne','IN','US'),(80,NULL,'FOR03','Jailhouse Flats','Fort Wayne','IN','US'),(81,NULL,'FTB01','Fort Bragg Field','Fort Bragg','NC','US'),(82,'Beyerle\'s Park','GEA01','Geauga Lake Grounds','Geauga Lake','OH','US'),(83,NULL,'GLO01','Gloucester Point Grounds','Gloucester City','NJ','US'),(84,NULL,'GRA01','Ramona Park','Grand Rapids','MI','US'),(85,NULL,'HAR01','Harrison Field','Harrison','NJ','US'),(86,NULL,'HOB01','Elysian Field','Hoboken','NJ','US'),(87,NULL,'HON01','Aloha Stadium','Honolulu','HI','US'),(88,NULL,'HOU01','Colt Stadium','Houston','TX','US'),(89,NULL,'HOU02','Astrodome','Houston','TX','US'),(90,'Enron Field; Astros Field','HOU03','Minute Maid Park','Houston','TX','US'),(91,NULL,'HRT01','Hartford Ball Club Grounds','Hartford','CT','US'),(92,NULL,'HRT02','Hartford Trotting Park','Hartford','CT','US'),(93,NULL,'IND01','South Street Park','Indianapolis','IN','US'),(94,NULL,'IND02','Seventh Street Park I','Indianapolis','IN','US'),(95,NULL,'IND03','Bruce Grounds','Indianapolis','IN','US'),(96,NULL,'IND04','Seventh Street Park II','Indianapolis','IN','US'),(97,NULL,'IND05','Seventh Street Park III','Indianapolis','IN','US'),(98,NULL,'IND06','Indianapolis Park','Indianapolis','IN','US'),(99,'Washington Park','IND07','Federal League Park','Indianapolis','IN','US'),(100,NULL,'IRO01','Windsor Beach','Irondequoit','NY','US'),(101,NULL,'JER01','Oakdale Park','Jersey City','NJ','US'),(102,NULL,'JER02','Roosevelt Stadium','Jersey City','NJ','US'),(103,NULL,'KAN01','Athletic Park','Kansas City','MO','US'),(104,NULL,'KAN02','Association Park','Kansas City','MO','US'),(105,NULL,'KAN03','Exposition Park','Kansas City','MO','US'),(106,NULL,'KAN04','Gordon and Koppel Field','Kansas City','MO','US'),(107,NULL,'KAN05','Municipal Stadium','Kansas City','MO','US'),(108,'Royals Stadium','KAN06','Kauffman Stadium','Kansas City','MO','US'),(109,'Walte\'s Pasture','KEO01','Perry Park','Keokuk','IA','US'),(110,NULL,'LAS01','Cashman Field','Las Vegas','NV','US'),(111,NULL,'LBV01','The Ballpark at Disney\'s Wide World','Lake Buena Vista','FL','US'),(112,NULL,'LOS01','Los Angeles Memorial Coliseum','Los Angeles','CA','US'),(113,NULL,'LOS02','Wrigley Field','Los Angeles','CA','US'),(114,'Chavez Ravine','LOS03','Dodger Stadium','Los Angeles','CA','US'),(115,NULL,'LOU01','Louisville Baseball Park','Louisville','KY','US'),(116,NULL,'LOU02','Eclipse Park I','Louisville','KY','US'),(117,NULL,'LOU03','Eclipse Park II','Louisville','KY','US'),(118,NULL,'LOU04','Eclipse Park III','Louisville','KY','US'),(119,NULL,'LUD01','Ludlow Baseball Park','Ludlow','KY','US'),(120,NULL,'MAS01','Long Island Grounds','Maspeth','NY','US'),(121,'JoeRobbie; ProPlayer; Dolphin; LandShark','MIA01','Sun Life Stadium','Miami','FL','US'),(122,NULL,'MIA02','Marlins Park','Miami','FL','US'),(123,NULL,'MID01','Mansfield Club Grounds','Middletown','CT','US'),(124,NULL,'MIL01','Milwaukee Base-Ball Grounds','Milwaukee','WI','US'),(125,NULL,'MIL02','Wright Street Grounds','Milwaukee','WI','US'),(126,NULL,'MIL03','Athletic Park','Milwaukee','WI','US'),(127,NULL,'MIL04','Lloyd Street Grounds','Milwaukee','WI','US'),(128,NULL,'MIL05','County Stadium','Milwaukee','WI','US'),(129,NULL,'MIL06','Miller Park','Milwaukee','WI','US'),(130,NULL,'MIN01','Athletic Park','Minneapolis','MN','US'),(131,NULL,'MIN02','Metropolitan Stadium','Bloomington','MN','US'),(132,NULL,'MIN03','Hubert H. Humphrey Metrodome','Minneapolis','MN','US'),(133,NULL,'MIN04','Target Field','Minneapolis','MN','US'),(134,NULL,'MNT01','Estadio Monterrey','Monterrey','Nuevo Leon','MX'),(135,'Jarry Park','MON01','Parc Jarry','Montreal','QC','CA'),(136,'Olympic Stadium','MON02','Stade Olympique','Montreal','QC','CA'),(137,'Brewster Park','NEW01','Howard Avenue Grounds','New Haven','CT','US'),(138,NULL,'NEW02','Hamilton Park','New Haven','CT','US'),(139,'Beyerle\'s Park','NEW03','Geauga Lake Grounds','Geauga Lake','OH','US'),(140,NULL,'NWK01','Wiedenmeyer\'s Park','Newark','NJ','US'),(141,NULL,'NYC01','Union Grounds','Brooklyn','NY','US'),(142,NULL,'NYC02','Capitoline Grounds','Brooklyn','NY','US'),(143,NULL,'NYC03','Polo Grounds I (Southeast Diamond)','New York','NY','US'),(144,NULL,'NYC04','Polo Grounds II (Southwest Diamond)','New York','NY','US'),(145,NULL,'NYC05','Washington Park I','Brooklyn','NY','US'),(146,NULL,'NYC06','Metropolitan Park','New York','NY','US'),(147,'Ridgewood Park I','NYC07','Grauer\'s Ridgewood Park','Queens','NY','US'),(148,NULL,'NYC08','Washington Park II','Brooklyn','NY','US'),(149,NULL,'NYC09','Polo Grounds III','New York','NY','US'),(150,NULL,'NYC10','Polo Grounds IV','New York','NY','US'),(151,NULL,'NYC11','Eastern Park','Brooklyn','NY','US'),(152,NULL,'NYC12','Washington Park III','Brooklyn','NY','US'),(153,NULL,'NYC13','Hilltop Park','New York','NY','US'),(154,NULL,'NYC14','Polo Grounds V','New York','NY','US'),(155,NULL,'NYC15','Ebbets Field','Brooklyn','NY','US'),(156,NULL,'NYC16','Yankee Stadium I','New York','NY','US'),(157,'William A. Shea Stadium','NYC17','Shea Stadium','New York','NY','US'),(158,'Ridgewood Park II','NYC18','Wallace\'s Ridgewood Park','Queens','NY','US'),(159,NULL,'NYC19','Washington Park IV','Brooklyn','NY','US'),(160,NULL,'NYC20','Citi Field','New York','NY','US'),(161,NULL,'NYC21','Yankee Stadium II','New York','NY','US'),(162,'Network Associates Coliseum','OAK01','Oakland-Alameda County Coliseum','Oakland','CA','US'),(163,'Pendleton Park','PEN01','East End Park','Cincinnati','OH','US'),(164,'Athletics Park','PHI01','Jefferson Street Grounds','Philadelphia','PA','US'),(165,NULL,'PHI02','Centennial Park','Philadelphia','PA','US'),(166,NULL,'PHI03','Oakdale Park','Philadelphia','PA','US'),(167,NULL,'PHI04','Recreation Park','Philadelphia','PA','US'),(168,NULL,'PHI05','Keystone Park','Philadelphia','PA','US'),(169,NULL,'PHI06','Huntingdon Grounds I','Philadelphia','PA','US'),(170,NULL,'PHI07','Forepaugh Park','Philadelphia','PA','US'),(171,NULL,'PHI08','University of Penn. Athletic Field','Philadelphia','PA','US'),(172,NULL,'PHI09','Baker Bowl','Philadelphia','PA','US'),(173,NULL,'PHI10','Columbia Park','Philadelphia','PA','US'),(174,'Connie Mack Stadium','PHI11','Shibe Park','Philadelphia','PA','US'),(175,NULL,'PHI12','Veterans Stadium','Philadelphia','PA','US'),(176,NULL,'PHI13','Citizens Bank Park','Philadelphia','PA','US'),(177,NULL,'PHI14','Huntingdon Grounds II','Philadelphia','PA','US'),(178,'Bank One Ballpark','PHO01','Chase Field','Phoenix','AZ','US'),(179,NULL,'PIT01','Union Park','Pittsburgh','PA','US'),(180,'Lower Field','PIT02','Exposition Park I','Pittsburgh','PA','US'),(181,'Upper Field','PIT03','Exposition Park II','Pittsburgh','PA','US'),(182,NULL,'PIT04','Recreation Park','Pittsburgh','PA','US'),(183,NULL,'PIT05','Exposition Park III','Pittsburgh','PA','US'),(184,NULL,'PIT06','Forbes Field','Pittsburgh','PA','US'),(185,NULL,'PIT07','Three Rivers Stadium','Pittsburgh','PA','US'),(186,NULL,'PIT08','PNC Park','Pittsburgh','PA','US'),(187,NULL,'PRO01','Adelaide Avenue Grounds','Providence','RI','US'),(188,NULL,'PRO02','Messer Street Grounds','Providence','RI','US'),(189,NULL,'RCK01','Agricultural Society Fair Grounds','Rockford','IL','US'),(190,NULL,'RIC01','Richmond Fair Grounds','Richmond','VA','US'),(191,NULL,'RIC02','Allens Pasture','Richmond','VA','US'),(192,NULL,'ROC01','Culver Field I','Rochester','NY','US'),(193,NULL,'ROC02','Culver Field II','Rochester','NY','US'),(194,NULL,'ROC03','Ontario Beach Grounds','Rochester','NY','US'),(195,NULL,'SAI01','St. George Cricket Grounds','New York','NY','US'),(196,'San Diego/Jack Murphy Stadium','SAN01','Qualcomm Stadium','San Diego','CA','US'),(197,NULL,'SAN02','PETCO Park','San Diego','CA','US'),(198,NULL,'SEA01','Sick\'s Stadium','Seattle','WA','US'),(199,NULL,'SEA02','Kingdome','Seattle','WA','US'),(200,NULL,'SEA03','Safeco Field','Seattle','WA','US'),(201,NULL,'SFO01','Seals Stadium','San Francisco','CA','US'),(202,'3Com Park','SFO02','Candlestick Park','San Francisco','CA','US'),(203,'Pacific Bell Park; SBC Park','SFO03','AT&T Park','San Francisco','CA','US'),(204,NULL,'SJU01','Estadio Hiram Bithorn','San Juan',NULL,'PR'),(205,'Springfield Track','SPR01','Hampden Park Race Track','Springfield','MA','US'),(206,NULL,'STL01','Red Stockings Base Ball Park','St. Louis','MO','US'),(207,NULL,'STL02','Grand Avenue Park','St. Louis','MO','US'),(208,NULL,'STL03','Sportsman\'s Park I','St. Louis','MO','US'),(209,NULL,'STL04','Union Grounds','St. Louis','MO','US'),(210,NULL,'STL05','Robison Field','St. Louis','MO','US'),(211,NULL,'STL06','Sportsman\'s Park II','St. Louis','MO','US'),(212,'Busch Stadium I','STL07','Sportsman\'s Park III','St. Louis','MO','US'),(213,'Federal League Park','STL08','Handlan\'s Park','St. Louis','MO','US'),(214,NULL,'STL09','Busch Stadium II','St. Louis','MO','US'),(215,NULL,'STL10','Busch Stadium III','St. Louis','MO','US'),(216,NULL,'STP01','Tropicana Field','St. Petersburg','FL','US'),(217,NULL,'SYD01','Sydney Cricket Ground','Sydney','New South Wales','AU'),(218,'Newell Park','SYR01','Star Park I','Syracuse','NY','US'),(219,NULL,'SYR02','Star Park II','Syracuse','NY','US'),(220,NULL,'SYR03','Iron Pier','Syracuse','NY','US'),(221,NULL,'THR01','Three Rivers Park','Three Rivers','NY','US'),(222,NULL,'TOK01','Tokyo Dome','Tokyo','Tokyo','JP'),(223,NULL,'TOL01','League Park','Toledo','OH','US'),(224,NULL,'TOL02','Tri-State Fair Grounds','Toledo','OH','US'),(225,NULL,'TOL03','Speranza Park','Toledo','OH','US'),(226,NULL,'TOL04','Armory Park','Toledo','OH','US'),(227,NULL,'TOR01','Exhibition Stadium','Toronto','ON','CA'),(228,'Skydome','TOR02','Rogers Centre','Toronto','ON','CA'),(229,NULL,'TRO01','Haymakers\' Grounds','Troy','NY','US'),(230,NULL,'TRO02','Putnam Grounds','Troy','NY','US'),(231,NULL,'WAR01','Rocky Point Park','Warwick','RI','US'),(232,NULL,'WAS01','Olympic Grounds','Washington','DC','US'),(233,NULL,'WAS02','National Grounds','Washington','DC','US'),(234,NULL,'WAS03','Capitol Grounds','Washington','DC','US'),(235,NULL,'WAS04','Athletic Park','Washington','DC','US'),(236,NULL,'WAS05','Swampoodle Grounds','Washington','DC','US'),(237,NULL,'WAS06','Boundary Field','Washington','DC','US'),(238,NULL,'WAS07','American League Park I','Washington','DC','US'),(239,NULL,'WAS08','American League Park II','Washington','DC','US'),(240,NULL,'WAS09','Griffith Stadium','Washington','DC','US'),(241,'D.C. Stadium','WAS10','Robert F. Kennedy Stadium','Washington','DC','US'),(242,NULL,'WAS11','Nationals Park','Washington','DC','US'),(243,NULL,'WAT01','Troy Ball Club Grounds','Watervliet','NY','US'),(244,NULL,'WAV01','Waverly Fairgrounds','Waverly','NJ','US'),(245,NULL,'WEE01','Monitor Grounds','Weehawken','NJ','US'),(246,NULL,'WHE01','Island Grounds','Wheeling','WV','US'),(247,NULL,'WIL01','Union Street Park','Wilmington','DE','US'),(248,NULL,'WIL02','BB&T Ballpark at Bowman Field','Williamsport','PA','US'),(249,NULL,'WNY01','West New York Field Club Grounds','West New York','NJ','US'),(250,NULL,'WOR01','Agricultural County Fair Grounds I','Worcester','MA','US'),(251,NULL,'WOR02','Agricultural County Fair Grounds II','Worcester','MA','US'),(252,NULL,'WOR03','Worcester Driving Park Grounds','Worcester','MA','US'); 46 | /*!40000 ALTER TABLE `parks` ENABLE KEYS */; 47 | UNLOCK TABLES; 48 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 49 | 50 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 51 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 52 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 53 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 54 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 55 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 56 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 57 | 58 | -- Dump completed on 2019-09-20 18:01:59 59 | -------------------------------------------------------------------------------- /baseballdatabank-csv/csv-files/readme2014.txt: -------------------------------------------------------------------------------- 1 | The Lahman Baseball Database 2 | 3 | 2014 Version 4 | Release Date: January 24, 2015 5 | 6 | ---------------------------------------------------------------------- 7 | 8 | README CONTENTS 9 | 0.1 Copyright Notice 10 | 0.2 Contact Information 11 | 12 | 1.0 Release Contents 13 | 1.1 Introduction 14 | 1.2 What's New 15 | 1.3 Acknowledgements 16 | 1.4 Using this Database 17 | 1.5 Revision History 18 | 19 | 2.0 Data Tables 20 | 2.1 MASTER table 21 | 2.2 Batting Table 22 | 2.3 Pitching table 23 | 2.4 Fielding Table 24 | 2.5 All-Star table 25 | 2.6 Hall of Fame table 26 | 2.7 Managers table 27 | 2.8 Teams table 28 | 2.9 BattingPost table 29 | 2.10 PitchingPost table 30 | 2.11 TeamFranchises table 31 | 2.12 FieldingOF table 32 | 2.13 ManagersHalf table 33 | 2.14 TeamsHalf table 34 | 2.15 Salaries table 35 | 2.16 SeriesPost table 36 | 2.17 AwardsManagers table 37 | 2.18 AwardsPlayers table 38 | 2.19 AwardsShareManagers table 39 | 2.20 AwardsSharePlayers table 40 | 2.21 FieldingPost table 41 | 2.22 Appearances table 42 | 2.23 Schools table 43 | 2.24 SchoolsPlayers table 44 | 45 | 46 | ---------------------------------------------------------------------- 47 | 48 | 0.1 Copyright Notice & Limited Use License 49 | 50 | This database is copyright 1996-2015 by Sean Lahman. 51 | 52 | This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. For details see: http://creativecommons.org/licenses/by-sa/3.0/ 53 | 54 | 55 | For licensing information or further information, contact Sean Lahman 56 | at: seanlahman@gmail.com 57 | 58 | ---------------------------------------------------------------------- 59 | 60 | 0.2 Contact Information 61 | 62 | Web site: http://www.baseball1.com 63 | E-Mail : seanlahman@gmail.com 64 | 65 | If you're interested in contributing to the maintenance of this 66 | database or making suggestions for improvement, please consider 67 | joining our mailinglist at: 68 | 69 | http://groups.yahoo.com/group/baseball-databank/ 70 | 71 | If you are interested in similar databases for other sports, please 72 | vist the Open Source Sports website at http://OpenSourceSports.com 73 | 74 | ---------------------------------------------------------------------- 75 | 1.0 Release Contents 76 | 77 | This release of the database can be downloaded in several formats. The 78 | contents of each version are listed below. 79 | 80 | MS Access Versions: 81 | lahman2014.mdb 82 | 2014readme.txt 83 | 84 | SQL version 85 | lahman2043.sql 86 | lahman2014_tables.sql 87 | 2014readme.txt 88 | 89 | Comma Delimited Version: 90 | 2014readme.txt 91 | AllStarFull.csv 92 | Appearances.csv 93 | AwardsManagers.csv 94 | AwardsPlayers.csv 95 | AwardsShareManagers.csv 96 | AwardsSharePlayers.csv 97 | Batting.csv 98 | BattingPost.csv 99 | CollegePlaying.csv 100 | Fielding.csv 101 | FieldingOF.csv 102 | FieldingPost.csv 103 | HallOfFame.csv 104 | Managers.csv 105 | ManagersHalf.csv 106 | Master.csv 107 | Pitching.csv 108 | PitchingPost.csv 109 | Salaries.csv 110 | Schools.csv 111 | SeriesPost.csv 112 | Teams.csv 113 | TeamsFranchises.csv 114 | TeamsHalf.csv 115 | 116 | ---------------------------------------------------------------------- 117 | 1.1 Introduction 118 | 119 | This database contains pitching, hitting, and fielding statistics for 120 | Major League Baseball from 1871 through 2014. It includes data from 121 | the two current leagues (American and National), the four other "major" 122 | leagues (American Association, Union Association, Players League, and 123 | Federal League), and the National Association of 1871-1875. 124 | 125 | This database was created by Sean Lahman, who pioneered the effort to 126 | make baseball statistics freely available to the general public. What 127 | started as a one man effort in 1994 has grown tremendously, and now a 128 | team of researchers have collected their efforts to make this the 129 | largest and most accurate source for baseball statistics available 130 | anywhere. (See Acknowledgements below for a list of the key 131 | contributors to this project.) 132 | 133 | None of what we have done would have been possible without the 134 | pioneering work of Hy Turkin, S.C. Thompson, David Neft, and Pete 135 | Palmer (among others). All baseball fans owe a debt of gratitude 136 | to the people who have worked so hard to build the tremendous set 137 | of data that we have today. Our thanks also to the many members of 138 | the Society for American Baseball Research who have helped us over 139 | the years. We strongly urge you to support and join their efforts. 140 | Please vist their website (www.sabr.org). 141 | 142 | If you have any problems or find any errors, please let us know. Any 143 | feedback is appreciated 144 | 145 | ---------------------------------------------------------------------- 146 | 1.2 What's New in 2014 147 | 148 | Player stats have been updated through 2014 season. 149 | 150 | Removed two deprecated fields from the batting table. The G_batting and 151 | G_old fields were rendered obsolete when we created the appearances table. 152 | They've beenremoved from the batting table starting with this version 153 | 154 | SchoolsPlayers has been replaced with a new table called CollegePlaying. 155 | This reflects advances in the compilation of this data, largely led by 156 | Ted Turocy. The old table reported college attendance for major league 157 | players by listing a start date and end date. The new version has a 158 | separate record for each year that a player attended. This allows 159 | us to better account for players who attended multiple colleges or 160 | skipped a season, as well as to identify teammates. 161 | 162 | 163 | ---------------------------------------------------------------------- 164 | 1.3 Acknowledgements 165 | 166 | Much of the raw data contained in this database comes from the work of 167 | Pete Palmer, the legendary statistician, who has had a hand in most 168 | of the baseball encylopedias published since 1974. He is largely 169 | responsible for bringing the batting, pitching, and fielding data out 170 | of the dark ages and into the computer era. Without him, none of this 171 | would be possible. For more on Pete's work, please read his own 172 | account at: http://sabr.org/cmsfiles/PalmerDatabaseHistory.pdf 173 | 174 | Three people have been key contributors to the work that followed, first 175 | by taking the raw data and creating a relational database, and later 176 | by extending the database to make it more accesible to researchers. 177 | 178 | Sean Lahman launched the Baseball Archive's website back before 179 | most people had heard of the world wide web. Frustrated by the 180 | lack of sports data available, he led the effort to build a 181 | baseball database that everyone could use. Baseball researchers 182 | everywhere owe him a debt of gratitude. Lahman served as an associate 183 | editor for three editions of Total Baseball and contributed to five 184 | editions of The ESPN Baseball Encyclopedia. He has also been active in 185 | developing databases for other sports. 186 | 187 | The work of Sean Forman to create and maintain an online encyclopedia 188 | at "baseball-reference.com" has been remarkable. Recognized as the 189 | premier online reference source, Forman's site provides an oustanding 190 | interface to the raw data. His efforts to help streamline the database 191 | have been extremely helpful. Most importantly, Forman has spearheaded 192 | the effort to provide standards that enable several different baseball 193 | databases to be used together. He was also instrumental in launching 194 | the Baseball Databank, a forum for researchers to gather and share 195 | their work. 196 | 197 | Since 2001, these two Seans have led a group of researchers 198 | who volunteered to maintain and update the database. 199 | 200 | Ted Turocy has done the lion's share of the work to updating the main 201 | data tables since 2012, including significant imporvements to the 202 | demographic data in the master table. In his role as SABR data czar, 203 | he led the effort to document college playing stints for all 204 | major league players. Turocy also spearheads the Chadwick Baseball 205 | Bureau. For more details on his tools and services, visit: 206 | http://chadwick.sourceforge.net/doc/index.html 207 | 208 | A handful of researchers have made substantial contributions to 209 | maintain this database over years. Listed alphabetically, they 210 | are: Derek Adair, Mike Crain, Kevin Johnson, Rod Nelson, Tom Tango, 211 | and Paul Wendt. These folks did much of the heavy lifting, and are 212 | largely responsible for the improvements made since 2000. 213 | 214 | Others who made important contributions include: Dvd Avins, 215 | Clifford Blau, Bill Burgess, Clem Comly, Jeff Burk, Randy Cox, 216 | Mitch Dickerman, Paul DuBois, Mike Emeigh, F.X. Flinn, Bill Hickman, 217 | Jerry Hoffman, Dan Holmes, Micke Hovmoller, Peter Kreutzer, 218 | Danile Levine, Bruce Macleod, Ken Matinale, Michael Mavrogiannis, 219 | Cliff Otto, Alberto Perdomo, Dave Quinn, John Rickert, Tom Ruane, 220 | Theron Skyles, Hans Van Slooten, Michael Westbay, and Rob Wood. 221 | 222 | Many other people have made significant contributions to the database 223 | over the years. The contribution of Tom Ruane's effort to the overall 224 | quality of the underlying data has been tremendous. His work at 225 | retrosheet.org integrates the yearly data with the day-by-day data, 226 | creating a reference source of startling depth. It is unlikely than 227 | any individual has contributed as much to the field of baseball 228 | research in the past five years as Ruane has. 229 | 230 | Sean Holtz helped with a major overhaul and redesign before the 231 | 2000 season. Keith Woolner was instrumental in helping turn 232 | a huge collection of stats into a relational database in the mid-1990s. 233 | Clifford Otto & Ted Nye also helped provide guidance to the early 234 | versions. Lee Sinnis, John Northey & Erik Greenwood helped supply key 235 | pieces of data. Many others have written in with corrections and 236 | suggestions that made each subsequent version even better than what 237 | preceded it. 238 | 239 | The work of the SABR Baseball Records Committee, led by Lyle Spatz 240 | has been invaluable. So has the work of Bill Carle and the SABR 241 | Biographical Committee. David Vincent, keeper of the Home Run Log and 242 | other bits of hard to find info, has always been helpful. The recent 243 | addition of colleges to player bios is the result of much research by 244 | members of SABR's Collegiate Baseball committee. 245 | 246 | Salary data was first supplied by Doug Pappas, who passed away during 247 | the summer of 2004. He was the leading authority on many subjects, 248 | most significantly the financial history of Major League Baseball. 249 | We are grateful that he allowed us to include some of the data he 250 | compiled. His work has been continued by the SABR Business of 251 | Baseball committee. 252 | 253 | Thanks is also due to the staff at the National Baseball Library 254 | in Cooperstown who have been so helpful over the years, including 255 | Tim Wiles, Jim Gates, Bruce Markusen, and the rest of the staff. 256 | 257 | A special debt of gratitude is owed to Dave Smith and the folks at 258 | Retrosheet. There is no other group working so hard to compile and 259 | share baseball data. Their website (www.retrosheet.org) will give 260 | you a taste of the wealth of information Dave and the gang have collected. 261 | 262 | Thanks to all contributors great and small. What you have created is 263 | a wonderful thing. 264 | 265 | ---------------------------------------------------------------------- 266 | 1.4 Using this Database 267 | 268 | This version of the database is available in Microsoft Access 269 | format, SQL files or in a generic, comma delimited format. Because this is a 270 | relational database, you will not be able to use the data in a 271 | flat-database application. 272 | 273 | Please note that this is not a stand alone application. It requires 274 | a database application or some other application designed specifically 275 | to interact with the database. 276 | 277 | If you are unable to import the data directly, you should download the 278 | database in the delimted text format. Then use the documentation 279 | in sections 2.1 through 2.22 of this document to import the data into 280 | your database application. 281 | 282 | ---------------------------------------------------------------------- 283 | 1.5 Revision History 284 | 285 | Version Date Comments 286 | 1.0 December 1992 Database ported from dBase 287 | 1.1 May 1993 Becomes fully relational 288 | 1.2 July 1993 Corrections made to full database 289 | 1.21 December 1993 1993 statistics added 290 | 1.3 July 1994 Pre-1900 data added 291 | 1.31 February 1995 1994 Statistics added 292 | 1.32 August 1995 Statistics added for other leagues 293 | 1.4 September 1995 Fielding Data added 294 | 1.41 November 1995 1995 statistics added 295 | 1.42 March 1996 HOF/All-Star tables added 296 | 1.5-MS October 1996 1st public release - MS Access format 297 | 1.5-GV October 1996 Released generic comma-delimted files 298 | 1.6-MS December 1996 Updated with 1996 stats, some corrections 299 | 1.61-MS December 1996 Corrected error in MASTER table 300 | 1.62 February 1997 Corrected 1914-1915 batters data and updated 301 | 2.0 February 1998 Major Revisions-added teams & managers 302 | 2.1 October 1998 Interim release w/1998 stats 303 | 2.2 January 1999 New release w/post-season stats & awards added 304 | 3.0 November 1999 Major release - fixed errors and 1999 statistics added 305 | 4.0 May 2001 Major release - proofed & redesigned tables 306 | 4.5 March 2002 Updated with 2001 stats and added new biographical data 307 | 5.0 December 2002 Major revision - new tables and data 308 | 5.1 January 2004 Updated with 2003 data, and new pitching categories 309 | 5.2 November 2004 Updated with 2004 season statistics. 310 | 5.3 December 2005 Updated with 2005 season statistics. 311 | 5.4 December 2006 Updated with 2006 season statistics. 312 | 5.5 December 2007 Updated with 2007 season statistics. 313 | 5.6 December 2008 Updated with 2008 season statistics. 314 | 5.7 December 2009 Updated for 2009 and added several tables. 315 | 5.8 December 2010 Updated with 2010 season statistics. 316 | 5.9 December 2011 Updated for 2011 and removed obsolete tables. 317 | 2012 December 2012 Updated with 2012 season statistics 318 | 2013 December 2013 Updated with 2013 season statistics 319 | 2014 December 2014 Updated with 2013 season statistics 320 | 321 | 322 | 323 | ------------------------------------------------------------------------------ 324 | 2.0 Data Tables 325 | 326 | The design follows these general principles. Each player is assigned a 327 | unique number (playerID). All of the information relating to that player 328 | is tagged with his playerID. The playerIDs are linked to names and 329 | birthdates in the MASTER table. 330 | 331 | The database is comprised of the following main tables: 332 | 333 | MASTER - Player names, DOB, and biographical info 334 | Batting - batting statistics 335 | Pitching - pitching statistics 336 | Fielding - fielding statistics 337 | 338 | It is supplemented by these tables: 339 | 340 | AllStarFull - All-Star appearances 341 | HallofFame - Hall of Fame voting data 342 | Managers - managerial statistics 343 | Teams - yearly stats and standings 344 | BattingPost - post-season batting statistics 345 | PitchingPost - post-season pitching statistics 346 | TeamFranchises - franchise information 347 | FieldingOF - outfield position data 348 | FieldingPost- post-season fieldinf data 349 | ManagersHalf - split season data for managers 350 | TeamsHalf - split season data for teams 351 | Salaries - player salary data 352 | SeriesPost - post-season series information 353 | AwardsManagers - awards won by managers 354 | AwardsPlayers - awards won by players 355 | AwardsShareManagers - award voting for manager awards 356 | AwardsSharePlayers - award voting for player awards 357 | Appearances - details on the positions a player appeared at 358 | Schools - list of colleges that players attended 359 | CollegePlaying - list of players and the colleges they attended 360 | 361 | 362 | Sections 2.1 through 2.24 of this document describe each of the tables in 363 | detail and the fields that each contains. 364 | 365 | 366 | -------------------------------------------------------------------------- 367 | 2.1 MASTER table 368 | 369 | 370 | playerID A unique code asssigned to each player. The playerID links 371 | the data in this file with records in the other files. 372 | birthYear Year player was born 373 | birthMonth Month player was born 374 | birthDay Day player was born 375 | birthCountry Country where player was born 376 | birthState State where player was born 377 | birthCity City where player was born 378 | deathYear Year player died 379 | deathMonth Month player died 380 | deathDay Day player died 381 | deathCountry Country where player died 382 | deathState State where player died 383 | deathCity City where player died 384 | nameFirst Player's first name 385 | nameLast Player's last name 386 | nameGiven Player's given name (typically first and middle) 387 | weight Player's weight in pounds 388 | height Player's height in inches 389 | bats Player's batting hand (left, right, or both) 390 | throws Player's throwing hand (left or right) 391 | debut Date that player made first major league appearance 392 | finalGame Date that player made first major league appearance (blank if still active) 393 | retroID ID used by retrosheet 394 | bbrefID ID used by Baseball Reference website 395 | 396 | 397 | ------------------------------------------------------------------------------ 398 | 2.2 Batting Table 399 | playerID Player ID code 400 | yearID Year 401 | stint player's stint (order of appearances within a season) 402 | teamID Team 403 | lgID League 404 | G Games 405 | AB At Bats 406 | R Runs 407 | H Hits 408 | 2B Doubles 409 | 3B Triples 410 | HR Homeruns 411 | RBI Runs Batted In 412 | SB Stolen Bases 413 | CS Caught Stealing 414 | BB Base on Balls 415 | SO Strikeouts 416 | IBB Intentional walks 417 | HBP Hit by pitch 418 | SH Sacrifice hits 419 | SF Sacrifice flies 420 | GIDP Grounded into double plays 421 | 422 | ------------------------------------------------------------------------------ 423 | 2.3 Pitching table 424 | 425 | playerID Player ID code 426 | yearID Year 427 | stint player's stint (order of appearances within a season) 428 | teamID Team 429 | lgID League 430 | W Wins 431 | L Losses 432 | G Games 433 | GS Games Started 434 | CG Complete Games 435 | SHO Shutouts 436 | SV Saves 437 | IPOuts Outs Pitched (innings pitched x 3) 438 | H Hits 439 | ER Earned Runs 440 | HR Homeruns 441 | BB Walks 442 | SO Strikeouts 443 | BAOpp Opponent's Batting Average 444 | ERA Earned Run Average 445 | IBB Intentional Walks 446 | WP Wild Pitches 447 | HBP Batters Hit By Pitch 448 | BK Balks 449 | BFP Batters faced by Pitcher 450 | GF Games Finished 451 | R Runs Allowed 452 | SH Sacrifices by opposing batters 453 | SF Sacrifice flies by opposing batters 454 | GIDP Grounded into double plays by opposing batter 455 | ------------------------------------------------------------------------------ 456 | 2.4 Fielding Table 457 | 458 | playerID Player ID code 459 | yearID Year 460 | stint player's stint (order of appearances within a season) 461 | teamID Team 462 | lgID League 463 | Pos Position 464 | G Games 465 | GS Games Started 466 | InnOuts Time played in the field expressed as outs 467 | PO Putouts 468 | A Assists 469 | E Errors 470 | DP Double Plays 471 | PB Passed Balls (by catchers) 472 | WP Wild Pitches (by catchers) 473 | SB Opponent Stolen Bases (by catchers) 474 | CS Opponents Caught Stealing (by catchers) 475 | ZR Zone Rating 476 | 477 | ------------------------------------------------------------------------------ 478 | 2.5 AllstarFull table 479 | 480 | playerID Player ID code 481 | YearID Year 482 | gameNum Game number (zero if only one All-Star game played that season) 483 | gameID Retrosheet ID for the game idea 484 | teamID Team 485 | lgID League 486 | GP 1 if Played in the game 487 | startingPos If player was game starter, the position played 488 | ------------------------------------------------------------------------------ 489 | 2.6 HallOfFame table 490 | 491 | playerID Player ID code 492 | yearID Year of ballot 493 | votedBy Method by which player was voted upon 494 | ballots Total ballots cast in that year 495 | needed Number of votes needed for selection in that year 496 | votes Total votes received 497 | inducted Whether player was inducted by that vote or not (Y or N) 498 | category Category in which candidate was honored 499 | needed_note Explanation of qualifiers for special elections 500 | ------------------------------------------------------------------------------ 501 | 2.7 Managers table 502 | 503 | playerID Player ID Number 504 | yearID Year 505 | teamID Team 506 | lgID League 507 | inseason Managerial order. Zero if the individual managed the team 508 | the entire year. Otherwise denotes where the manager appeared 509 | in the managerial order (1 for first manager, 2 for second, etc.) 510 | G Games managed 511 | W Wins 512 | L Losses 513 | rank Team's final position in standings that year 514 | plyrMgr Player Manager (denoted by 'Y') 515 | 516 | ------------------------------------------------------------------------------ 517 | 2.8 Teams table 518 | 519 | yearID Year 520 | lgID League 521 | teamID Team 522 | franchID Franchise (links to TeamsFranchise table) 523 | divID Team's division 524 | Rank Position in final standings 525 | G Games played 526 | GHome Games played at home 527 | W Wins 528 | L Losses 529 | DivWin Division Winner (Y or N) 530 | WCWin Wild Card Winner (Y or N) 531 | LgWin League Champion(Y or N) 532 | WSWin World Series Winner (Y or N) 533 | R Runs scored 534 | AB At bats 535 | H Hits by batters 536 | 2B Doubles 537 | 3B Triples 538 | HR Homeruns by batters 539 | BB Walks by batters 540 | SO Strikeouts by batters 541 | SB Stolen bases 542 | CS Caught stealing 543 | HBP Batters hit by pitch 544 | SF Sacrifice flies 545 | RA Opponents runs scored 546 | ER Earned runs allowed 547 | ERA Earned run average 548 | CG Complete games 549 | SHO Shutouts 550 | SV Saves 551 | IPOuts Outs Pitched (innings pitched x 3) 552 | HA Hits allowed 553 | HRA Homeruns allowed 554 | BBA Walks allowed 555 | SOA Strikeouts by pitchers 556 | E Errors 557 | DP Double Plays 558 | FP Fielding percentage 559 | name Team's full name 560 | park Name of team's home ballpark 561 | attendance Home attendance total 562 | BPF Three-year park factor for batters 563 | PPF Three-year park factor for pitchers 564 | teamIDBR Team ID used by Baseball Reference website 565 | teamIDlahman45 Team ID used in Lahman database version 4.5 566 | teamIDretro Team ID used by Retrosheet 567 | 568 | ------------------------------------------------------------------------------ 569 | 2.9 BattingPost table 570 | 571 | yearID Year 572 | round Level of playoffs 573 | playerID Player ID code 574 | teamID Team 575 | lgID League 576 | G Games 577 | AB At Bats 578 | R Runs 579 | H Hits 580 | 2B Doubles 581 | 3B Triples 582 | HR Homeruns 583 | RBI Runs Batted In 584 | SB Stolen Bases 585 | CS Caught stealing 586 | BB Base on Balls 587 | SO Strikeouts 588 | IBB Intentional walks 589 | HBP Hit by pitch 590 | SH Sacrifices 591 | SF Sacrifice flies 592 | GIDP Grounded into double plays 593 | 594 | ------------------------------------------------------------------------------ 595 | 2.10 PitchingPost table 596 | 597 | playerID Player ID code 598 | yearID Year 599 | round Level of playoffs 600 | teamID Team 601 | lgID League 602 | W Wins 603 | L Losses 604 | G Games 605 | GS Games Started 606 | CG Complete Games 607 | SHO Shutouts 608 | SV Saves 609 | IPOuts Outs Pitched (innings pitched x 3) 610 | H Hits 611 | ER Earned Runs 612 | HR Homeruns 613 | BB Walks 614 | SO Strikeouts 615 | BAOpp Opponents' batting average 616 | ERA Earned Run Average 617 | IBB Intentional Walks 618 | WP Wild Pitches 619 | HBP Batters Hit By Pitch 620 | BK Balks 621 | BFP Batters faced by Pitcher 622 | GF Games Finished 623 | R Runs Allowed 624 | SH Sacrifice Hits allowed 625 | SF Sacrifice Flies allowed 626 | GIDP Grounded into Double Plays 627 | 628 | ------------------------------------------------------------------------------ 629 | 2.11 TeamFranchises table 630 | 631 | franchID Franchise ID 632 | franchName Franchise name 633 | active Whetehr team is currently active (Y or N) 634 | NAassoc ID of National Association team franchise played as 635 | 636 | ------------------------------------------------------------------------------ 637 | 2.12 FieldingOF table 638 | 639 | playerID Player ID code 640 | yearID Year 641 | stint player's stint (order of appearances within a season) 642 | Glf Games played in left field 643 | Gcf Games played in center field 644 | Grf Games played in right field 645 | 646 | ------------------------------------------------------------------------------ 647 | 2.13 ManagersHalf table 648 | 649 | playerID Manager ID code 650 | yearID Year 651 | teamID Team 652 | lgID League 653 | inseason Managerial order. One if the individual managed the team 654 | the entire year. Otherwise denotes where the manager appeared 655 | in the managerial order (1 for first manager, 2 for second, etc.) 656 | half First or second half of season 657 | G Games managed 658 | W Wins 659 | L Losses 660 | rank Team's position in standings for the half 661 | 662 | ------------------------------------------------------------------------------ 663 | 2.14 TeamsHalf table 664 | 665 | yearID Year 666 | lgID League 667 | teamID Team 668 | half First or second half of season 669 | divID Division 670 | DivWin Won Division (Y or N) 671 | rank Team's position in standings for the half 672 | G Games played 673 | W Wins 674 | L Losses 675 | 676 | ------------------------------------------------------------------------------ 677 | 2.15 Salaries table 678 | 679 | yearID Year 680 | teamID Team 681 | lgID League 682 | playerID Player ID code 683 | salary Salary 684 | 685 | ------------------------------------------------------------------------------ 686 | 2.16 SeriesPost table 687 | 688 | yearID Year 689 | round Level of playoffs 690 | teamIDwinner Team ID of the team that won the series 691 | lgIDwinner League ID of the team that won the series 692 | teamIDloser Team ID of the team that lost the series 693 | lgIDloser League ID of the team that lost the series 694 | wins Wins by team that won the series 695 | losses Losses by team that won the series 696 | ties Tie games 697 | ------------------------------------------------------------------------------ 698 | 2.17 AwardsManagers table 699 | 700 | playerID Manager ID code 701 | awardID Name of award won 702 | yearID Year 703 | lgID League 704 | tie Award was a tie (Y or N) 705 | notes Notes about the award 706 | 707 | ------------------------------------------------------------------------------ 708 | 2.18 AwardsPlayers table 709 | 710 | playerID Player ID code 711 | awardID Name of award won 712 | yearID Year 713 | lgID League 714 | tie Award was a tie (Y or N) 715 | notes Notes about the award 716 | 717 | ------------------------------------------------------------------------------ 718 | 2.19 AwardsShareManagers table 719 | 720 | awardID name of award votes were received for 721 | yearID Year 722 | lgID League 723 | playerID Manager ID code 724 | pointsWon Number of points received 725 | pointsMax Maximum numner of points possible 726 | votesFirst Number of first place votes 727 | 728 | ------------------------------------------------------------------------------ 729 | 2.20 AwardsSharePlayers table 730 | 731 | awardID name of award votes were received for 732 | yearID Year 733 | lgID League 734 | playerID Player ID code 735 | pointsWon Number of points received 736 | pointsMax Maximum numner of points possible 737 | votesFirst Number of first place votes 738 | 739 | ------------------------------------------------------------------------------ 740 | 2.21 FieldingPost table 741 | 742 | playerID Player ID code 743 | yearID Year 744 | teamID Team 745 | lgID League 746 | round Level of playoffs 747 | Pos Position 748 | G Games 749 | GS Games Started 750 | InnOuts Time played in the field expressed as outs 751 | PO Putouts 752 | A Assists 753 | E Errors 754 | DP Double Plays 755 | TP Triple Plays 756 | PB Passed Balls 757 | SB Stolen Bases allowed (by catcher) 758 | CS Caught Stealing (by catcher) 759 | 760 | ------------------------------------------------------------------------------ 761 | 2.22 Appearances table 762 | 763 | yearID Year 764 | teamID Team 765 | lgID League 766 | playerID Player ID code 767 | G_all Total games played 768 | GS Games started 769 | G_batting Games in which player batted 770 | G_defense Games in which player appeared on defense 771 | G_p Games as pitcher 772 | G_c Games as catcher 773 | G_1b Games as firstbaseman 774 | G_2b Games as secondbaseman 775 | G_3b Games as thirdbaseman 776 | G_ss Games as shortstop 777 | G_lf Games as leftfielder 778 | G_cf Games as centerfielder 779 | G_rf Games as right fielder 780 | G_of Games as outfielder 781 | G_dh Games as designated hitter 782 | G_ph Games as pinch hitter 783 | G_pr Games as pinch runner 784 | 785 | 786 | ------------------------------------------------------------------------------ 787 | 2.23 Schools table 788 | schoolID school ID code 789 | schoolName school name 790 | schoolCity city where school is located 791 | schoolState state where school's city is located 792 | schoolNick nickname for school's baseball team 793 | 794 | 795 | ------------------------------------------------------------------------------ 796 | 2.24 CollegePlaying table 797 | playerid Player ID code 798 | schoolID school ID code 799 | year year 800 | 801 | 802 | 803 | --------------------------------------------------------------------------------