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
Answers
Answer:
dgh shri desh sheharon shehej hehehe shdhhd
-- Retrieve the MatchID of all those matches where both the teams have scored > 70
select Match_id
from March_details
where First_team_score >70 and Second_team_score >70;
-- Retrieve the MatchID of all those matches where FirstTeam has scored < 70 but SecondTeam has scored > 70
select Match_id
from March_details
where First_team_score <70 and Second_team_score >70;
-- Find out the MatchID and date of matches played by Team 1 and won by it
select Match_id, March_date
from March_details
where First_team_score>Second_team_score and First_team_id=1
union
select Match_id, March_date
from March_details
where Second_team_score> First_team_score and Second_team_id =1 ;
-- Find out the MatchID of matches played by Team 2 and not won by it.
select Match_id
from March_details
where First_team_id=2 and First_team_score < Second_team_score
union
select Match_id
from March_details
where Second_team_id=2 and First_team_score > Second_team_score ;
-- 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
select Team_id as T_ID, Team_name as T_NAME
from team as T_DATA;