Author Joe Celko demonstrates the thought processes that are involved in attacking a problem from an SQL perspective to help advanced database programmers solve the puzzles you frequently face. These techniques not only help with the puzzle at hand, but also help develop the mindset needed to solve the many difficult SQL puzzles you face every day. This updated edition features many new puzzles; dozens of new solutions to puzzles; and new chapters on temporal query puzzles and common misconceptions about SQL and RDBMS that leads to problems. This book is recommended for database programmers with a good knowledge of SQL.
|Published (Last):||4 August 2012|
|PDF File Size:||8.24 Mb|
|ePub File Size:||12.24 Mb|
|Price:||Free* [*Free Regsitration Required]|
Problem solve Get help with specific problems with your technologies, process and projects. This is the same thing as finding two equal sets. How many ways can you find to do this problem? Printed with permission from Morgan Kaufmann, a division of Elsevier. Copyright For more information about this book, and other similar titles, please visit www.
Set theory has two symbols for subsets. One is a "horseshoe" on its side, which means that set A is contained within set B and is sometimes called a proper subset. The other is the same symbol with a horizontal bar under it, which means "contained in or equal to," which is sometimes called just a subset or containment operator. Standard SQL has never had an operator to compare tables against each other. The IN predicate is a test for membership, not for subsets. Membership is for one element, while a subset is itself a set, not just an element.
This tells you which pairs are not matched, not who is. The final step is to remove these nonmatching pairs from all possible pairs. Answer 2 The usual way of proving that two sets are equal to each other is to show that set A contains set B, and set B contains set A.
What you would usually do in standard SQL would be to show that there exists no element in set A that is not in set B, and therefore A is a subset of B. First, I join one supplier to another on their common parts, eliminating the situation where supplier 1 is the same as supplier 2, so that I have the intersection of the two sets.
If the intersection has the same number of pairs as each of the two sets has elements, then the two sets are equal. You have to be careful about using the ALL clauses on the set operators if you have duplicates. The good news is that these operators work with rows and not at the column level, so this template will generalize to any pairs of union-compatible tables.
You do not have to know the column names. About the author Joe Celko is a noted consultant, lecturer, teacher and one of the most-read SQL authors in the world.
Joe Celko's SQL Puzzles and Answers
On the one hand, it is a positive development, but on the other hand, this ease of sharing makes it tempting to create simple websites with badly organized databases which make users confused or even frustrated. Whether you are looking for a handbook or a rare ebook, the chances are that they are available for downloading from our website in txt, DjVu, ePub, PDF formats. For starters, if you are reading this, you have most likely found what you need here, so why go on to browse other websites? Even if your search has been fruitless yet, we have an impressive database of various ebooks, handbooks, and manuals, so if you are looking for a rare title, your chances of finding it here are quite high. In addition, we do our best to optimize your user experience and help you download necessary files quickly and efficiently. We make sure that all our files are available in PDF format, which is currently one of the most popular document formats for computers and mobile devices. Finally, we are always ready to help you if you are having trouble using the website or are unable to find a particular title.
Subscribe to RSS
Can you solve Joe Celko's SQL puzzles?
SQL puzzles and answers: Finding equal sets