




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Winslett; Class: Database Systems; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Spring 2008;
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Devise an entity-relationship diagram for this database. List the keys. Tell whether each relationship is many- many, many-one, one-many, or one-one. To keep your answer small, you only need to include one attribute per entity set in addition to its key attribute(s). You can assume textbooks come in one volume only, so you do not have to model volume information.
Note that in the Out relation, ’W’ means that Illinois won, and ’L’ means that Illinois lost. BETS Relation Who Amt Outcome Game Liu 100 W Michigan Liu 20 W Yale Liu 30 W Georgia Liu 40 W USC Winslett 20 L Michigan Winslett 20 L Georgia Winslett 150 W Notre Dame Jones 250 W USC Harandi 110 L USC Reed 5 W USC Reed 5 L USC Reed 5 W Tennessee Reed 5 L Tennessee Campbell 100 L Georgia Campbell 100 W Michigan Campbell 100 W Yale Ng 100 W Georgia Ng 5 L LSU Kale 5 L Auburn
Note that in the Bets relation, ’W’ means that the bettor is betting that Illinois will win, and ’L’ means that the bettor is betting that Illinois will lose. Also note that not all the games have been played yet: the LSU, Arizona, Tennessee, and Auburn games have not yet taken place. Answer the following queries using relational algebra. Your queries should work for any instance of the database, not just this one.
a. [5 points] List all the games where someone bets that Illinois will win. For the instance given above, your answer should be: Georgia Michigan Notre Dame Tennessee USC Yale
Solution: πGameσoutcome=′W ′ BET S
b. (5 points) List the completed games that no one bet on. For the instance given above, your answer should be: Kansas
Solution: πGameOU T − πGameBET S
a [10 points]. Who has bet on every game? For the instance given above, your answer must be empty relation.
Solution:
Create View AllGames As (Select Game from OUT) UNION (Select Game from BETS)
Select Who from BETS Group By Who Having count (distinct Game) = (Select count (distinct Game) form AllGames)
b [15 points]. For each game, list the number of people betting on Illinois to win and the number betting on Illinois to lose. For the instance given above, your answer should be: Michigan W 2 Michigan L 1 Yale W 2 Georgia W 2 Georgia L 2 USC W 2 USC L 3 Notre Dame L 1 LSU L 1 Tennessee W 1 Tennessee L 1 Auburn L 1 Solution:
Select Game, Outcome, Count(Who) from Bets Group By Game,Outcome
c [20 points]. What game or games so far won the most money for people betting on Illinois to win? For the instance given above, your answer should be: Michigan : Solution:
Create View Success-Win As Select Bets.Game, Sum(Bets.Amt) As SumAmt From Bets, Out Where Out.Game = Bets.Game and Bets.Outcome=’W’ and Out.Outcome=’W’ Group By Game
Select distinct Game From Success-Win Where SumAmt >= ALL (Select SumAmt From Success-Win)