Exercise #6 |
||
For each maker producing laptops with a hard drive capacity of 10 Gb or higher, find the speed of such laptops. Result set: maker, speed. This is the first exercise that requires obtaining data from more than one table: the name of the maker is in the Product table, while the speed and hard drive capacity (hd) are in the Laptop table.
Notes:
I apologize to readers experienced in But let's get back to the solution:
The author of this solution claims that this query returns 5 extra rows compared to the correct answer, while the query he considers more accurate:
The mistake lies in the fact just listing the tables separated by commas without specifying any criterion how to combine them yields nothing else than the Cartesian product of them (see Chapter 5 section 5.6 for details). We agree that the second solution is more accurate. The only thing it lacks is an appropriate table join operation. Whereas the first solution represents an attempt to fiddle with the output of the “more accurate” second query by confining it to laptop models. It should be noted this attempt was a rather clumsy one, since, if we understood the author’s idea correctly, the predicate
the following
|