Quick revision
The short answer
The choice follows from the access patterns, the read and write rates, the data size and growth, the consistency and transaction needs, and how often new queries will appear. With those answers, user profiles start in PostgreSQL with a replica or a cache, chat messages go to a wide-column store partitioned by conversation and bucketed by time, and the billing ledger stays relational with ACID transactions. A good answer also says what numbers would change each choice and admits that running two kinds of database has a cost.
What to remember
In this answer, we saw that the database choice comes from the access patterns, rates, size, consistency needs and how often queries change. Profiles are small and flexible, so PostgreSQL with a replica or cache is enough. Chat messages arrive at about 23,000 per second and grow by over a hundred terabytes a year, read only by conversation and time, so a wide-column store partitioned by conversation and time bucket fits. The ledger needs transactions and constraints, so it stays relational. We also named the thresholds that would change each choice and the real cost of operating two kinds of database.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The choice follows from the access patterns, the read and write rates, the data size and growth, the consistency and transaction needs, and how often new queries will appear. With those answers, user profiles start in PostgreSQL with a replica or a cache, chat messages go to a wide-column store partitioned by conversation and bucketed by time, and the billing ledger stays relational with ACID transactions. A good answer also says what numbers would change each choice and admits that running two kinds of database has a cost.
Why this question is asked
In a system design interview, the database choice is one of the first places where the interviewer can tell habit from reasoning. Saying NoSQL because it scales, or PostgreSQL because we always use it, both miss the point. The interviewer wants to hear the questions we ask, a quick calculation with the given numbers, and a choice we can defend and revisit. In this answer, we will list the deciding questions and why each matters, run the numbers for user profiles, chat messages and a billing ledger, choose a store for each, and say what would change the choice, including the follow-up about putting profiles in a key-value store.
1The Questions That Decide
The first question is how the data is read. A store is fast for the queries its layout was designed for. If every read is by one key, almost any store works. If reads are range scans within a group, such as messages of one conversation in time order, a store that keeps that group together on disk is ideal. If the product needs ad hoc filters, joins across entities, or reports that nobody has thought of yet, a relational database with SQL is far more forgiving.
The second is the rate and size: writes and reads per second at average and peak, bytes per record, total size and growth per year. These numbers tell us whether one primary database can carry the load at all. The third is consistency and transactions: do several records have to change together or not at all, must a value be unique, can a reader see slightly stale data? The last is change: how often will new query patterns appear? A NoSQL model is designed around known queries, so every new query may need a new table or index, while SQL absorbs new queries with an index.
| Question | Points toward relational | Points toward NoSQL |
|---|---|---|
| How is it read? | joins, ad hoc filters, reports | by key, or range within one partition |
| How fast does it grow? | fits one primary for years | beyond one machine's write rate |
| Transactions and constraints? | multi-row ACID, uniqueness | single-item updates are enough |
| How often do queries change? | often, unknown future reports | rarely, access patterns are fixed |
2User Profiles: 10 Million Users, Read-Heavy
Ten million rows of perhaps 2 KB each is about 20 GB, which fits in the memory of a modest PostgreSQL server. Reads might be a few thousand per second at peak, which one primary with a read replica, or a cache such as Redis in front of it, handles easily. Profiles have constraints (unique email, unique handle), and product teams will ask new questions such as users who signed up last month in Germany, which SQL answers with an index.
So we would start with PostgreSQL. There is nothing here that needs horizontal partitioning, and the flexibility is worth more than raw scale we do not need.
3Chat Messages: 2 Billion a Day
Now the numbers change the answer. Two billion messages a day divided by 86,400 seconds is about 23,000 writes per second on average, and peaks might be three times that. At around 200 bytes per message with metadata, that is about 400 GB a day, roughly 150 TB a year before replication. One relational primary can do tens of thousands of simple inserts per second, but not at this size and growth for years, so we would end up sharding it by hand.
The read pattern is narrow and known: load the latest messages of one conversation, then page back in time. That is exactly what a wide-column store such as Cassandra or ScyllaDB is built for. We partition by conversation id so a conversation's messages are stored together, and add a time bucket, for example a month, to the partition key so a very long conversation does not grow one partition without limit. Messages are clustered by a time-ordered id within the partition, so the newest page is one sequential read.
4Billing Ledger: Correctness First
A ledger records money movements, and its rules are strict: entries are double-entry and must balance, a balance must never be computed from half of a transfer, and the same payment must never be recorded twice. Those are multi-row transactions, unique constraints and careful locking or serializable isolation, which is exactly what a relational database such as PostgreSQL gives us. Ledgers are also smaller than they sound: even a large business with a few thousand entries per second at peak stays within what one well-run primary handles, with partitioning by time for older entries.
So the ledger stays relational. If it ever outgrows one primary, we would split it by account ranges or by business entity, still on a relational engine, rather than give up transactions.
5What Would Change the Choice
A good answer names the thresholds. If chat volume were 100 times lower, around 230 writes per second and about 1.5 TB a year, PostgreSQL with a table partitioned by month would be simpler and good enough, and we would keep one kind of database. If profiles grew to a billion users, or if they were read at hundreds of thousands of requests per second purely by id, a key-value store would start to make sense.
We should also say that running two kinds of database has a cost of its own: two backup and restore procedures, two sets of monitoring, two kinds of on-call expertise, and data that must be joined across systems in the warehouse. For a small team, that cost alone can justify keeping chat on PostgreSQL longer than the numbers suggest.
6Follow-up questions
What would make you put profiles in a key-value store instead?
Three things together would: a very high read rate that is purely by user id, such as a profile service serving hundreds of thousands of requests per second to other services; a size or global distribution need where users must be served from several regions with low latency; and an access pattern with no joins or ad hoc queries because reporting goes through the warehouse. Even then, many teams keep PostgreSQL as the source of truth and put a key-value cache in front of it.
Why not use one database for all three services to keep things simple?
One kind of database is a fair goal, and PostgreSQL could carry profiles and the ledger. The chat service is the one whose numbers push it out. If the team is small and the volume is uncertain, starting chat on partitioned PostgreSQL and planning a migration path is a reasonable trade-off, as long as we watch the growth.
Is MongoDB a good choice for chat?
It can work, sharded by conversation id, but a wide-column store is a more natural fit for an append-heavy, time-ordered workload of this size because its storage engine is optimised for sequential writes and reads within a partition. The more important point in an interview is to explain the partitioning and the read pattern, whatever store we name.
7Conclusion
In this answer, we saw that the database choice comes from the access patterns, rates, size, consistency needs and how often queries change. Profiles are small and flexible, so PostgreSQL with a replica or cache is enough. Chat messages arrive at about 23,000 per second and grow by over a hundred terabytes a year, read only by conversation and time, so a wide-column store partitioned by conversation and time bucket fits. The ledger needs transactions and constraints, so it stays relational. We also named the thresholds that would change each choice and the real cost of operating two kinds of database.
Open with
I would start by asking how each service is read and written, at what rate, how big the data gets, whether it needs transactions or uniqueness, and how often new queries will appear.
Then, if they want more
For user profiles, ten million users at a couple of kilobytes each is about 20 gigabytes, read-heavy, with constraints like unique email and lots of ad hoc product questions, so I would use PostgreSQL with a read replica or a Redis cache.
For chat, two billion messages a day is about 23,000 writes a second on average, and roughly 150 terabytes a year, but the reads are always the latest messages of one conversation. That fits a wide-column store like Cassandra, partitioned by conversation id plus a time bucket and clustered by a time-ordered message id.
For the billing ledger, correctness beats scale: double-entry transactions, unique payment ids and careful locking, so it stays in PostgreSQL.
I would also say what changes the choice: at a hundred times less chat volume I would keep chat in partitioned PostgreSQL, and I would remember that running two kinds of database means two sets of backups, monitoring and on-call skills.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Which questions decide between a relational database and a NoSQL store, and which store...": https://scrivio-interview-library.netlify.app/architecture/storage-and-pipelines/54aa87a338/