Module 0 · Orientation

Understand tables, rows and columns

By the end you will be able to recognise rows, columns and cells in a table.

About 8 min

0 of 52 lessons

Before you start, you need

What SQL is and what it is for

Read a table by rows and columns

Picture a list of customers laid out like a spreadsheet. Each row brings together one person's data. If you read a row from left to right, you will find their name, their city and other attributes.

Each column stores one attribute for everyone. Its heading tells you which one: name, city or email. Reading the city column from top to bottom lets you compare where each customer lives.

A cell is where a row and a column meet. The name cell in customer 1's row contains Amy Wilson. The id column stores an identifier: a number that lets you tell people apart even if they share a name.

Sometimes an attribute is missing. NULL marks a missing value, for example an email address that has not been recorded. It is not the same as the number 0 or an empty text. For now, it is enough to recognise it; you will learn how to look for these missing values in a lesson of their own.

Minimal syntax
SELECT id, name
FROM customers;

See it in action

How can we tell each customer apart and name them?

SQL
SELECT id, name
FROM customers;
Example result: 8 of 12 rows
idname
1Amy Wilson
2Liam Martin
3Megan Reed
4David Clark
5Sara Green
6Peter Hill
7Laura Ward
8Hugh Miller
  1. Each result row corresponds to one customer. id and name are the two chosen columns.
  2. Amy Wilson appears next to her id, 1. The cell for her name contains Amy Wilson; the cell for her id contains 1.
  3. Even if two people had the same name, their ids would tell them apart. A column always describes the same attribute on every row.

Practice with help

Getting things wrong is part of learning: you can run your query as many times as you like and nothing is lost. If you get stuck, open a hint (each one reveals a bit more) and save the solution for last.

Guided practice

Identify each customer

Not started

Write a query that shows the id and name of every customer.

Expected result: 12 rows with the columns id, name, in that order. Row order does not matter.

View tables and data

Open this panel to see the full data.

Your turn

Solve this variation. Spot the part that has changed before you look for help.

Practice

Read another part of the table

Not started

Show name and city for every customer, in that column order.

Expected result: 12 rows with the columns name, city, in that order. Row order does not matter.

View tables and data

Open this panel to see the full data.

Key takeaways

  • A row represents one item.
  • A column describes one attribute.
  • A cell holds the value of one attribute for one item.
  • NULL marks a missing value.

Next: How to read a SQL query