Русский    English

Exercise #2

Find printer makers. Result set: maker.

Here we for the first time come across the mistake, typical for a number of problems (e.g., 20, 27, 28). Its cause lies in the inattentive study of database schema. «Fallacious» solution:

  2. FROM Product
  3. WHERE model IN (SELECT model
  4. FROM Printer
  5. )

Thus for each row of Product table it is checked whether there is such a model in Printer table. The relationship between these two tables (one-to-many) does presuppose availability of the model in Product table which would be absent in Printer table. As a result we can skip the producer of the printers if his models are not available (in Printer table). As we have already pointed out when discussing schema of data, the product type in Product table, is set as type attribute, which is not taken into account in this case.

If it is still not clear to you how to solve the problem pls. have a look at Chapter 4 «Tips and solutions».


If additional comments are provided or the fallacious decision is offered, by the end of the analysis there will be a reference to the corresponding page of this Chapter 4 – T&S.

To solve the problem on SQL-EX.RU

Bookmark and Share
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema date/time functions DATEADD DATEDIFF DATENAME DATEPART DATETIME DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates EXCEPT exercise (-2) exercise 19 exercise 23 exercise 32 More tags
The book was updated
month ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.
Rambler's Top100