
Team Player Design Project 

SE 512
Winter 1989
14 March 1989


Section 1   INTRODUCTION 


1.1  Definition

Team Player is an on-line system to support rotisserie baseball leagues formed 
by sports enthusiasts. A rotisserie league is a simulated baseball league in 
which a group of people, participating in a pool, choose teams consisting of 
professional baseball players.  A draft is held yearly and each participant 
sets up their own team (one or more players at each position and several 
pitchers). Team Player allows league creation, league modification, 
statistical tracking, and report generation on an IBM PC or true compatible. 


1.3  Scenario

After the draft has been held, the administrator sets up the league via on-
line entry screens.  The information captured for the entire league includes 
league name, point distributions (defaults can be used), and the number of 
players allowed at each position.  Next, information on individual teams is 
entered, teams being identified by team name and owner name.  The drafted 
players are assigned to their individual teams and given a playing position. 

Once all the teams have been set up, year-to-date (YTD) statistics are 
gathered for all players.  Statistics can be input to Team Player either 
automatically or manually.  For automatic input, the administrator downloads 
the YTD statistics from an on-line service such as CompuServe to a text file 
that is read by Team Player.  If done manually, the software will present 
screens for all players whose statistics are being kept.  The administrator 
will enter values as shown weekly in the newspaper sports section, and the 
software will write these values to a text file read by Team Player. 



Section 2   REQUIREMENTS SPECIFICATION


2.1  Product Requirements

This section specifies the general requirements for Team Player.  Team Player 
will: 
P-L-+---T1----+-T--2----T----3--T-+----4T---+---T5----+-T--6----T----7--T-+--R

* handle all league transactions and provide means for storage of league data 
* provide menu driven, user friendly screens 
* provide on-line forms for manual entry of weekly player statistics 
* allow automatic entry of weekly player statistics downloaded to a text file 
  from a sports information service such as CompuServe 
* allow manual entry and modification of league data 
* provide access and browse of text file for league rules and tutorial 
* assign points for each league structure 
* calculate weekly point totals 
* generate reports 
L---+---T1----+-T--2----T----3--T-+----4T---+---T5----+-T--6----T----7--T-+--R


2.2  Context Diagram

The Context Diagram for Team Player is shown in Figure 1.  The main 
source/sink is the baseball fan who provides all information necessary to 
configure the league and who receives reports from the system.  Professional 
baseball statistics are input to the system either manually from information 
taken from the newspaper, or automatically downloaded from a sports 
information service such as CompuServe.                                       


2.3  Level 0 Data Flow Diagram

The Team Player Level 0 DFD identifies the three main processes that make up 
the system.  Each process is reviewed in the following section. 


2.4  Process Specifications

Process 1.0 - Configure League:

This process handles all of the functions associated with setting up and 
modifying league setups.  If a user is setting up a new league this process 
steps the user through all the steps required to input the required 
configuration data.  This data is then stored in the league and team files.  
If the user is modifying an existing league then the program prompts the user 
through selecting what they want modified and inputs the changes to the league 
or team configuration. 

PROCESS SPEC:


Process 2.0 - Update Stats:

The purpose of this module is to update the all_players ytd_stats file and 
calculate the weekly statistics.  The weekly statistics are input by the user 
either by prompting the user thru a manual update or by reading in a DOS file 
full of the statistics and automatically doing the update.  After the update 
has been completed the league weekly points are calculated. 

PROCESS SPEC 2:

2.1  Get league name and update choice
2.2  Move this weeks all_players_ytd_stats to previous week
2.3  If update choice is manual then do
                Step user thru data entry for each player assigned
                To a team and store information in
                All_players_ytd_stats
     Else   
                Do an automatic update by getting a dos file name
                From user and read in statistics from the file.
                Store new statistics in all_players_ytd_stats.
2.4  Calculate the weekly point totals for each player and
     store in league weekly points


Process 3.0 - Generate Reports:

This procedure allows the user to select a desired item to be reported on and 
outputs the desired information.  The possible reports to be selected are YTD 
league report, weekly league report, YTD team report, weekly team report, 
player ranking, and pro player statistics. 

