SQL is a programming language used to interact with a database. Learning to interact with databases is crucial to your work as a backend developer. While we eventually want to use libraries that will write SQL for us, it is important to be familiar with how SQL works under the hood so that you understand what your code is doing at the database level.
For your SQl intermission work, you will complete an introductory tutorial, and then will complete some exercises to help you practice the most important SQL concepts. This assignment is meant as an introduction to sql, so don’t be alarmed if you don’t feel like you have mastered these concepts. Use the accompanying Checks for Understanding to assess yourself.
Jumpstart Lab Tutorial
Work through the Jumpstart Lab SQL Tutorial, but do not complete the “Sequel” tutorial linked at the bottom of the Jumpstart Lab page. Then complete the Checks for Understanding.
Checks for Understanding
- What is a database?
- What is SQL?
- What is SQLite3?
- What is a Table?
- What is a primary key?
- What is a foreign key?
- Explain what each of the following SQL commands do:
- order by
- inner join
Now you’ll work through some of the exercises at pgexercises.com. In the Jumpstart Lab tutorial, you used SQLite3. In these exercises, you will use Postgresql. It’s largely the same, but make sure that when you are looking at documentation you are looking at the Postgresql Documentation.
Work through the three following sections (Basic, Joins, Aggregates) of exercises on the site. Make sure you are also reading the Answers and Discussion section at the bottom, even if you get the answer right. There are some helpful explanations and alternative solutions.
To reiterate from before, you do not need to be a master of SQL coming out these exercises, so you should timebox these exercises. Timebox each of the three sections to no more than 2 hours for a maximum of 6 hours spent on these exercises. There will likely be exercises that you have difficulty completing, and that’s okay! Use the provided hints, give it your best effort, and skip to the answer if you can’t get it. Just make sure you read and understand the answer before moving on.
After you complete the exercises, answer the Checks for Understanding.
- Getting Started. Skip the “I want to use my own Postgres system” at the end.
- Select All
- Selecting Columns
- Where 2
- String Search
- Where 3
- Unique and Order
- Basic Aggregate
Checks for Understanding
- How can you limit which columns you select from a table?
- How can you limit which rows you select from a table?
- How can you give a selected column a different name in your output?
- How can you sort your output from a SQL statement?
- What is joining? When do you need to join?
- What is an aggregate function?
- List three aggregate functions and what they do.
- What does the
- How does the
groupstatement relate to aggregates?