Lesson 2 · Unit 04
SQL or NoSQL
What each kind of database gives up, and what it gets
What you practise
- Key-value, document, wide-column and graph stores
- What each gives up (joins, transactions, schema) and gets (scale-out, flexible shape)
- Questions to ask before choosing
- "use Postgres until it hurts"
Try a question from this lesson
Pick one
A login session is stored and fetched by its session id, millions of times a second. It is never searched or joined any other way. What is the simplest store that fits?
Correct answer
A key-value store
Why
If the only question you ever ask is "give me the value for this key", you need a giant hash map and nothing more. No joins, no query planner, and very little to slow it down.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
What NoSQL trades
Relational databases give you joins, transactions across any rows, and a fixed schema. All three are hard to keep once data is spread over many machines.
NoSQL stores give some of them up. In return they spread across machines easily and let every item have its own shape.
The question is never which is better. It is which trade your data needs.
10 more exercises in the app
- 1× match the pairs
- 2× type the answer
- 1× true or false
- 4× multiple choice
- 1× fill the blanks
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.