



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




select Player.name from Player
select distinct p.name from Player p, Registration r, PlayedIn pi where p.pid = r.pid AND r.registrnum = pi.registrnum AND pi.seed is not null
select p1.name, p2.name from player p1, player p2, registration r1, registration r2, playedin pi where p1.pid = r1.pid AND p2.pid = r2.pid AND r1.registrnum = r2.registrnum AND r1.registrnum = pi.registrnum AND r1.pid != r2.pid AND p1.pid < p2.pid AND pi.tid in (select tid from tournament t where to_char(t.startdate, ’YYYY’) = ’2007’ AND t.ttype = ’Doubles’ AND t.name = ’Wimbledon’)
select p.name, t.name from registration rroger, registration r, match m, matchresults mr, (select p.pid pid from Player p where name=’Roger Federer’) roger, tournament t, player p where rroger.pid = roger.pid AND m.mid = mr.mid AND mr.winner = rroger.registrnum AND ( (rroger.registrnum = m.registrnum1 AND r.registrnum = m.registrnum2) OR (rroger.registrnum = m.registrnum2 AND r.registrnum = m.registrnum1) ) AND t.tid = m.tid AND t.numrounds = m.round AND t.ttype = ’Singles’ AND p.pid = r.pid
*** Note that we do not have to actually check for rroger.registrnum equal to one of the match registration numbers, because we assume the winner is always one of the registration numbers, but we do it here for good practice. If we chose to omit the check, we would need to constrain rroger.registrnum != r.registrnum
select winner.playername winnername, winner.seed winnerseed, loser.playername losername, loser.seed loserseed from match m, tournament t, matchresults mr, (select r.registrnum, pi.seed seed, p.name playerName from player p, registration r, playedin pi where p.pid = r.pid AND r.registrnum = pi.registrnum AND pi.seed is not null) winner, (select r.registrnum, pi.seed seed, p.name playerName from player p, registration r, playedin pi where p.pid = r.pid AND r.registrnum = pi.registrnum AND pi.seed is not null) loser where m.tid = t.tid AND t.ttype = ’Singles’ AND m.round = t.numrounds AND m.mid = mr.mid AND (m.registrnum1 = winner.registrnum OR m.registrnum2 = winner.registrnum) AND (m.registrnum1 = loser.registrnum OR m.registrnum2 = loser.registrnum) AND winner.registrnum != loser.registrnum AND mr.winner = winner.registrnum
*** See note for question 4, similarly here for the two registration relations.
select distinct usplayers.name from tournament t1, tournament t2, registration r1, registration r2, playedin pi1, playedin pi2, (select p.pid pid, p.name from Player p, CountryCodes cc where p.ccode = cc.code AND cc.country = ’United States’) usplayers where t1.tid = pi1.tid AND pi1.registrnum = r1.registrnum AND t2.tid = pi2.tid AND pi2.registrnum = r2.registrnum AND r1.pid = usplayers.pid AND r2.pid = usplayers.pid AND r1.registrnum != r2.registrnum AND to_char(t1.startdate,’YYYY’) = ’2007’ AND to_char(t2.startdate,’YYYY’) = ’2007’
select t.name, t.startdate, t.enddate, t.ttype, t.numrounds from tournament t where t.numrounds > 5
select t.name, t.ttype, t.surface, t.numrounds from tournament t order by t.numrounds desc
select t.name, t.ttype, t.enddate - t.startdate length from tournament t where (t.enddate - t.startdate > 7)
select distinct germans.name from registration r, playedin pi, tournament t, (select p.pid pid, p.name name from player p, countrycodes cc where p.ccode = cc.code AND p.gender = ’M’ AND cc.country = ’Germany’) germans where germans.pid = r.pid AND r.registrnum = pi.registrnum AND pi.tid = t.tid AND t.name = ’Australian Open’ AND t.ttype = ’Singles’ AND to_char(t.startdate,’YYYY’) = ’2007’
select t.name, to_char(t.startdate, ’YYYY’) year, p.name winner, ss1.winnergames Set1Win, ss1.losergames Set1Lose, ss2.winnergames Set2Win, ss2.losergames Set2Lose, ss3.winnergames Set3Win, ss3.losergames Set3Lose from Tournament t, Match m, MatchResults mr, Player p, Registration r, SetScore ss1, SetScore ss2, SetScore ss where t.ttype = ’Singles’ AND t.tid = m.tid AND m.mid = mr.mid AND mr.numsets = 3 AND m.round >= t.numrounds - 2 AND p.pid = r.pid AND r.registrnum = mr.winner AND ss1.mid = m.mid AND ss1.setnum = 1 AND ss2.mid = m.mid AND ss2.setnum = 2 AND ss3.mid = m.mid AND ss3.setnum = 3
select distinct p1.name, p2.name, p3.name from player p1, player p2, player p3, registration r1a, registration r1b, registration r2a, registration r2b, registration r3a, registration r3b where r1a.pid = r1b.pid AND r2a.pid = r2b.pid AND r3a.pid = r3b.pid AND r1a.pid = p1.pid AND r2a.pid = p2.pid AND r3a.pid = p3.pid AND r1a.registrnum = r2b.registrnum AND r2a.registrnum = r3b.registrnum AND r3a.registrnum = r1b.registrnum AND p1.pid < p2.pid AND p2.pid < p3.pid
select distinct p1.name, p2.name from Match m_singles, Tournament t_singles, Match m_doubles, Tournament t_doubles, Player p1, Registration r1s, Registration r1d, Player p2, Registration r2s, Registration r2d where m_singles.tid = t_singles.tid AND t_singles.ttype = ’Singles’ AND m_doubles.tid = t_doubles.tid AND t_doubles.ttype = ’Doubles’ AND r1s.registrnum = m_singles.registrnum1 AND p1.pid = r1s.pid AND r2s.registrnum = m_singles.registrnum2 AND p2.pid = r2s.pid AND (r1d.registrnum = m_doubles.registrnum1 OR r1d.registrnum = m_doubles.registrnum2) AND (r2d.registrnum = m_doubles.registrnum2 OR r2d.registrnum = m_doubles.registrnum1) AND p1.pid = r1d.pid AND p2.pid = r2d.pid AND p1.pid != p2.pid
select winning_matches.tname, winning_matches.tyear, m.round, loser.name from Player loser, registration rloser, Match m, (select t.name tname, to_char(t.startdate,’YYYY’) tyear, m.mid mid from Player blake, Registration r, Match m, Tournament t, MatchResults mr, SetScore ss where blake.name = ’James Blake’ AND r.pid = blake.pid AND r.registrnum = mr.winner AND mr.mid = m.mid AND t.tid = m.tid AND ss.mid = m.mid AND t.ttype = ’Singles’ AND ((ss.winnergames = 0 AND ss.losergames = 6) OR (ss.winnergames = 6 AND ss.losergames = 0))) winning_matches where winning_matches.mid = m.mid AND rloser.pid = loser.pid AND (rloser.registrnum = m.registrnum1 OR rloser.registrnum = m.registrnum2) AND loser.name != ’James Blake’
haas_r.registrnum = m.registrnum2) AND (r.registrnum = m.registrnum1 OR r.registrnum = m.registrnum2) AND r.pid = p.pid AND p.pid != haas.pid AND p.ccode = cc.code AND (cc.country = ’United States’ OR cc.country = ’Chile’ OR cc.country = ’Russia’)
select distinct p.name from Tournament wimt, Tournament ust, Tournament frt, Tournament aut, Player p, Registration wimr, Registration usr, Registration frr, Registration aur, Match wimm, Match usm, Match frm, Match aum where wimt.name = ’Wimbledon’ AND ust.name = ’US Open’ AND frt.name = ’French Open’ AND aut.name = ’Australian Open’ AND p.pid = wimr.pid AND p.pid = usr.pid AND p.pid = frr.pid AND p.pid = aur.pid AND (wimr.registrnum = wimm.registrnum1 OR wimr.registrnum = wimm.registrnum2) AND (usr.registrnum = usm.registrnum1 OR usr.registrnum = usm.registrnum2) AND (frr.registrnum = frm.registrnum1 OR frr.registrnum = frm.registrnum2) AND (aur.registrnum = aum.registrnum1 OR aur.registrnum = aum.registrnum2) AND wimm.tid = wimt.tid AND usm.tid = ust.tid AND frm.tid = frt.tid AND aum.tid = aut.tid AND wimm.round >= wimt.numrounds - 2 AND usm.round >= ust.numrounds - 2 AND frm.round >= frt.numrounds - 2 AND aum.round >= aut.numrounds - 2