The database you will use for this assignment contains infor

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 player’s 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.

Question: ANSWER NEEDS TO BE IN RELATIONAL ALGEBRA

3. 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 AllLeagues(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

Solution

3. (a) select distinct cus1.CustomerID as c1,cus2.CustomerID as c2,cus1.City
from Customers as cus1,Customers as cus2
where cus1.City=cus2.City and cus1.CustomerID<cus2.CustomerID;

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site