XorByte

System Design Interview - Databases Part 1

May 06, 2020

Scenario

You are in your system design interview after cracking the Data Structures and Algorithmic coding rounds, now in this round the interviewer would ask you to either design Netflix, Facebook, Reddit, Twitter, Whatsapp, Amazon or maybe Uber or anything huge in a matter of 45-60 mins.

Databases - System design interview

Key Considerations

  • The interviewer wants you to have a higher level view of the system but at the same time also wants to have a detailed explanation for a particular feature.
  • With this is mind Donโ€™t just jump on to your solution without asking him about the most important features which are a must have.
  • This round might be taken by your future manager or teammate or maybe by someone who is highly skilled in this design process, You start showering jargons and statements without proper reasoning and you could be done in 5-10 minutes ! Nobody wants such type of people in the team.
  • Understand the problem context first, for example if the interviewer adds a constraint or says that the database server is overloaded then you should not directly say lets switch to NoSQL DB or do Sharding, instead first understand what type of load is increasing, is it Read or write which is affecting, the strategies and solutions would be different as per the context.
  • Make clear and simple diagrams, a cylinder for a database and box for a server wonโ€™t give you extra points but it can create a nice ambience.

Databases and Scalability

The major pain point in internet scale systems is how you store and retrieve data. In a system design interview few basic Database scaling related questions you should be able to handle are following:

  1. Which type of database you would have for this system ? Relational or NoSQL?
  2. What are the pros and cons of Relational and NoSQL Databases, Why XX company still uses Relational Databases even at such large scale, how can they do it?
  3. Your Database server is overloaded, How would you scale it ?
  4. Caching, Replication and Sharding is done, still the load is high, what to do next ?
  5. How is indexing done ? What are different types of indexing strategies?
  6. Write a query for retrieving and displaying data. (For eg: Get profiles of the best players sorted by number of runs.)
  7. ACID vs BASE? What are the available tradeoffs, How do you decide which one to go for?

The above Questions are very direct, mind that in the interview you would not have such direct questions. Most probably, you will be having a vague system and you have to clarify the constraints, features, bottlenecks and possible solutions to those bottlenecks yourselves by having an effective and engaging communication with the interviewer just like a teammate.

All this probably sums up for databases section in a 45 minutes system design interview, however your interviwer might have a deep love for databases and then you could be shot with more detailed questions, however having a basic understanding of the above points can keep you in the safe zone.

Next articles in the series would be covering the details and specifics of each of the above questions, Till then, Have a good day and Keep Learning.

Ashish Kumar Singh , I am a Software Engineer, I ๐Ÿ˜ Code. [Twitter] [Linkedin]