🌍 System Design · subject

System Design Data Storage and Databases Syllabus

The Data Storage and Databases syllabus for System Design in full: 6 chapters and 25 topics, every one listed below, plus 51 Data Storage and Databases flashcards with answers.

6Chapters
25Topics
51Flashcards

Data Storage and Databases syllabus: all 6 chapters

Expand any chapter to see its topics and sub-topics.

  1. Relational Databases

    4 topics
    • ACID Transactions
    • Normalization and Schema Design
    • Indexing and B-Trees
    • Isolation Levels and Locking
  2. NoSQL Databases

    5 topics
    • Key-Value Stores
    • Document Stores
    • Wide-Column Stores
    • Graph Databases
    • BASE vs ACID
  3. Database Scaling

    4 topics
    • Replication
    • Sharding and Partitioning
    • Federation and Denormalization
    • Read Replicas and Write Scaling
  4. Storage Engines and Data Structures

    4 topics
    • LSM Trees and SSTables
    • B-Tree Storage Engines
    • Write-Ahead Logging
    • Bloom Filters
  5. Specialized Data Stores

    4 topics
    • Time-Series Databases
    • Search Engines and Inverted Indexes
    • Object and Blob Storage
    • Data Warehouses and OLAP
  6. Distributed Transactions

    4 topics
    • Two-Phase Commit
    • Saga Pattern
    • Outbox Pattern
    • Idempotency and Exactly-Once Semantics

System Design Data Storage and Databases flashcards — 51 questions with answers

  1. What does the ACID acronym stand for in database transactions?

    Atomicity, Consistency, Isolation, Durability. Together they guarantee that transactions are processed reliably even under failures and concurrency.

  2. Define Atomicity in the context of ACID transactions.

    A transaction is all-or-nothing: either every operation commits successfully, or the entire transaction is rolled back leaving no partial effects.

  3. What does Durability guarantee in an ACID transaction?

    Once a transaction is committed, its changes persist permanently even if the system crashes immediately afterward, typically ensured via write-ahead logging or fsync to non-volatile storage.

  4. In relational normalization, what condition defines First Normal Form (1NF)?

    Every column holds atomic (indivisible) values and there are no repeating groups or arrays; each cell contains a single value.

  5. State the rule for Second Normal Form (2NF).

    The table is in 1NF and every non-key attribute is fully functionally dependent on the whole primary key (no partial dependency on part of a composite key).

  6. State the rule for Third Normal Form (3NF).

    The table is in 2NF and has no transitive dependencies: non-key attributes depend only on the primary key, not on other non-key attributes.

  7. What is Boyce-Codd Normal Form (BCNF) and how does it strengthen 3NF?

    BCNF requires that for every non-trivial functional dependency $X \to Y$, $X$ must be a superkey. It removes anomalies that 3NF can still permit when candidate keys overlap.

  8. What is the main trade-off of normalization?

    Normalization reduces data redundancy and update anomalies but requires more joins at read time, which can hurt read performance; denormalization trades storage/consistency for faster reads.

  9. What is a database index and what is its primary purpose?

    An auxiliary data structure that maps column values to row locations, allowing lookups to skip full table scans, reducing search from $O(n)$ toward $O(\log n)$.

  10. Why are B-Trees (B+ Trees) the standard structure for database indexes?

    They are balanced, keep data sorted, have high fan-out so trees stay shallow, and support $O(\log n)$ lookups, inserts, deletes, and efficient range scans while matching disk page sizes.

  11. In a B+ Tree, where are the actual data pointers stored versus internal nodes?

    All keys and record pointers live in the leaf nodes, which are linked in a sorted linked list; internal nodes hold only routing keys to guide the search.

  12. For a B-Tree of order $m$ holding $n$ keys, what is the search time complexity?

    $O(\log_{m} n)$ node accesses, so height stays low; because fan-out $m$ is large (hundreds), even billions of rows need only a few disk reads.

  13. What is the trade-off between more indexes and write performance?

    Each index speeds reads but must be updated on every insert/update/delete, adding write overhead and storage; over-indexing slows writes.

  14. Name the four standard SQL isolation levels from weakest to strongest.

    Read Uncommitted, Read Committed, Repeatable Read, Serializable.

  15. Which read phenomenon does Read Committed prevent but Read Uncommitted allow?

    Dirty reads (reading uncommitted data from another transaction). Read Committed only sees committed data; Read Uncommitted can see uncommitted changes.

  16. What is a phantom read and which isolation level prevents it?

    A phantom read occurs when a re-executed range query returns new rows inserted by another committed transaction. Only Serializable fully prevents phantoms.

  17. Match the three read anomalies to the isolation levels that permit them.

    Read Uncommitted allows dirty reads, non-repeatable reads, phantoms. Read Committed allows non-repeatable reads and phantoms. Repeatable Read allows phantoms only. Serializable allows none.

  18. What is the difference between a shared lock and an exclusive lock?

    A shared (read) lock permits concurrent readers but blocks writers; an exclusive (write) lock blocks all other readers and writers. Multiple shared locks coexist; an exclusive lock is incompatible with any other lock.

  19. What is Two-Phase Locking (2PL) and its two phases?

    A concurrency protocol guaranteeing serializability: a growing phase where a transaction only acquires locks, and a shrinking phase where it only releases them. No lock is acquired after any is released.

  20. What is Multi-Version Concurrency Control (MVCC)?

    A technique where writes create new versions of rows rather than overwriting, so readers see a consistent snapshot without blocking writers, avoiding read-write lock contention.

