Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Description In this project, you are expected to build a small in-memory database that stores data related to NBA coaches and teams. Users can

image text in transcribed

image text in transcribed

1 Description In this project, you are expected to build a small in-memory database that stores data related to NBA coaches and teams. Users can send simple queries to this database and add new data to the database. The database has two tables (or relations) one for coaches and one for teams. The schemas for the two tables are as follows: coaches Coach ID: 7 or fewer capital letters followed by 2 digits, season: 4 digit year, first name: any reasonable English name, last name: any reasonable English name, season win : non-negative integer, season loss : non-negative integer, playoff win : non-negative integer, playoff loss : non-negative integer, team: capital letters and/or digits teams team ID: capital letters and/or digits, Location: American city name (one or two words), Name : team name, League: one capital letter You must follow these schemas exactly. Your database should have a command-line interface to allow users to add data and send in queries. The interface should accept the following commands: 1. add_coach: add a new record describing the performance of one coach in one season. It should have the following 9 arguments: ID, season, first name, last name, season wins, season losses, playoff wins, playoff losses, and team, the types of which should match the schema of the "coaches" relation above; 2. add_team: add a new record with one team's basic information. It should be followed by the following 4 arguments: ID, location, name, and league, the types of which should match the schema of the "teams" table; 3. load_coaches: load multiple coach and season records from a file. The argument should be the name of the file to read. The file stores each record in one line of text, and different fields of the line/record are separated by commas. In our sample files, you may find empty attribute values nothing in between two commas) and you should still load that line into your database instead of rejecting it. 4. load_teams: load multiple teams' records from a file. The argument should be the name of the file to read. Records are organized in the same way as for load_coaches. 5. print_coaches: print a list of all coaches, with info about one coach's performance in one season in a line; 6. print_teams: print a list of all teams, with info about one team per line; 7. coaches_by_name: print the information of coach(es) with the specified last name (the only argument); 8. teams_by_city: print the information of teams in the specified city (the only argument); 9. best_coach: print the name of the coach who has the most net wins in a given season (the only argument). Net wins should be calculated as (season wins - season losses) + (playoff wins - playoff losses); 10. search_coaches: print the info of coaches with the specified properties. This command may have multiple arguments (1+). Arguments are given in the format field-VALUE where field represents the name of a search criterion and VALUE is the value of that field you want to return. For example, a command search_coaches first_name=John season_win=40 should return all performance data for coaches with first name John who had 40 seasonal wins. Note that fields should exactly match one of the column names in the coaches table (ignore any that do not match a column in this table). Note that a coach's last name can be two words with a space in between (e.g., van Gundy). Your program should be able to handle this, and there will be test cases that search by such names. In order to not confuse your program, we separate the two words of the last name using a + Example query: coaches_by_name van+Gundy Obviously, your job here would be to process the argument by replacing the + sign with a space before you do the search. You should do the same for city names and other commands such as add_coach and add team. 1 Description In this project, you are expected to build a small in-memory database that stores data related to NBA coaches and teams. Users can send simple queries to this database and add new data to the database. The database has two tables (or relations) one for coaches and one for teams. The schemas for the two tables are as follows: coaches Coach ID: 7 or fewer capital letters followed by 2 digits, season: 4 digit year, first name: any reasonable English name, last name: any reasonable English name, season win : non-negative integer, season loss : non-negative integer, playoff win : non-negative integer, playoff loss : non-negative integer, team: capital letters and/or digits teams team ID: capital letters and/or digits, Location: American city name (one or two words), Name : team name, League: one capital letter You must follow these schemas exactly. Your database should have a command-line interface to allow users to add data and send in queries. The interface should accept the following commands: 1. add_coach: add a new record describing the performance of one coach in one season. It should have the following 9 arguments: ID, season, first name, last name, season wins, season losses, playoff wins, playoff losses, and team, the types of which should match the schema of the "coaches" relation above; 2. add_team: add a new record with one team's basic information. It should be followed by the following 4 arguments: ID, location, name, and league, the types of which should match the schema of the "teams" table; 3. load_coaches: load multiple coach and season records from a file. The argument should be the name of the file to read. The file stores each record in one line of text, and different fields of the line/record are separated by commas. In our sample files, you may find empty attribute values nothing in between two commas) and you should still load that line into your database instead of rejecting it. 4. load_teams: load multiple teams' records from a file. The argument should be the name of the file to read. Records are organized in the same way as for load_coaches. 5. print_coaches: print a list of all coaches, with info about one coach's performance in one season in a line; 6. print_teams: print a list of all teams, with info about one team per line; 7. coaches_by_name: print the information of coach(es) with the specified last name (the only argument); 8. teams_by_city: print the information of teams in the specified city (the only argument); 9. best_coach: print the name of the coach who has the most net wins in a given season (the only argument). Net wins should be calculated as (season wins - season losses) + (playoff wins - playoff losses); 10. search_coaches: print the info of coaches with the specified properties. This command may have multiple arguments (1+). Arguments are given in the format field-VALUE where field represents the name of a search criterion and VALUE is the value of that field you want to return. For example, a command search_coaches first_name=John season_win=40 should return all performance data for coaches with first name John who had 40 seasonal wins. Note that fields should exactly match one of the column names in the coaches table (ignore any that do not match a column in this table). Note that a coach's last name can be two words with a space in between (e.g., van Gundy). Your program should be able to handle this, and there will be test cases that search by such names. In order to not confuse your program, we separate the two words of the last name using a + Example query: coaches_by_name van+Gundy Obviously, your job here would be to process the argument by replacing the + sign with a space before you do the search. You should do the same for city names and other commands such as add_coach and add team

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago