Q. Using the sports database containing two relations (TEAM, MATCH_DETAILS), answer the following relational algebra queries.


a) Retrieve the MatchID of all those matches where both the teams have scored > 70.


b) Retrieve  the  MatchID  of  all  those  matches  where  FirstTeam  has  scored  <  70  but SecondTeam  has scored > 70.


c) Find out the MatchID and date of matches played by Team 1 and won by it.


d) Find out the MatchID of matches played by Team 2 and not won by it.


e) In the TEAM relation, change the name of the relation to T_DATA.  Also change the attributes TeamID and TeamName to T_ID and T_NAME respectively.


Answer :-

a = Select MatchIdD from  MATCH_DETAILS where FirstTeamScore > 70 and SecondTeamScore > 70 ;

b = Select MatchIdD from  MATCH_DETAILS where FirstTeamScore < 70 and SecondTeamScore > 70 ;

c = Select MatchIdD , MatchDate from  MATCH_DETAILS where FirstTeamID = 1 and FirstTeamScore > SecondTeamScore ;

d = Select MatchIdD , MatchDate from  MATCH_DETAILS where FirstTeamID = 2 and FirstTeamScore < SecondTeamScore ;

Select MatchIdD , MatchDate from  MATCH_DETAILS where SecondTeamID = 2 and FirstTeamScore > SecondTeamScore ;

e = ALTER TABLE Team
  RENAME TO T_DATA ;

ALTER TABLE T_DATA CHANGE COLUMN TeamID T_ID int ;

ALTER TABLE T_DATA CHANGE COLUMN TeamName T_Name ;

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post