Practice Unit: Tables, Rows and Columns
Every relational database is built from the same three ideas. This unit makes sure they are solid before you write anything more complicated. It takes about an hour, including the exercise.
Objectives
After this unit you will be able to:
- explain what a table, a row and a column are
- describe a real-world list as a table on paper
- create that table in SQL and add a few rows
- spot when one table is trying to hold two kinds of thing
Explanation
A table holds one kind of thing: students, books, orders. Think of it as a list with a fixed set of headings.
A column is one heading: name, email, year. Every row has a value (or an empty one) in every column, and each column has a data type, such as whole numbers, text or dates, that limits what it may contain.
A row is one item in the list: one student, one book. Rows are sometimes called records.
students
+----+---------+------+
| id | name | year |
+----+---------+------+
| 1 | Amira | 2 |
| 2 | Jonas | 1 |
+----+---------+------+
Here students is the table, id, name and year are columns, and each line below the header is a row.
Practice exercise
Part A, on paper. Choose something you own a collection of: games, plants, recipes. Write the table name, then four or five column headings, then three example rows.
Part B, in SQL. Turn your paper table into SQL. For a plants table:
CREATE TABLE plants (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
location TEXT,
watered DATE
);
INSERT INTO plants (name, location, watered) VALUES ('Fern', 'Kitchen', '2026-11-20');
SELECT * FROM plants;
NOT NULL means that column must always have a value. Add two more rows and select them again.
Part C, spot the problem. Suppose someone adds a column pot_colours and types "red, blue" into it. What might go wrong?
Self-check answers
What is the difference between a row and a column? A column is a heading that every item shares; a row is one item with a value under each heading.
Why does each column have a type? So the database can reject nonsense, like the word "banana" in a date column, and store and compare values correctly.
Answer to Part C. A column should hold one value per row. "red, blue" squeezes a list into one cell, which makes it hard to search ("which plants have blue pots?") and easy to misspell. The usual fix is a second table with one row per pot. You will meet this idea again under the name normalisation.
What should a table be named? After the kind of thing it holds. Many people use plural names such as plants; some prefer singular. Either is fine, but stay consistent.
Where next
Move on to picking a good primary key, which explains the id column you just used.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.
This page is a free outline. No downloadable files, paid content, courses or certificates are offered on this site.