AI Hints
Home›System Design Tutorial›Choosing Storage
System Design · Lesson 52 of 120

Choosing a Database

A decision guide.

⏱ 2 min read▶ Video at 1:01:21🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

We've met a lot of storage options. Now, how do you choose? Start from the data, and the questions you'll ask about it, not from the database that's fashionable this year.

Choosing a Database
From the video: Choosing a Database
  • Many options
  • Start from the data
  • And your questions

A decision guide

Here's a simple guide. Structured data with relationships and transactions, use a relational database. Simple lookups by key, at huge scale, use a key value store. Flexible records, use a document store. Big files, use object storage. Full text search, use a search engine. And time stamped measurements, use a time series database.

DataChoose
Related, transactionalRelational (Postgres)
Lookup by key, huge scaleKey-value (DynamoDB)
Flexible recordsDocument (MongoDB)
Big filesObject storage (S3)
Full-text searchSearch (Elasticsearch)
Metrics over timeTime-series

Good habits

A few habits help. Default to a relational database, because it's flexible and well understood. Add a specialised store only when you have a clear need. Remember that every extra database is one more thing to run, back up, and monitor. And keep one source of truth for each piece of data.

keyvalue
Defaultrelational
Specialisefor a clear need
Each storecosts operations
One truthper piece of data

Summary

Choose storage from the shape of your data and your queries. Default to relational, and add specialised stores when needed. Next, let's practise with Shoply.

Key takeaways
  • Data shape first
  • Relational by default
  • Specialise with reason
Next up: Practice: Shoply's Data — which store for what