Courses / Databases for Backend Interviews
Course · Beta · FreeDatabases for Backend Interviews
Start with why databases exist and how to model data: entities and relationships, the relational model, functional dependencies and normal forms. Then write SQL by pattern: aggregation, filtering, comparison, sequences and hierarchies, and reshaping, with timed practice. The last third covers what senior backend rounds ask about: indexes and query plans, transactions, isolation and locking, replication, partitioning and sharding, and how to choose between relational and NoSQL stores.
0 of 27 chapters done · saved on this device
Try a scene from chapter 1
Watch for the test step sending the answer back to Build
Read it as steps
The retention question: the April range written with BETWEEN fails the test and returns to Build.
What you will be able to do
- Turn written requirements into an ER model and then into tables with the right keys and constraints
- Find the functional dependencies in a table and normalise it to 3NF or BCNF, or explain why not to
- Recognise which SQL pattern a question needs and write it with joins, window functions and recursive CTEs
- Read an EXPLAIN ANALYZE plan and choose the index that fixes a slow query
- Explain isolation levels, MVCC and locks with real two-session runs, and pick one for a given bug
- Plan replicas, partitions and shards, and choose between a relational and a NoSQL store for a workload
Who it is for
Backend and full-stack engineers with about 2 to 10 years of experience who use a database through an ORM or a driver every day and now face SQL rounds, schema design questions and database deep dives. Students who have written basic SQL can follow; every term is defined when it first appears.
You will need
Basic SQL (SELECT, WHERE, a simple join) and enough TypeScript or JavaScript to read a short Node script. Node 22.18 or later to run the examples, which were tested on Node 24. Nothing to install beyond npm packages; no cloud account is needed.
Pick a path
Curriculum
12 modules · 27 chapters · 14 hModule 1Start here0 of 1 done
How SQL rounds, schema design questions and database deep dives run, what interviewers score, a method for answering, and a study plan for this course.
Module 2Database foundations0 of 2 done
What breaks when an application keeps its data in plain files, and what a database management system does instead, from the catalogue to data independence.
- Not started: 02Before Databases: What Goes Wrong with Plain Files20 min · 2 scenesLost updates, torn writes, duplicated data and missing rules when an app stores records in files
- Not started: 03Databases and the DBMS: Catalogues, Schemas and Data Independence22 min · 1 sceneWhat a DBMS does, the catalogue that describes the data, the three-schema architecture and roles
Module 3Data modelling and the ER model0 of 2 done
Turn requirements into a conceptual, logical and physical model, then draw entities, attributes and relationships and map them to tables.
- Not started: 04Data Modelling: From Requirements to Conceptual, Logical and Physical Models22 min · 1 sceneRead requirements for entities, rules and access needs, then refine a model down to Postgres tables
- Not started: 05The Entity-Relationship Model: Entities, Relationships, Cardinality and Mapping33 min · 2 scenesEntities, attributes, cardinality, participation, weak entities and subtypes, mapped to real tables
Module 4The relational model and normalisation0 of 3 done
Relations, keys and integrity rules, relational algebra and its SQL forms, functional dependencies, and the normal forms that remove update anomalies.
- Not started: 06The Relational Model: Relations, Keys, Integrity and Relational Algebra30 min · 2 scenesRelations and keys, entity and referential integrity, and relational algebra written as SQL
- Not started: 07Functional Dependencies: Closures, Candidate Keys and Minimal Covers19 min · 1 sceneTest a dependency against data, derive others with Armstrong's axioms, and find keys by closure
- Not started: 08Normalisation: Anomalies, 1NF to BCNF, and When to Denormalise34 min · 2 scenesRemove update anomalies with 1NF to BCNF, check decompositions, and denormalise only on purpose
Module 5Structured Query Language0 of 1 done
The SQL a backend engineer writes every week on PostgreSQL 18: tables and constraints, changes and upserts, queries, NULL, joins, subqueries, views and permissions.
Module 6SQL patterns: aggregation and filtering0 of 3 done
A map of query patterns and one practice schema, then counting and bucketing rows, rolling totals, and filtering by existence, exclusion and rank.
- Not started: 10SQL Query Patterns: A Pattern Map and the Practice Schema21 min · 1 sceneThe pattern families, the clues that point to each, the grocery schema the patterns use, and a refresher
- Not started: 11Aggregation Patterns: Tally Counts, Group Buckets and Rolling Totals34 min · 2 scenesConditional counts, buckets with no gaps, subtotals with ROLLUP, and running totals that handle ties
- Not started: 12Filtering Patterns: Existence, Exclusion, Aggregate Filters and Top-N per Group34 min · 2 scenesHalf-open ranges, semi-joins and anti-joins, HAVING, top-N per group and removing duplicates
Module 7SQL patterns: comparing, sequencing and reshaping0 of 4 done
Compare rows with groups, neighbours and earlier periods, find streaks and sessions, walk hierarchies with recursion, reshape results, then practise against the clock.
- Not started: 13Comparison Patterns: Row Against Group, Neighbour and Earlier Period26 min · 1 sceneCompare a row with its group, the row before it, a paired row and the same period last month
- Not started: 14Sequencing and Hierarchy Patterns: Streaks, Sessions and Recursive Trees33 min · 2 scenesNumber events, find streaks and sessions, and walk category trees and org charts with recursive CTEs
- Not started: 15Transformation Patterns: Pivoting, Unpivoting, Text and JSON21 min · 1 sceneTurn rows into columns and back, split and join text, and build or flatten JSON in SQL
- Not started: 16Timed SQL Practice: Three Rounds Across Every Pattern14 minThree timed sets of original problems with run solutions, and public problems to practise next
Module 8Indexes and query plans0 of 2 done
How Postgres finds rows: heap pages, B-trees and other index types, how to design an index for a query, and how to read the plan the optimizer chose.
- Not started: 17Indexes: B-Trees, Composite Keys, Covering and Partial Indexes50 min · 3 scenesHeap pages, B-tree levels, column order, index-only scans, partial and GIN indexes, and their write cost
- Not started: 18Query Plans: EXPLAIN, Statistics and Join Algorithms37 min · 2 scenesRead EXPLAIN ANALYZE, see how statistics drive estimates, compare join algorithms, find slow queries
Module 9Transactions, isolation and locking0 of 3 done
What a commit guarantees and how the write-ahead log keeps that promise, which anomalies each isolation level allows in Postgres, and how locks and retries keep concurrent writes correct.
- Not started: 19Transactions: ACID, the Write-Ahead Log and Crash Recovery38 min · 2 scenesACID in practice, aborted transactions and savepoints, WAL and commits, crash recovery, idempotency
- Not started: 20Isolation Levels and MVCC: Anomalies, Snapshots and Vacuum38 min · 2 scenesReproduce each anomaly in two sessions, see what each Postgres level allows, and how MVCC and vacuum work
- Not started: 21Locks and Concurrency Control: Row Locks, Deadlocks and Optimistic Updates37 min · 3 scenesTable and row locks, SKIP LOCKED queues, version checks, deadlocks, and the lock queue behind DDL
Module 10Replication, partitioning and sharding0 of 2 done
Copy data to standbys and live with lag and failover, split a large table into partitions, and spread data across shards with a key you can keep.
- Not started: 22Replication: Streaming Standbys, Lag, Failover and Logical Replication38 min · 2 scenesRun a real standby, choose sync or async, handle stale reads, promote on failure, replicate logically
- Not started: 23Partitioning and Sharding: Partition Keys, Routing and Resharding41 min · 2 scenesRange, list and hash partitions with pruning, then shard keys, a small router, and what resharding moves
Module 11NoSQL and choosing a database0 of 3 done
Key-value, document, wide-column and graph models and their consistency trade-offs, key design in DynamoDB, and a method for matching a workload to a store.
- Not started: 24NoSQL Data Models: Key-Value, Document, Wide-Column and Graph36 min · 1 sceneWhat each NoSQL model stores well, Redis and JSON documents run locally, and CAP and PACELC stated precisely
- Not started: 25Modelling for a Key-Value Store: DynamoDB Keys, Indexes and Transactions37 min · 2 scenesPartition and sort keys from access patterns, GSIs, conditional writes, transactions and capacity maths
- Not started: 26Choosing a Database: Matching Workloads to Relational and NoSQL Stores30 min · 1 sceneQuestions that decide a store, three worked choices, and the real cost of running several stores
Module 12Mock interview0 of 1 done
Five timed prompts across SQL, schema design, query tuning and concurrency, each with a model answer and a rubric to score yourself.
How this course is made
Written by the aiiolar team. Every chapter is fact-checked by a second reviewer, checked against a shared set of numbers so chapters agree, and checked for originality before it goes up. Found a mistake? Tell us and we fix it within a week.
Questions
Which database does the course use?
PostgreSQL 18 for everything relational, run either inside Node with PGlite or as a real local server for the chapters that need two sessions, timings or replication. The NoSQL chapters run Redis and PostgreSQL JSON documents on your own machine, and the DynamoDB chapter runs on a small in-memory model of the service, not on DynamoDB itself. Differences in MySQL are named where they matter.
Do I need Docker or a cloud account?
No. Every example runs from npm packages and local downloads on your own machine. Behaviour that only exists in a hosted service, such as DynamoDB throttling, is taught from the official documentation and labelled that way.
Is the SQL tested?
Yes. Every query on the page was run and its output was copied from that run. Where a result depends on timing or on the order two sessions run in, the page says so and shows one real run.
How is it different from the System Design course?
System Design treats a database as one building block among many. This course stays inside the database: how to model data, how to query it, and what indexes, transactions, replicas and shards actually do. The two link to each other where they meet.
How much time should I plan?
About 14 hours of reading, plus time for the practice sets and for running the examples. Most people preparing for a round do one chapter a day and repeat the timed practice and the mock interview in the last week.
Do I need to know database theory first?
No. The early chapters teach the theory interviewers expect, such as keys, normal forms and relational algebra, with runnable examples instead of proofs.