Skip to content

Conversation

@upsideon
Copy link

Description

While working through the first edition of your book, I noticed that one of the answers in the try-it-yourself exercises for "Chapter 6: Joining Tables in a Relational Database" could be improved.

I propose and submit the following changes in this pull request:

  • Fixing a typo in the description for the question that asks us to find which counties do not exist in both the 2000 and 2010 census data.
  • Adding an alternative answer to that same question, which retrieves the results of the two existing queries using a single query with FULL OUTER JOIN.

Although this is a change to the supporting code for the first edition, I feel that it could be useful to other readers who, like myself, do not have access to the second edition of the book. Furthermore, it facilitates learning the different join types and how a problem such as this can be solved in multiple ways.

I also wanted to say that I am enjoying the book and I appreciate the work you've put into it and the supporting material. Please let me know if you'd like me to make improvements to the submitted changes or if you'd prefer the pull request to be closed.

Query Demonstration

As evidence that the query works the same as the separate queries, here are the results of the proposed query:

            county_2010            | state_2010 |                     county_2000                     | state_2000
-----------------------------------+------------+-----------------------------------------------------+------------
 Hoonah-Angoon Census Area         | AK         |                                                     |
 Petersburg Census Area            | AK         |                                                     |
 Prince of Wales-Hyder Census Area | AK         |                                                     |
                                   |            | Prince of Wales-Outer Ketchikan Census Area, Alaska | AK
 Skagway Municipality              | AK         |                                                     |
                                   |            | Skagway-Hoonah-Angoon Census Area, Alaska           | AK
 Wrangell City and Borough         | AK         |                                                     |
                                   |            | Wrangell-Petersburg Census Area, Alaska             | AK
 Broomfield County                 | CO         |                                                     |
                                   |            | Clifton Forge city, Virginia                        | VA
(10 rows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant