TOPIC 20/3013 MINNOT STARTED

SQL for BAs: statement types, keys and constraints

Know the five families of SQL statements, the difference between a primary key and a unique key, and the rules a database enforces on its own.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: filing-cabinet rules. Someone builds the drawers. Someone files folders and takes them out. A manager decides who gets a key. A clerk says the day's moves are finished, or undoes them.

Daily List is a made-up to-do app (SYNTHETIC / TRAINING ONLY). The team plans a reminders table. Sam, the , wants to know which family each statement belongs to, because each family carries a different risk.

What it is: (Structured Query Language) is the language a database understands. A table is a grid of rows and columns. Statements fall into groups by what they do. An is one of those families: defining tables, changing rows, reading rows, granting access, or saving and undoing a batch. A primary key is the column that picks out exactly one row and is not NULL. A database constraint is a rule the database applies on its own, such as "this cannot be empty". DELETE removes chosen rows. TRUNCATE empties a table and keeps it. DROP removes the table. Those three are the neighbours people mix up.

Why it matters: A SELECT only looks. An UPDATE with no WHERE rewrites every row. A DROP removes the drawer and everything in it. Sam asks which family a change belongs to before anyone runs it.

The five names are a teaching list. Real products blur the edges a little.

PLAIN WORDS · 2 in this section
constraint
a limit or rule that restricts what can be done
empties
becomes empty, or drains into somewhere else

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the work.

THE REAL JOB The picture helps a newcomer remember the five families of statements and that a key picks out one row while a constraint is a rule the database enforces.

  1. Build the table
  2. Fill it with rows
  3. Look at the rows
  4. Lock who may enter
  5. Confirm or undo
Five families of Structured Query Language (SQL)

HOW THE PICTURE MAPS

How each part of the picture matches the work
In the pictureIn the work
Building the drawersData definition
Filing and removing foldersData manipulation
Looking inside a drawerData query
Handing out keys to the roomData control
Saying "all done" or "undo it"Transaction control

WHERE THIS PICTURE STOPS

  • A cabinet is fixed once built, but a table can be rebuilt with one command.
  • A paper folder has one place. A row can be copied into other tables.
  • A manager sees who opened a drawer, but the database must be told to log it.

HOOK

Build, fill, look, lock, confirm.

REMEMBER IT THIS WAY

A contrast: two neighbours told apart by one test.

Ask of any statement: does it build the drawers, move the folders, or only look inside?

What each part of the trick stands for
In the trickWhat it stands for
build the drawersBuilding the drawers is definition
move the foldersFiling and removing folders is manipulation
look insideLooking inside is query

TELL A FRIEND

Structured Query Language () statements fall into five families by what they do, and a picks out one row. A constraint is a rule the database enforces by itself.

OFTEN MIXED UP WITH SQL for BAs: SELECT and WHERE. That topic teaches how to read rows with SELECT and WHERE. This one names all five families and the rules inside a table.

PRACTISE AND KEEP

Sources for this topic — 6 sources
  1. Market practice

    Constraints (PostgreSQL documentation, data definition chapter) ↗ — PostgreSQL Global Development Group · PostgreSQL 18, §5.5 CHECK/NOT NULL/UNIQUE/primary/foreign keys; publisher page opened6November 2026. Dialect scope explicit.

    §5.5 CHECK/NOT NULL/UNIQUE/primary/foreign keys. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: §5.5 CHECK/NOT NULL/UNIQUE/primary/foreign keys. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  2. Market practice

    SQLite: CREATE TABLE ↗ — SQLite project · SQLite: CREATE TABLE; DEFAULT/NOT NULL/CHECK, primary-key legacy NULL exceptions. Publisher page opened6November 2026.

    DEFAULT/NOT NULL/CHECK, primary-key legacy NULL exceptions. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

  3. Market practice

    SQLite: foreign-key support ↗ — SQLite project · SQLite: foreign-key support; Connection-level enabling and referenced/referencing constraints. Publisher page opened6November 2026.

    Connection-level enabling and referenced/referencing constraints. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

  4. Market practice

    Statements that cause an implicit commit (MySQL reference manual) ↗ — Oracle / MySQL · MySQL 8.4 publisher manual opened6November 2026. §15.3.3 DDL statements that implicitly commit; no claim all database DDL behaves alike.

    Official list of statements that end a transaction in MySQL, including TRUNCATE TABLE. · Checked 2026-11-06

    MySQL8.4 publisher manual opened6November2026. §15.3.3 DDL statements that implicitly commit; no claim all database DDL behaves alike.

  5. Market practice

    TRUNCATE (PostgreSQL documentation) ↗ — PostgreSQL Global Development Group · PostgreSQL 18, TRUNCATE transactional and locking behavior; publisher page opened6November 2026. Dialect scope explicit.

    TRUNCATE transactional and locking behavior. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: TRUNCATE transactional and locking behavior. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  6. Simplified educational illustration

    Payments Signal editorial teaching models — Payments Signal

    This site's own simplified teaching models. · Checked 2026-07-12

    What this simplifies: Daily List people, data and exercises are invented for teaching. Query results belong to the declared fixture and database version. Authorization, business identity, time bounds and unknown-value policy must be agreed in context; no universal mandatory query template is implied.

    Used wherever diagrams, scenarios, figures, or example values are didactic constructions rather than sourced facts; every such use carries a simplifications disclosure. All people, companies, banks, and list entries in examples are fictional.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.