bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/System Design/Building Blocks
System Design•Building Blocks

Databases & Indexing

Choose storage by access pattern, not popularity. Relational databases give transactions, joins, and strong consistency; NoSQL stores trade those for horizontal scale and flexible schemas. Indexes make reads fast but slow writes and cost space.

Key ideas

  • Use a relational (SQL) database when you need transactions, joins, and strong consistency — orders, payments, inventory.
  • Use a key-value, document, or wide-column store for massive scale, simple access patterns, or flexible schemas.
  • Index the columns you filter and sort on — but every index adds write cost and storage, so index deliberately.

Compare

StoreBest for
Relational (SQL)Transactions, joins, strong consistency
Key-valueO(1) lookups by key — caches, sessions, mappings
DocumentFlexible, nested records
Wide-columnHuge write volume, time-series, feeds

Tip

Let the query you run most often drive the schema and index design — model for reads.

Previous

Sharding & Replication

Next

Queues & Async Work