Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The database you will use for this assignment contains information related to Major League Baseball (MLB) about players, teams, and games. The relations are: Players(playerID,

The database you will use for this assignment contains information related to Major League Baseball (MLB) about players, teams, and games. The relations are: Players(playerID, playerName, team, position, birthYear) playerID is a player identifier used in MLB, and all players throughout the history of baseball have a unique ID playerName is players name team is the name of the MLB team the player is currently playing on (or the last team the player played for if they are not currently playing) position is the position of the player birthYear is the year that player was born Teams(teamID, teamName, home, leagueName) teamID is a unique ID internal to MLB. teamName is the name of the team home is the home city of the team leagueName is the league the team is in, i.e. either National or American, which stands for National League and American League, respectively Games(gameID, homeTeamID, guestTeamID, date) gameID is a unique ID used internally in MLB homeTeamID is the ID of the hometeam guestTeamID is the ID of the visiting team date is the date of the game. A sample instance of this database is given at the end of this homework handout. Since it is just one instance of the database designed to give you some intuition, you should not customize your answer to work only with this instance.

image text in transcribedimage text in transcribed

Write the following queries in relational algebra, using the schema provided above. (a) Define a relation Members(playerID1, playerID2, team) where playerID1 and playerID2 are (or have been) on the same team. Avoid listing self-references or duplicates, e.g. do not allow (1,1,Braves) or both (2,5,Phillies) and (5,2,Phillies). (b) Define a relation WorldSeries(teamID1, league1, teamID2, league2, date) where teamID1 and teamID2 played against each other in a World Series game. Although there is no direct information about the World Series in the relations, we can infer that when two teams from different leagues play each other, it is a World Series game. So, in this relation, league1 and league2 should be different leagues. (c) Define a relation BothLeagues(city) for which each city has a team in all leagues. For example, there are currently two leagues (National and American). Although not shown in this instance, New York is home to the Mets in the National league as well as the Yankees in the American league (Chicago also has one in each league, for those of you who are baseball fans). Remember that your query must work over all instances of this schema, even if there are more than two leagues in the instance.

Players playerName Javy Lopez Cliff Lee Derek Jeter Skip Schumaker Cardinals Dominic Brown Phillies birthYear 1970 1978 1974 1980 1987 playerID team Braves Phillies Yankees position Catcher Pitcher Infielder Infielder Outfielder 2 4 Team teamName Phillies Braves Yankees Twins Rangers Cubs home Philadelphia Atlanta New York Minnesota Texas Chicago leagueName National National American American American National teamID 2 4 6

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

here) and other areas you consider relevant.

Answered: 1 week ago