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 SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL for analyzing beginners’ mistakes; however, such easy tasks hardly leave room for other kind of mistakes. The difficulty level is specified in the Level column in the list of exercises. Thus, you can proceed with more difficult tasks. 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
|