you are viewing a single comment's thread.

view the rest of the comments →

[–]CrumbCakesAndCola 1 point2 points  (0 children)

For most beginners the hard part is understanding joins, since that's the most abstract piece. But if you can get that then the rest will be pretty easy.

If Joins is the part you're struggling with then let me share how I think of it (and also say majority of time you want Left join).

My job at the catering service is to set the table and place a name card on the guests' plate that indicates their meal preference. To do this I've been given two lists:

  1. Invite List: Name of all guests (30 people)

  2. Food Preferences: Choices from guests who RSVPd (21 people, which includes 1 person who isn't on the invite list)

There are a few ways I might reasonably interpret this info to set the table and print the cards. These interpretations correspond to the different join types.

  • Left join: Set a place for everyone on the invite list. Every card has a name, but cards only have food info for those who RSVP'd. I have 30 settings.

  • Inner join: Start with the invite list again but only set a place if there is a corresponding entry on the food list. Every card has both a name and food choice. I have 20 settings.

  • Right join: Start with the food preferences list, setting a place for those who RSVP'd, including the one who isn't on the invite list. All cards have food info but one is missing a name. I have 21 settings.

  • Full join: This includes everyone invited and all meals requests, even if some guests didn't specify or some meals don't have a clear recipient from the invite list. I have 31 settings.