System Design
Intermediate
Database Selection and Consistency
Pick storage systems based on access patterns, transaction needs, and operational realities.
35 min
3 sections
sql
nosql
consistency
1
2
3
01. Start with invariants
Section 1 of 3
Choose storage by the correctness rules the business cannot violate. Seat booking, bank transfers, and inventory holds need transactional boundaries. Analytics, recommendations, and activity feeds can often tolerate eventual consistency.
text
Strong invariant examples:
- A seat can be sold once.
- A ledger entry is immutable after posting.
- A username is globally unique.
- A quota cannot go below zero.
Eventual examples:
- Profile search index update.
- Recommendation refresh.
- Aggregated dashboard counter.
- Email open event processing.Back to Course