

Day 02/30 of System Design 🚀 How to pick the right DB? 🧐 One of the most interesting problems while designing a system is figuring out which database to pick. First of all let's start by busting a common myth: Relational Databases do not scale. And to understand why this is a myth, let’s look at why NoSQL DBs scale so well: 1️⃣ No relations & constraints: They don't have to constantly validate complex connections. 2️⃣ Built for sharding: Data is modeled natively to be split across multiple nodes. And if we relax those exact same rules on a Relational DB, we can make it scale too! 👉 Do not use foreign key checks 👉 Do not use cross-shard transactions 👉 Implement manual sharding How does this help in designing a system? Never jump straight to a particular DB. Instead, pause and understand: 1) What data you are storing. 2) How much data you are storing. 3) How you will be accessing the database. 4) What kind of queries you will be firing. 5) Any special features you expect (e.g., Expiration). Consider following to pick the db [A] If data CAN fit on a single node: - Need strong consistency & data correctness? ➡️ Go for a Relational Database - Need to run complex queries? ➡️ Go for a Relational Database - Need fast key-value access? ➡️ Go for Redis - Need advanced data structures? ➡️ Go for Redis [B] If data CANNOT fit on a single node - Have expertise in SQL & can handle manual sharding? ➡️ Drop constraints & go for a Relational DB - Simple key-value based access? ➡️ Go for a Key-Value store (like DynamoDB, MongoDB, etc.) - Need sophisticated graph algorithms? ➡️ Go for a Graph DB (like Neo4j) - Have nothing specific, but want to futureproof? ➡️ Go for a Document DB (like MongoDB) What’s your go-to database choice when you're starting a new project from scratch? 👇 #systemdesign














