System Design

Hey! I'm Shreshtha ๐ A builder at heart, curious about how things work under the hood. I love solving problems and turning ideas into real tech โ from apps to APIs. This blog is where I share what I learn, what I break, and what I build โ in real-time. No gatekeeping, just a fellow dev figuring things out and documenting the journey.
1. What is the fundamental difference in data modeling between SQL and NoSQL databases?
SQL: Utilizes a relational data model with structured tables, rows, and columns. Relationships are established using foreign keys, and data integrity is maintained through constraints.โ
NoSQL: Employs various data models:โAlgoMaster+1GeeksforGeeks+1
Key-Value Stores (e.g., Redis): Simple key-value pairs.โ
Document Stores (e.g., MongoDB): JSON-like documents with flexible schemas.โGeeksforGeeks+1AlgoMaster+1
Column-Family Stores (e.g., Cassandra): Rows with dynamic columns.โAlgoMaster
Graph Databases (e.g., Neo4j): Nodes and edges representing entities and relationships.
2. How do SQL and NoSQL databases handle schemas?
SQL: Enforces a rigid, predefined schema. Altering the schema requires migrations, which can be complex and time-consuming.โ
NoSQL: Offers a flexible, dynamic schema. Different records can have varying structures, allowing for easier adaptation to changing data requirements.โ
3. What are the scalability characteristics of SQL vs. NoSQL databases?
SQL: Primarily scales vertically by enhancing the hardware of a single server (e.g., adding more RAM or CPU). This approach has limitations in handling massive workloads.
NoSQL: Designed for horizontal scalability, distributing data across multiple servers or nodes. This makes them well-suited for large-scale, high-traffic applications.
4. How do the query languages differ between SQL and NoSQL databases?
SQL: Uses Structured Query Language (SQL) for defining and manipulating data. It's standardized and powerful for complex queries involving joins and aggregations.โ
NoSQL: Lacks a universal query language. Each database has its own querying mechanism:โ
MongoDB: Uses a JSON-like query syntax.โ
Cassandra: Employs CQL (Cassandra Query Language), similar to SQL but with limitations.โ
Neo4j: Uses Cypher, a declarative graph query language.
5. What are the differences in transaction support between SQL and NoSQL databases?
SQL: Provides robust ACID (Atomicity, Consistency, Isolation, Durability) compliance, ensuring reliable and consistent transactions, which is critical for applications like banking systems.
NoSQL: Generally follows the BASE (Basically Available, Soft state, Eventually consistent) model. While some NoSQL databases offer limited transaction support, they often prioritize availability and partition tolerance over immediate consistency.โ
6. How does performance compare between SQL and NoSQL databases?
SQL: Excels in complex queries and transactions on structured data. Performance can degrade with massive datasets unless properly optimized.โ
NoSQL: Optimized for high-throughput and low-latency operations on large volumes of unstructured or semi-structured data. Ideal for real-time applications and big data analytics.โ
7. What are the typical use cases for SQL and NoSQL databases?
SQL: Suitable for applications requiring structured data, complex queries, and multi-row transactions. Common in finance, healthcare, and enterprise resource planning systems.โ
NoSQL: Ideal for applications needing flexible schemas, horizontal scalability, and rapid development. Common in social networks, IoT, content management, and real-time analytics.


