SQL vs NoSQL: how to choose
"SQL or NoSQL?" comes up in nearly every design round, because the answer shows whether you choose from requirements or from habit. A strong answer has three parts: a default, the specific needs that would move you off it, and the numbers that show whether this design has those needs.
The family doctor and the specialist
When you're unwell, you see your family doctor first. She handles most problems, knows your whole history, and can deal with several things in one visit. You see a specialist when there's a named reason, like a knee that needs surgery. The specialist is better at that one thing, and you wouldn't ask them about your cough. And the referral letter says why you're there.
- you, the patient → your app and its data
- the family doctor → a relational database such as PostgreSQL or MySQL: handles most workloads, with joins, transactions and questions nobody planned for
- the specialist → a NoSQL store, picked for one named need: a write rate one machine can't take, key lookups at huge scale, deep graph walks
- the referral letter → the requirement and the number behind the switch