idterm ex

advertisement
A114/I111 Fall 2004 Midterm Exam
(Thursday Sep 23 SB221)
You are keeping track of soccer matches that have been played between various teams.
The data you currently have in your database contains these matches:
Games
Game No Hosts
1 Brazil
2 England
3 Brazil
4 France
5 Italy
6 Italy
7 France
8 USA
9 Italy
10 Italy
11 Brazil
Visitors Goals Hosts Goals Visitors
Germany
1
0
France
2
1
Holland
0
3
Germany
2
4
USA
0
1
Germany
3
3
USA
2
2
Brazil
0
1
England
2
0
USA
0
0
Germany
0
0
Assume that for every team you need to store a picture/logo in your database and you
don’t want to store it in more than one place (pictures take a lot of space). Here’s the kind
of picture you would store for the team of France, for example:
In any event with the information you have you need to create a database, populate it
with data and design, test and develop 6 (six) queries:
1. List the total number of goals scored by the host teams sorted in descending order
(highest on top). With the information above the result of this query should be:
Query1
Hosts SumOfGoals Hosts
Italy
5
France
4
England
2
Brazil
1
USA
0
2. List the total number of goals scored by the visitor teams sorted in descending
order (highest on top). For the data above the result of this query should be:
Query2
Visitors SumOfGoals Visitors
Germany
7
USA
3
Holland
3
France
1
Brazil
1
England
0
3. List the games sorted by the total number of goals (descending, highest scoring
game listed first). With the data above the result should be something like this:
Query3
Game No Hosts
6 Italy
4 France
7 France
3 Brazil
2 England
9 Italy
8 USA
5 Italy
1 Brazil
11 Brazil
10 Italy
Visitors Total Goals Hosts Goals Visitors
Germany
6
3
3
Germany
6
2
4
USA
4
2
2
Holland
3
0
3
France
3
2
1
England
2
2
0
Brazil
1
0
1
USA
1
0
1
Germany
1
1
0
Germany
0
0
0
USA
0
0
0
4. List the average goals scored per match in your database.
The result should be: 2.45454545…
5. List those games in which the total number of goals scored was below the average
(where by average I mean the average calculated in Query 4). Note: You are not
allowed to use the actual value 2.45454545… in this query, since it’s supposed to
remain correct later, when you add data that will undoubtedly change the average
per game. At this stage (for your information only) with the data above the correct
result should be:
Query5
Game No Hosts
9 Italy
8 USA
5 Italy
1 Brazil
11 Brazil
10 Italy
Visitors Goals Hosts Goals Visitors
England
2
0
Brazil
0
1
USA
0
1
Germany
1
0
Germany
0
0
USA
0
0
6. List the teams that have never been hosts to any game. Here’s some help:
You have 75 minutes for this exam. The last question is like the challenge in the practice
practical exam. That’s why the help offered is so huge. Each query is worth 15 points.
Exam is open book and open notes, open everything---except you can’t talk to anyone but
the instructor. Exam must be individual work, modulo the resources you might be using.
When you’re done turn this into OnCourse. Grades will be posted tonight. Make-ups can
be set up (in principle, details to be worked out individually) during the last (eighth)
week. Partial credit is available so do ALL that you can. Setting up the tables correctly is
worth 10 points (including adding the data correctly into the database).
Work hard, and quickly, but please be patient with yourself. Good luck and do well!
Download