In short
Before you write a single query, you need a clear picture of where data lives. Every relational database is just a set of tables, and every table follows the same simple shape.
A table describes one kind of thing, each row is one record of that thing, and each column is one attribute with a fixed data type.

Think of it like this
The class attendance register
A school register is about one kind of thing: students. Each line is one student (a row). Each printed heading, like roll number, name and date of birth, is a column, and every entry under it is the same type of value. A database table is that register, kept very strictly.
Watch it happen
From database down to a single column
1/4A database is the container. One project usually has one database.
The big ideas
What you need to know
One table, one kind of thing
students holds students, orders holds orders. Mixing them in one table causes repeated and conflicting data.
A row is one record
One row is one student, one order or one payment. Rows have no guaranteed order inside the table.
A column is one attribute
Each column stores one fact, like city or amount, and has a fixed data type such as INTEGER, TEXT or DATE.
Keep values atomic
Store first_name and last_name separately, or one phone number per row. A column full of comma lists is hard to query.
See it in code
Walk through the code
1CREATE TABLE students (2 roll_no INTEGER,3 name TEXT,4 city TEXT,5 dob DATE6);7 8INSERT INTO students (roll_no, name, city, dob) VALUES9 (101, 'Ananya Iyer', 'Chennai', '2005-04-12'),10 (102, 'Rohit Verma', 'Lucknow', '2004-11-30');11 12SELECT * FROM students;1/3The table definition: four columns, each with a data type.
Build a tiny table, add two rows and read them back. In MySQL, TEXT works too, though VARCHAR(100) is more common.
Save yourself the pain
Common mistakes
Oops
Storing several values in one cell, like phones = '98400 11111, 98400 22222'.
Do this instead
Give each fact its own column or its own row in a related table, so you can filter and count it.
Oops
Expecting rows to come back in the order you inserted them.
Do this instead
Tables are unordered. If order matters, always add ORDER BY to your query.
Oops
Saving dates or amounts as TEXT because it is easier.
Do this instead
Use DATE and NUMERIC. Then sorting, maths and date filters just work.
Your mission
Describe a table in words
Quick check
In an orders table, what does a single row represent?
Go deeper
- 1Open a sample database such as Sakila (MySQL) or dvdrental (PostgreSQL) and list its tables.
- 2For one table, say in plain words what a single row represents.
- 3Spot a column that would be better split into two columns.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.