SQL and databases for testers
Check what the app saved: select, filter and join, find doubles and orphans, make test data, and test constraints and transactions.
- Databases for testersBehind the screen sits a database. Learn its tables, rows and keys so you know what the app really stored and what a fault there looks like.
- Tables, rows, columns and types: what to read before you testBefore any query, see what the database holds.
- Reading an entity-relationship diagramAn ERD shows the tables of a database and how they link. Learn to read one to plan tests and write better data queries.
- Looking at data with SQL SELECTA select query only looks and never changes. With a few clauses a tester can find one row, count rows, spot repeats and find rows with no match.
- SQL (Structured Query Language) filtering, sorting and totals for testersMost checks are a filter and a count. Learn WHERE with AND, OR, IN, BETWEEN and LIKE, then ORDER BY, LIMIT, DISTINCT and the five totals.
- Patterns, lists, ranges and aliases: LIKE, IN, BETWEEN and ASCheck data by a pattern, a list or a range, give columns short names, and learn the order a query really runs in, so your checks give the answer you meant.
- NULL: the value that is not a valueNULL means unknown or missing. It breaks tests that look simple. Learn how NULL behaves in comparisons, counts and constraints.
- SQL (Structured Query Language) CRUD (create, read, update, delete) for testers: INSERT, SELECT, UPDATE and DELETEAlmost every app action is one of four database actions. Learn the four SQL (Structured Query Language) statements and what each one should leave behind.
- Totals in plain words: count, SUM (add up), AVG (average), MIN (smallest) and MAX (largest)Learn the five total functions, what each does with missing values, what they return when no row matches, and how to check a total shown on a screen against a trusted count.
- Aggregation in depth: HAVING, distinct counts and subtotalsA count on a screen can mean rows, values or people. Learn where a filter goes before or after grouping, how a distinct count differs, and how to check subtotals.
- Joins and grouping: check data across tablesData often sits in several tables. A join puts rows side by side and GROUP BY counts them. Learn the checks that catch missing and doubled rows.
- Join types in depth: what each join keeps, and what to testA screen that lists tasks with owners hides a join. Learn what inner, left and full joins keep or drop, so you can predict row counts and spot missing rows.
- Join fan-out: when a total on the screen is too bigA join can repeat a row once for each match, and a sum then counts it again. Learn to state the table grain, spot a wrong total, and test the cases that expose it.
- Anti-joins and the NOT IN trap: finding rows with no matchWhich users have no task? Learn three ways to ask, why one can return nothing when a null is present, and how to test a no-match report.
- SQL (Structured Query Language) UNION, UNION ALL, INTERSECT and EXCEPT for testersSometimes you need to join two result lists or find what is in one and not the other. Learn the four set operators and the count traps.
- Subqueries and window functions: find the odd row outSome data checks need a query inside a query, or a running comparison across rows. Learn the two tools that answer questions like latest per user and second highest.
- case: labels and buckets in a query, and how to test themLearn how case turns values into labels or buckets, what it returns when nothing matches, and how to test the edges of each rule so a label on a screen is never silently wrong.
- CREATE, ALTER and DROP: how tables are made, changed and removedLearn what the three table statements do, what to test when a table is changed, and why a drop needs a backup and a check of what depends on it.
- Database constraints: rules the data must obeyA constraint is a rule the database enforces, such as not empty, unique or linked. Learn to test the rule at the database as well as in the app.
- Indexes and views: faster lookups and saved queriesLearn what an index does and costs, what a view is, and what a tester checks: that an index does not change answers, and that a view shows current data.
- SQL (Structured Query Language) injection: what it is and how a tester checks for itSee how text typed into a form can become part of a query, why a parameterised query stops it, and what a tester tries safely on a test site and reports without harm.
- Finding duplicates and orphan rows with a query, as a testerAfter a save, an import or a move, ask the database two questions: is anything there twice, and does anything point at nothing? Learn both checks and how to report them.
- Window functions in depth: frames, lag and lead, and the latest rowMany reports show a running total, a change since yesterday or the latest item for each user. Learn how a frame of rows works so you can build data that tests them.
- Stored procedures and triggers: logic inside the databaseSome rules run inside the database as stored procedures and triggers. Learn how to test code you cannot see on the screen.
- Database transactions, ACID and isolation: testing for half-saved dataA save that is half done leaves bad data. Learn what a transaction promises and how to test for half-saved data when steps fail or two users act at once.
- Setting up and cleaning test data with SQL (Structured Query Language)Tests need known data to start from and a clean state afterwards. Learn to insert, update and remove test data safely.
- Generating test data with a queryTyping a few rows is fine for one check. A search, a report or a limit needs hundreds. Learn how a query can make rows, dates and names, and how to clean them up.
- Checking data after an actionAfter an action, the screen can look right while the stored data is wrong. Compare the two, and hunt for repeats, missing links and moved data that no longer matches.