Show the other 31 Data Storage and Databases flashcards
  1. What is a key-value store and its core operations?

    The simplest NoSQL model: an associative map of unique keys to opaque values, supporting $O(1)$ average get(key), put(key, value), and delete(key). Examples: Redis, DynamoDB, Riak.

  2. What data model does a document store use and how does it differ from key-value?

    It stores semi-structured documents (JSON/BSON/XML) whose fields can be indexed and queried, unlike opaque key-value blobs. Examples: MongoDB, CouchDB.

  3. Describe the wide-column store data model.

    Data is stored in tables of rows keyed by a row key, where each row can have different columns grouped into column families; optimized for large-scale writes and sparse data. Examples: Cassandra, HBase, Bigtable.

  4. What problem are graph databases optimized for, and what are their core primitives?

    They model highly connected data using nodes (entities) and edges (relationships with properties), enabling efficient traversal of relationships (e.g., social graphs) that would require many costly joins in SQL. Examples: Neo4j, Amazon Neptune.

  5. What does the BASE acronym stand for?

    Basically Available, Soft state, Eventual consistency. It is the availability-favoring counterpart to ACID common in NoSQL systems.

  6. Contrast the consistency philosophy of ACID versus BASE.

    ACID enforces strong, immediate consistency and isolation (favoring correctness). BASE relaxes consistency to eventual, prioritizing availability and partition tolerance and scaling.

  7. State the CAP theorem.

    A distributed data store can simultaneously guarantee at most two of: Consistency, Availability, and Partition tolerance. Under a network partition you must choose between C and A.

  8. What is database replication and its two primary goals?

    Maintaining copies of data on multiple nodes. Goals: high availability/fault tolerance (survive node failure) and read scalability (spread reads across replicas).

  9. Contrast synchronous versus asynchronous replication.

    Synchronous replication waits for replicas to acknowledge before committing (strong consistency, higher latency). Asynchronous commits on the primary first and propagates later (lower latency, risk of data loss / stale replicas).

  10. Compare single-leader (master-slave) and multi-leader replication.

    Single-leader: one primary accepts writes, replicas are read-only copies; simple, no write conflicts. Multi-leader: multiple nodes accept writes; higher write availability but requires conflict resolution.

  11. What is the difference between horizontal partitioning (sharding) and vertical partitioning?

    Horizontal partitioning splits rows across shards by a shard key. Vertical partitioning splits columns/tables across servers by feature or access pattern.

  12. What is a shard key and why is its choice critical?

    The attribute used to route a row to a shard. A poor key causes hotspots and uneven load; a good key distributes data and queries evenly and avoids cross-shard operations.

  13. Compare range-based versus hash-based sharding.

    Range sharding assigns contiguous key ranges to shards (good for range scans, risks hotspots on sequential keys). Hash sharding applies a hash to the key for uniform distribution (even load, but range queries hit all shards).

  14. What is consistent hashing and what problem does it solve in sharding?

    A hashing scheme mapping keys and nodes onto a ring so that adding/removing a node remaps only about $\frac{1}{n}$ of keys instead of nearly all, minimizing reshuffling. Virtual nodes improve balance.

  15. What is database federation?

    Splitting databases by function/feature (e.g., separate DBs for users, products, orders) so each handles its own read/write load, reducing contention and replication lag on any single database.

  16. What is denormalization and when is it used?

    Deliberately adding redundant/duplicated data (e.g., precomputed joins or aggregates) to avoid expensive joins and speed reads, at the cost of extra storage and the need to keep copies in sync on writes.

  17. What are read replicas and what scaling problem do they address?

    Read-only copies of a primary database that serve read queries, offloading the primary to scale read-heavy workloads. They do not scale writes and may return slightly stale data due to replication lag.

  18. Why is scaling writes harder than scaling reads, and what technique addresses it?

    All writes must reach the authoritative copy, so replicas cannot absorb them. Write scaling requires sharding/partitioning to split write load across independent primaries.

  19. What is replication lag and one consequence for application design?

    The delay between a write on the primary and its appearance on a replica. It can cause read-your-writes inconsistency, so apps may route a user's reads to the primary or use monotonic-read techniques.

  20. What is an LSM Tree (Log-Structured Merge Tree)?

    A write-optimized structure that buffers writes in an in-memory memtable, flushes them as immutable sorted files (SSTables) to disk, and periodically merges (compacts) them. Used by Cassandra, RocksDB, LevelDB.

  21. What is an SSTable?

    A Sorted String Table: an immutable on-disk file storing key-value pairs sorted by key, enabling efficient sequential writes, merges, and binary-search/index lookups. It is the persistent unit of an LSM tree.

  22. In an LSM tree, what is compaction and why is it needed?

    A background process that merges multiple SSTables, discarding overwritten and deleted (tombstoned) entries, to reclaim space, keep read amplification bounded, and maintain sorted order.

  23. Compare the write and read characteristics of LSM trees versus B-Tree storage engines.

    LSM trees favor writes (sequential appends, high write throughput, higher read/space amplification). B-Trees favor reads and do in-place updates (random writes, lower read amplification, better for read-heavy/range workloads).

  24. What is write amplification and why does it matter for storage engines?

    The ratio of bytes physically written to disk versus bytes of logical data written by the application. High write amplification (from B-Tree page rewrites or LSM compaction) wears out SSDs and consumes I/O bandwidth.

  25. What is Write-Ahead Logging (WAL) and the rule it enforces?

    A durability technique where every change is appended to a sequential log on stable storage before the change is applied to the main data files. The rule: log the intent before mutating data, so crashes can be recovered by replaying the log.

  26. How does WAL support Atomicity and Durability?

    Durability: committed changes are safely in the log even if data pages are not yet flushed. Atomicity: on recovery, committed transactions are redone and uncommitted ones are undone/ignored, ensuring all-or-nothing effects.

  27. What is a Bloom filter and what does it answer?

    A space-efficient probabilistic bit-array structure that answers set membership. It can return false positives but never false negatives: 'possibly in set' or 'definitely not in set'.

  28. For a Bloom filter with $m$ bits, $n$ elements, and $k$ hash functions, what is the approximate false-positive probability?

    $$p \approx \left(1 - e^{-kn/m}\right)^{k}$$ and the optimal number of hash functions is $k = \frac{m}{n}\ln 2$.

  29. How do LSM-tree databases use Bloom filters to speed reads?

    Each SSTable has a Bloom filter; before reading a file for a key, the engine checks its filter and skips the disk read entirely if the filter says the key is definitely absent, cutting read amplification.

  30. What is a time-series database optimized for, and name two examples?

    Storing and querying timestamped data points (metrics, sensor readings) with high write throughput, time-range queries, downsampling, and retention/rollup policies. Examples: InfluxDB, Prometheus, TimescaleDB.

  31. Why do time-series databases favor append-heavy, time-partitioned storage?

    Time-series workloads are write-mostly with immutable, chronologically ordered inserts and queries over recent time windows; partitioning by time enables efficient appends, compression of similar values, and cheap dropping of expired partitions.

System Design Data Storage and Databases FAQ

What is in the System Design Data Storage and Databases syllabus?

System Design Data Storage and Databases is split into 6 chapters: Relational Databases, NoSQL Databases, Database Scaling, Storage Engines and Data Structures, Specialized Data Stores and Distributed Transactions. Together they contain 25 topics.

How many chapters are in System Design Data Storage and Databases?

6 chapters, containing 25 topics. The largest chapter is NoSQL Databases, with 5 topics.

Are there flashcards for System Design Data Storage and Databases?

Yes — a 51-card Data Storage and Databases deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.