PROCESS SPEC:

3.1  PROMPT USER FOR REPORT SELECTION
3.2  IF SELECTION IS YTD LEAGUE REPORT THEN
                GET LEAGUE NAME
                GET TEAMS ON THE LEAGUE
                OUTPUT YTD POINTS FOR THE LEAGUE
3.3  IF SELECTION IS WEEKLY LEAGUE REPORT THEN
                GET LEAGUE NAME
                GET TEAMS ON THE LEAGUE
                OUTPUT WEEKLY TOTALS FOR THE LEAGUE
3.4  IF SELECTION IS YTD TEAM REPORT THEN
                GET TEAM NAME
                OUTPUT YTD TOTAL FOR TEAM
3.5  IF SELECTION IS WEEKLY TEAM REPORT THEN
                GET TEAM NAME
                OUTPUT WEEKLY TOTAL FOR TEAM
3.6  IF SELECTION IS PLAYER RANKING
                OUTPUT EACH PLAYERS POINT TOTALS STARTING WITH
                THE PLAYER WITH THE HIGHEST POINT ALL THE WAY DOWN
                TO THE PLAYER WITH THE LOWEST POINTS.
3.7  IF SELECTION IS PRO PLAYER STATISTICS
                OUTPUT ALL PLAYERS STATISTICS IN YTD PLAYER STATS.



Section 3   DATA DEFINITIONS 


3.1  Data Dictionary

This section includes the Team Player Data Dictionary in DeMarco notation.

LEAGUE_CONFIGURATION = {league_name + league_values + {team_name + owner + 
{player_name + position}}} 

PLAYER_LIST = {p-id + player_name + position}
               

PRO_TEAM_LIST = {pt-id + pro_team_name}
                 

TEAM_FILE = {t-id + team_name + owner + league_name}  *t-id is unique 
             

TEAM_PLAYER_FILE = {t-id + p-id}
                       

ALL_PLAYERS_YTD_STATS = {p-id + position +  pt-id + player_stats}
                                      
  alias: professional_statistics    

PLAYER_STATS = {sp_stats | rp_stats | bt_stats}

  SP_STATS = {wins + losses + earned_runs + innings + complete_games + 
    strike_outs + walks} * starting pitcher *

  RP_STATS = {wins + losses + earned_runs + innings + saves + strike_outs + 
    walks}  * relief pitcher *

  BT_STATS = {singles + doubles + triples + home_runs + runs_scored 
    *batter *  + runs_batted_in + stolen_bases} 

  POSITION = | relief_pitcher  = 0 |
             | starting_pitcher= 1 |
             | first_base      = 2 |
             | second_base     = 3 |
             | third_base      = 4 |
             | catcher         = 5 |
             | short_stop      = 6 |
             | left_field      = 7 |
             | right_field     = 8 |
             | center_field    = 9 |

LEAGUE_ATTRIBUTES = {league_name + league_values}
                     

 LEAGUE_VALUES= point_values_rules + no_pitchers + no_relievers + no_batters


  POINT_VALUES_RULES = rules_for_starting_pitchers + rules_for_relief_pitchers 
  + rules_for_batters  * point values rules for each league *

  RULES_FOR_STARTING_PITCHERS = points-for-win-p + points_for_losses-p +
                 points_for_earned_runs_p + points_for_innings_p +
                 points_for_complete_games_p + points_for_strikeouts_p +
                 points_for_walks_p

  RULES_FOR_RELIEF_PITCHERS = points-for-win-r + points_for_losses-r +
                 points_for_earned_runs_r + points_for_innings_r +
                 points_for_saves + points_for_strikeouts_r +
                 points_for_walks_r

  RULES_FOR_BATTERS = points_for_singles + points_for_doubles +
  *all other*    points_for_triples + points_for_home_runs +
  *positions*    points_for_runs_scored + points_for_runs_batted_in +
                 points_for_stolen_bases

