PDF Version Available

This document is also available in PDF format: week3.pdf

The PDF version includes bookmarks for easy navigation and is optimized for printing.

Accessibility Notice

This document is also available in HTML format at:

Link: https://aholdengouveia.name/AdvData/labs/week3.html

The HTML version provides enhanced accessibility features including keyboard navigation, screen reader support, responsive design, dark mode support, and high contrast options.

Request

Request: DATA-5809
Requested by: Inventory lead
Data: Your database from the SQL Review lab

Background

Your manager liked your first queries. Now the inventory lead wants to combine your data with a second table, and to know whether anything in the data doesn't match up. Rows that don't match are a common sign of data problems, and finding them early saves the company time and money. You'll start with join training, then apply it to your own data.

Learning Outcomes

By the end of this lab, you will be able to:

Lab Instructions

Screenshots

Several parts of this lab ask for a screenshot. Each screenshot should have your name, term, and year. One of the easiest ways to do that is make a text document with your name and term/year on your computer and save it to use all term. Any screenshots that don't include this information won't be counted.

Example screenshot: a web browser showing the Google home page, with a small text editor window in front of it that says YOUR NAME HERE and TERM YEAR
This is an image of what each of your screenshots should look like

Part 1: SQL Joins Tutorial

Go through these 3 sections of SQLBolt (linked under Resources), and complete the exercises at the end of each one:

Take a screenshot of each section after you complete its exercises. Make sure you have the green checkmark on each problem.

Part 2: Join Challenges

Complete 3 HackerRank challenges that use joins (linked under Resources). You can filter the list by basic and advanced joins. HackerRank is free, but you need to register so your work is saved to your profile.

  1. Take a screenshot of each solution.
  2. With each screenshot, explain how you solved it and what resources you used. If you needed a hint, say where you found it.
  3. Pick one of your 3 solutions and explain which type of join you used and why. What would change in the results if you used the other type (inner instead of left, or left instead of inner)?
  4. Take a screenshot of your HackerRank profile showing the completed challenges.

Optional, not required for this class: if you'd like more practice, try more of the HackerRank join challenges.

Part 3: Joins on Your Data

Your data set from the SQL Review lab is one table, so you'll make a second table to join it to. Books are my example data only, so use your own data set.

  1. Create a small lookup table with 5 to 10 rows that adds information about one column in your main table. For example, my book data has a format column, so I made a table that matches each format to the shelf section where it goes in the store.
  2. Explain how the two tables relate. Which column links them? What is the primary key of your lookup table, and which column in your main table acts as the foreign key?
  3. Write 3 queries that join your two tables, documented in the same format as the SQL Review lab. Use at least one inner join and at least one left join.
  4. Make one of your 3 queries a data quality check: use a left join to find rows in your main table that have no match in your lookup table. In the Notes, explain why those rows don't match and what you would do about it.
  5. Take a screenshot of each query and its results.

Acceptance Criteria

This request is done when:

Deliverables

One file that includes:

Audience: the inventory lead and the rest of the data team.

Resources

References, a video, a PowerPoint and some notes are available at my website Link: https://www.aholdengouveia.name/AdvData/sqlpt2.html

SQLBolt, the tutorial for Part 1 Link: https://sqlbolt.com/

HackerRank join challenges for Part 2 Link: https://www.hackerrank.com/domains/sql?filters%5Bsubdomains%5D%5B%5D=join&filters%5Bsubdomains%5D%5B%5D=advanced-join

Sample query documentation, with join examples (Q3 and Q4) Link: https://www.aholdengouveia.name/AdvData/labs/SampleQueryDocumentation.txt