PDF Version Available

This document is also available in PDF format: week2.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/week2.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-3172
Requested by: Operations manager at your company
Data: Your data set from the Introduction to Data lab

Background

Before anyone relies on this data, your manager wants to see that it can answer real business questions, and that your queries are documented so the rest of the team can reuse them. You'll start with a quick SQL refresher as training, then load your data into a database and put it to work.

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 Review Tutorial

Go through these 5 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. Then answer these questions:

  1. Which, if any, questions did you find challenging? Why?
  2. How many of the questions did you need a hint on? Why?
  3. What is your review of this tutorial? What would you change or fix?
  4. Pick one query you wrote and explain what each part does: SELECT, FROM, WHERE, and ORDER BY.

Part 2: Business Questions About Your Data

Now use SQL on your own data set from the Introduction to Data lab. Books are my example data only, so your questions and queries must be about your own data.

  1. Load your data set into a database as a single table. You will organize your data into multiple tables later in the term, so one table is fine for now. Here's the way I suggest, which runs in your browser with nothing to install. The tools are linked under Resources.
    1. Open my CSV to Database Converter, and choose your CSV file. Keep the first 100 to 1,000 rows, since bigger databases can cause errors in browser tools. Select Convert, check the summary, and download your database.
    2. Open SandboxSQL, use Load a Database, and choose the file you downloaded.
    3. Check that it worked by running SELECT COUNT(*) on your table. The count should match the number of rows the converter showed.
    You can use a different tool if you prefer, as long as you turn in a database file, not a CSV file or a spreadsheet.
  2. Write 5 business questions that someone at the company from your data card might ask about your data.
  3. Write a query that answers each question. Across your 5 queries, use WHERE, ORDER BY, and at least one WHERE with more than one condition.
  4. Document each query using the format in the sample query documentation (linked under Resources). Each one needs a header comment with the business question, who is asking, a business justification, and any notes, followed by the query and a short summary of the result. Your result summary must quote specific numbers or values from your results, such as how many rows came back or the top value.
  5. Take a screenshot of each query and its results.
  6. Export your database to turn in. In SandboxSQL, use the Export button, which saves it as a .sqlite file. SandboxSQL doesn't always keep your work if you close the page, so export at the end of each session, and use Load a Database to open your .sqlite file next time.

Acceptance Criteria

This request is done when:

Deliverables

Two files:

  1. A document that includes Part 1, your 5 SQLBolt screenshots and your answers to the 4 questions, and Part 2, your 5 documented queries with a screenshot of each one and its results
  2. Your database file

Audience: your manager 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/sqlpt1.html

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

Suggested tool: SandboxSQL, free, runs in your browser, and saves your database as a .sqlite file with its Export button Link: https://www.sandboxsql.com/

My CSV to Database Converter, which makes a database file from your CSV file Link: https://www.aholdengouveia.name/AdvData/labs/csv-to-database.html

Optional, if you'd rather install a tool: DB Browser for SQLite, which can import a CSV file directly Link: https://sqlitebrowser.org/

Sample query documentation, showing the format to follow Link: https://www.aholdengouveia.name/AdvData/labs/SampleQueryDocumentation.txt