SQL is the language people use to ask questions of a database. The letters stand for Structured Query Language, and most people say it as “ess-cue-el” or “sequel”. If you have ever used a spreadsheet to sort a list, filter a column or add up a total, you already know the kind of thinking SQL needs. The difference is size and safety. A spreadsheet is good for a few thousand rows that one person edits. A database holds millions of rows that many people and programs read and change at the same moment, and SQL is how they all talk to it.
This first lesson has no software to install. It explains the ideas in plain words, so every later lesson makes sense. Read it slowly. The ideas here, tables, rows, columns and keys, come back in every lesson of the course.
What is a database?
A database is an organised place to keep data so it can be found, changed and shared quickly. When you order food on a phone app, the restaurant list, your address, your past orders and the delivery status all live in a database. When a bank shows your balance, a database holds it. When a company like the one you may apply to keeps its staff records, a database holds those too.
Most databases that people meet at work are relational databases. The word relational means the data is stored in tables, and the tables are linked to each other. You can picture each table as a sheet in a workbook. One sheet holds customers, another holds products, another holds orders. A relational database keeps these sheets separate on purpose, and then lets you connect them when you ask a question.
Tables, rows and columns
Every table has columns and rows. A column is one kind of fact, such as name or price. A row is one thing described by those facts, such as one customer or one product. If a products table has the columns id, name, category and price, then a row might say: product 1 is called Notebook, belongs to Stationery and costs 120.
products
id | name | category | price
1 | Notebook | Stationery | 120
2 | Pen pack | Stationery | 80
3 | Desk lamp | Home | 650
Each column has a data type. Prices are numbers. Names are text. A joining date is a date. The database checks the type, so it will refuse to store the word “cheap” in a price column. This small rule saves a lot of mistakes.
Keys: how rows are told apart
Two people can have the same name. Two products can have the same price. So every table needs a column that is different for every row, and it is called the primary key. Most of the time it is a column called id with the numbers 1, 2, 3 and so on. When you need exactly one row, you ask for it by its primary key.
Now think about orders. An order belongs to a customer. Instead of copying the customer's name and city into every order, the order stores only the customer's id. That column in the orders table is called a foreign key, because it points to the primary key of another table. Storing the name once and pointing to it from many places is the heart of a relational database. If a customer changes city, you update one row and every order is still correct.
What SQL actually does
SQL lets you do four main jobs with a database. Many people remember them as CRUD.
- Create new rows (
INSERT). - Read rows that match a question (
SELECT). - Update values in existing rows (
UPDATE). - Delete rows you no longer need (
DELETE).
Most of your time, especially in a data, analyst, support or testing job, goes to the second job: reading. In the first half of this course you will learn to read data well. After that you will learn to change it safely, design tables and make queries fast.
A SQL statement is a sentence that reads almost like English. For example: SELECT name, price FROM products WHERE price > 500; means “show me the name and price from the products table, only where the price is more than 500”. You will write sentences like this in the next lessons.
Different databases, one language
You will hear the names MySQL, PostgreSQL, SQL Server, Oracle and SQLite. They are database programs, often called database engines, and all of them understand SQL. The basics are the same everywhere: SELECT, WHERE, JOIN, GROUP BY work in all of them. Small things differ, such as how you get the current date or limit the number of rows. This course uses SQLite for practice because it is free, small and needs no server. Where another engine does something differently, the lesson says so.
That means the skills you build here transfer. If your future job uses MySQL or PostgreSQL, you will spend a day learning the small differences, not weeks learning SQL again.
Who uses SQL, and for what?
- Data and business analysts pull numbers for reports: sales by month, customers by city.
- Software developers store and fetch the data behind apps and websites.
- Testers check that the data in the database matches what the screen shows.
- Support and operations staff look up an order or a user to answer a question.
- Finance and HR teams often use SQL-based reporting tools.
SQL appears in many job descriptions, especially for analyst and developer roles, and it is a common topic in interviews. It is not a guarantee of any job, but it is a practical skill that is useful in many kinds of work.
What you will build in this course
You will work with one small shop database: customers, products, orders and the items inside each order. It has only a few rows, so you can see every answer with your own eyes and check your thinking. By the end you will be able to answer questions such as: Which customers have not ordered anything? What did each customer spend? Which product sells the most in each category?
Your task
- Take any spreadsheet you know, such as a contact list or a price list. Write down its column names and say what data type each one holds (number, text or date).
- Decide which column could be a primary key, meaning it is different on every row. If none is, invent an
idcolumn. - Think of a second sheet that connects to it, such as orders for customers. Which column would the second sheet use to point to the first? That is your foreign key.
How to check it worked
- You can say in one sentence what a table, a row and a column are.
- You can explain why orders store a customer id instead of the customer's full name.
- You can name the four basic jobs of SQL: create, read, update and delete.