FREE BOOK

Chapter 7 - Thinking in Sets

Posted by Addison Wesley Free Book | C# Language August 09, 2009
In this chapter, you will learn What Is a Set, Anyway,Operations on Sets, Intersection, Difference, Union and SQL Set Operations.

SUMMARY
 
We began this chapter by discussing the concept of a set. Next,we discussed each of the major set operations implemented in SQL in detail-intersection, difference, and union. We showed how to use set diagrams to visualize the problem you're trying to solve. Finally,we introduced you to the basic SQL syntax and keywords (INTERSECT, EXCEPT, and UNION) for all three operations just to whet your appetite.
 
At this point you're probably saying,"Wait a minute, why did you show me three kinds of set operations-two of which I probably can't use?"Remember the title of the chapter: Thinking in Sets. If you're going to be at all successful solving complex problems, you'll need to break your problem into result sets of information that you then link back together.
 
So, if your problem involves "it must be this and it must be that," you might need to solve the "this"and then the "that"and then link them to get your final solution. The SQL Standard defines a handy INTERSECT operation-but an INNER JOIN might work just as well. Read on in Chapter 8.
 
Likewise, if your problem involves "it must be this but it must not be that," you might need to solve the "this" and then the "that" and then subtract the "that" from the "this" to get your answer. We showed you the SQL Standard EXCEPT operation, but an OUTER JOIN might also do the trick. Get the details in Chapter 9.
 
Finally,we showed you how to add sets of information using a UNION. As promised,we'll really get into UNION in Chapter 10.

Total Pages : 7 34567

comments