Advanced Database Query Exercise: Difference between revisions
Jump to navigation
Jump to search
imported>Hendrik Brummermann No edit summary |
imported>Hendrik Brummermann No edit summary |
(No difference)
| |
Revision as of 10:15, 11 September 2011
This is an advanced version of the basic Database Query Exercise. You should probably do that one first.
The same instructions apply:
- Some tasks can be solved with one single query, other tasks may require a set of queries with human interaction in between. Please point out what to look for in the result set and anything else that should be kept in mind.
- If possible explain how the results can be validated.
With the following addition: Make sure that you use the existing indices on large tables such as gameEvents and itemlog.
Example
The itemids and names of all items that have been touched by alice and malice in the last two days?
<source lang="sql">
SELECT DISTINCT i3.itemid, i3.param1
FROM itemlog As i1, itemlog As i2, itemlog i3
WHERE i1.itemid = i2.itemid AND i1.itemid = i3.itemid
AND i1.source = 'alice' AND i2.source='malice' AND i3.event = 'register'
AND i1.timedate > '2011-09-11' AND i2.timedate > '2011-09-11'
ORDER BY i1.param1
</source>
(Assuming today is 2011-09-14)