LEAGUE_WEEKLY_POINTS= {t-id + p-id + week + point_totals}
                             
 * details of points for each player for each week *

 POINT_TOTALS = {sp_totals | rp_totals | bt_totals}

   SP_TOTALS = {wins_points_p + losses_points_p + earned_runs_points-p + 
     *starting  innings_points_p + complete_games_points + 
     strike_outs_points_p + pitcher*  walks_points_p}      

   RP_TOTALS = {wins_points_r + losses_points_r + earned_runs_points-r + 
     *relief    innings_points_r + saves_points + strike_outs_points_r +
      pitcher*  walks_points_r}

   BT_TOTALS = {singles_points + doubles_points + triples_points + 
     *batter*   home_runs_points + runs_scored_points + runs_batted_in_points + 
                stolen_bases_points}



3.3  Data Item Definitions 

Data Items are defined as follows:

ANY_BINARY = [1|2|3|4|.....|256]

ANY_CHARACTER = [A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z| |]

ANY_DIGIT = [1|2|3|4|5|6|7|8|9|0]

COMPLETE_GAMES = 1{any_digit}2

COMPLETE_GAMES_POINTS = any_binary

DOUBLES = 1{any_digit}2

DOUBLES_POINTS = any_binary

EARNED_RUNS = 1{any_digit}2

EARNED_RUNS_POINTS_P = any_binary

EARNED_RUNS_POINTS_R = any_binary

HOME_RUNS = 1{any_digit}2

HOME_RUNS_POINTS = any_binary

INNINGS = 1{any_digit}2

INNINGS_POINTS_P = any_binary

INNINGS_POINTS_R = any_binary

LEAGUE_NAME = 1{any_character | any_digit}15

LOSSES = 1{any_digit}2

LOSSES_POINTS_P = any_binary

LOSSES_POINTS_R = any_binary

NO_BATTERS = any_binary

NO_PITCHERS = any_binary

NO_RELIEVERS = any_binary

OWNER  = 1{any_character}25

P-ID = 1{any_binary}2

PLAYER_NAME = 1{any_character}25

POINTS_FOR_COMPLETE_GAMES_P = any_binary

POINTS_FOR_DOUBLES = any_binary

POINTS_FOR_EARNED_RUNS_P = any_binary

POINTS_FOR_EARNED_RUNS_R = any_binary

POINTS_FOR_HOME_RUNS = any_binary

POINTS_FOR_INNINGS_P = any_binary

POINTS_FOR_INNINGS_R = any_binary            WALKS = 1{any_digit}2      
                                                                        
POINTS_FOR_LOSSES_P = any_binary             WALKS_POINTS_P = any_binary
                                                                        
POINTS_FOR_LOSSES_R = any_binary             WALKS_POINTS_R = any_binary
                                                                        
POINTS_FOR_RUNS_BATTED_IN = any_binary       WEEK = any_binary          
                                                                        
POINTS_FOR_RUNS_SCORED = any_binary          WINS = 1{any_digit}2       
                                                                        
POINTS_FOR_SAVES = any_binary                WINS_POINTS_P = any_binary 
                                                                        
POINTS_FOR_SINGLES = any_binary              WINS_POINTS_R = any_binary 

POINTS_FOR_STRIKEOUTS_P = any_binary

POINTS_FOR_STRIKEOUTS_R = any_binary

POINTS_FOR_TRIPLES = any_binary

POINTS_FOR_WALKS_P = any_binary

POINTS_FOR_WALKS_R = any_binary

POINTS_FOR_WIN_P = any_binary

POINTS_FOR_WIN_R = any_binary

PRO_TEAM_NAME = 1{any_character}25

PT-ID = any_binary

RUNS_BATTED_IN = 1{any_digit}2

RUNS_BATTED_IN_POINTS = any_binary

RUNS_SCORED = 1{any_digit}2

RUNS_SCORED_POINTS = any_binary

SAVES = 1{any_digit}2

SAVES_POINTS = any_binary

SINGLES = 1{any_digit}2

SINGLES_POINTS = any_binary

STOLEN_BASES = 1{any_digit}2

STOLEN_BASES_POINTS = any_binary

