SQL databases

Beginner 12 min read

Tables, keys and queries: how applications store data reliably in a relational database.

Why it matters

Almost every application keeps its important data in a SQL database. A good table design and a few correct queries prevent slow pages, duplicated data and lost updates.

Where it fits

  1. Plan & Design
  2. ● Develop › Data
  3. Version control
  4. Verify
  5. Build & Package
  6. CI/CD
  7. Deploy
  8. Operate

What you will learn

  • Create a table with a primary key and the right column types.
  • Insert, select, filter and sort rows.
  • Explain what a transaction guarantees.

Before you start

Tables, rows and keys

A table is a list of rows with the same columns. A primary key identifies each row; a foreign key points to a row in another table. The database enforces these rules, so bad data cannot get in.

Example
CREATE TABLE users (
    id INTEGER PRIMARY KEY,
    email TEXT NOT NULL UNIQUE
);

INSERT INTO users (email) VALUES ('ana@example.com');

SELECT id, email FROM users ORDER BY email;

Transactions

A transaction groups statements so that they all succeed or none do — moving money between two accounts must never apply only half. Use them whenever one action changes several rows.

Watch out: Build queries with parameters (placeholders), never by joining user input into the SQL string. That is how SQL injection happens.

Install and set up

Official documentation and references

Documentation

Guides

Practise in Zerethon IDE

Learn next

Done with this topic?

Reviewed 2026-10-23. Links go to the official documentation unless marked otherwise.