← Teacher guide

Look inside a table

Students meet tables, rows and columns, and write SELECT with named columns and with a star.

SQL and databases · Ask a table · about 25 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Run 8 min · Investigate 7 min · Modify and Make 10 min

Running the lesson

  1. Predict: the wrong options mix up rows and columns. Ask how many columns the answer has before anyone runs it.
  2. Run: open the table list so students see the real column names before they type any.
  3. Investigate: the star is shorthand, and the row count does not change.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

Putting SELECT, the columns and FROM in order. Say the query aloud: select these, from that table.

When students get stuck

What you will seeA question to askThe fix
no such columnDoes that word appear in the table list?Copy the column name exactly as it is shown.
A comma after the last column.What comes after the last column name?Commas go between columns. FROM comes straight after the last one.

Answers to the checks

  1. Predict: The songs table has 15 songs. What will this query show?
    15 rows with two columns. SELECT picks the columns, and with no filter every row comes back.
  2. Count the columns: Run the query. How many columns does the table have?
    7
  3. Pick the right query: You want only the year of every song. Which query does that?
    SELECT year FROM songs;
    SELECT, then the column, then FROM and the table.

Solutions

One possible solution for each task. Other correct programs are fine.

Modify

SELECT title, genre
FROM songs;

Make

SELECT title, artist, year
FROM songs;

Stretch and support

Stretch: Show the columns in a different order and see that the table follows.

Support: Give the query with one column filled in and ask for the second.

Exit ticket

What is the difference between a row and a column in the songs table?

A row is one song with all its details. A column is one kind of detail, such as title, for every song.

What each step is for

Where it leads

Next lesson: show only the rows that match, such as one genre.