STRIKE_OUTS = 1{any_digit}2

STRIKE_OUTS_POINTS_P = any_binary

STRIKE_OUTS_POINTS_R = any_binary

T-ID = any_binary

TEAM_NAME = 1{any_character | any_digit}15

TRIPLES = 1{any_digit}2

TRIPLES_POINTS = any_binary


3.4  Overview of Data Stores

The data stores for Team Player are shown here.  


L---+---T1-    -T--2----T----3--T-+----4T---+---T5----+-T--6-                                           R
  PLAYER_LIST   Ŀ
                 p_id  player_name         position 
                Ĵ
                  1    Alvin Davis            3     
                  2    George Brett           5     
                  3    Mickey Mantle          8     
                  4    Willie Mays            8     
                


              Ŀ 
              p_id positionpt_idstat1stat2stat3stat4stat5stat6stat7 
              Ĵ 
               273    2       8   98   40   2    15   82   67    1  
                49    4       7   31   28   8    34  144  101    0  
               651    5      13  150   47   2     8   71  107    0  
                35    1      13   24    4  90   250   12  205  100  
                22    0      24    5    5  50    80   12   40   25  
               
                                                                               

              Ŀ      
              t_id p_id weekpt1  pt2  pt3  pt4  pt5  pt6  pt7       
              Ĵ      
                1   273  1   10    2    6    8    3    3    0       
                1   651  1    6    2    0    0    5    4    2       
                2    35  1   26  -10   -6    8    0    7    3       
                1   273  2    3    2    0    0    4    2    1       
                1   651  2    8    0    3    4    3    3    1       
                2    35  2    0    0    0    0    0    0    0       
                1   273  3    6    0    0    8    3    3    1       
                1   651  3    5    6    3    0    2    1    0       
                2    35  3    0  -10   -5    4    0    4   -6       
              
                                                                               
  PRO_TEAM_LIST     Ŀ          
                      pt_id    pro_team_name                       
                    Ĵ          
                        0      Boston Red Sox                      
                        1      New York Yankees                    
                        2      Detroit Tigers                      
                        3      Cleveland Indians                   
                        4      Milwaukee Brewers                   
                        5      Baltimore Orioles                   
                        6      Toronto Blue Jays                   
                        7      Seattle Mariners                    
                        8      Chicago White Sox                   
                        9      Kansas City Royals                  
                       10      California Angels                   
                       11      Texas Rangers                       
                       12      Oakland Athletics                   
                       13      Minnesota Twins                     
                       14      New York Mets                       
                       15      Philadelphia Phillies               
                       16      St. Louis Cardinals                 
                       17      Chicago Cubs                        
                       18      Pittsburgh Pirates                  
                       19      Montreal Expos                      
                       20      Los Angeles Dodgers                 
                       21      Houston Astros                      
                       22      Cincinnatti Reds                    
                       23      San Diego Padres                    
                       24      San Francisco Giants                
                       25      Atlanta Braves                      
                              





  TEAM_FILE                                                                  
            Ŀ
             t_id   team_name       owner               league_name     
            Ĵ
               0    Grizzlies       Deb Bear            Engineers       
               1    Bat Busters     Chris Halasz        Crashers        
               2    Super Cynics    Lance Lovick        Engineers       
               3    No Sox          Pamela Perrott      Engineers       
               4    Big Boppers     Scott Love          Crashers        
            




  TEAM_PLAYER_FILE     ķ
                        t_id      p_id   
                       Ķ
                          1         50   
                          1        265   
                          1         37   
                          1         28   
                          1        255   
                          1         76   
                          2         81   
                          2          3   
                          2         98   
                       Ľ
                  


3.5  Database Size Comparisons
L---+---T1----+-T--2----T----3--T-+----4T---+---T5----+-T--6----T----7--T-+--R

When initial system design was completed, the database sizes were as shown in 
"before" below.  The files were larger than we wanted, so we came up with 
changes to decrease storage space.  It was decided that 15 bytes was adequate 
to store both team and league names, and that a number of other fields could 
be reduced as well.  Additionally, we included a player list, team list and 
pro_team list each with single bit ID's that would be stored in other files.  
Net_totals were dropped from league_weekly_points since they can be 
calculated.  After all changes were made, the sizes were as shown in the 
"after" column. 

L---+---T1----+-T--2----T----3--T-+----4T---+---T5----+-T--6-                                                 R
.s:8
.x:17
ͻ
                                               RECORD   RECORD    NUMBER      TOTAL      TOTAL   
                                                SIZE     SIZE       OF        BYTES      BYTES   
                                               BEFORE   AFTER    RECORDS     BEFORE      AFTER   
͹
 ALL_PLAYERS_YTD_STATS = { player_name +         25                                              
                           p_id +                         2                                      
 * 2 files like this *     position +             1       1        625                           
 * are kept, one for *     pro_team_name +       25              (times                          
 * this week and one *     pt_id +                        1         2                            
 * for last week     *     stats }              2*7     2*7       files)                         
                                                                                                 
                           TOTAL                 65      18                   81,250     22,500  
͹
 TEAM_FILE = { team_name +                       25      15                                      
               t_id +                                     1        20                            
 * t_id is *   owner +                           25      25       times                          
 * unique  *   league_name }                     25      15     number of                        
                                                                 leagues                         
               TOTAL                             75      56                   15,000     11,200  
͹
                                                                                                 
 TEAM_PLAYER_FILE = { team_name +                25                460                           
                      t_id +                              1       times                          
                      player_name +              25             number of                        
                      p_id }                              2      leagues                         
                                                                                                 
                      TOTAL                      50       3                  230,000     13,800  
͹
                                                                                                 
 LEAGUE_FILE = { league_name +                   25      15         1                            
                 league_values }               24*2    24*1        per                           
                                                                 league                          
                 TOTAL                           73      39                      730        390  
͹
                                                                                                 
 LEAGUE_WEEKLY_POINTS = { team_name +            25                                              
                          t_id +                          1                                      
                          player_name +          25                 26                           
                          p_id +                          2       weeks                          
                          week +                  2       1       times                          
                          point_totals +        7*2     7*1        460                           
                          net_totals }            3              players                         
                                                                                                 
                          TOTAL                  69      11                8,250,000   1,315,600 
ͼ
ͻ
                                               RECORD   RECORD    NUMBER      TOTAL      TOTAL   
                                                SIZE     SIZE       OF        BYTES      BYTES   
                                               BEFORE   AFTER    RECORDS     BEFORE      AFTER   
͹
                                                                                                 
 PLAYER_LIST = { p_id +                                   2                                      
                 player_name +                           25        625                           
                 position }                               1                                      
                                                                                                 
                 TOTAL                                   28                               17,500 
͹
                                                                                                 
 PRO_TEAM_LIST = {pt_id +                                 1                                      
                  pro_team_name }                        25         26                           
                                                                                                 
                  TOTAL                                  26                                  676 
͹
                                                                                                 
 ***    GRAND TOTAL    ***                                                                       
                                                                           8,576,980   1,381,666 
ͼ
.s:6
L---+---T1----+-T--2----T----3--T-+----4T---+---T5----+-T--6-R
.x:10

It seemed clear at this point that the league_weekly_points 
file would have to be on disk.  So would the 
all_players_YTD_stats file.  These are accessed mainly at 
report time and can be read and reported on at the time 
statistics are downloaded or when reports are generated. 

We then decided to use a linked list to link the league to its 
teams, and the teams in a league to its players.  Since 
several of the files above are merely for linking these 
together, we thought this scheme might be useful. 

We would keep the player_list file.  This is a list of all pro 
players, whether they are on a team in a league or not.  This 
would be implemented as an array of 1000 cells.  There are 
about 625 professional players (26 teams of 24 players), but 
with some leaving the pros and others replacing them during 
the season, we wanted to allow for more total players in a 
year.  Initially, we would sort the players alphabetically as 
we did the first statistics download and assign them p-id's.  
As others needed to be added, they would be added at the end. 

