0% found this document useful (0 votes)
12 views2 pages

SQL Vs NoSQL Interview Answers

Uploaded by

kumaranuj98208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

SQL Vs NoSQL Interview Answers

Uploaded by

kumaranuj98208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL vs NoSQL Interview Answers

Main difference
SQL = Relational, structured. NoSQL = Non-relational, flexible.

Schema
SQL = Fixed schema. NoSQL = Dynamic schema.

Query Language
SQL = Structured Query Language. NoSQL = Varies by DB.

Scalability
SQL = Vertical (scale up). NoSQL = Horizontal (scale out).

Transactions
SQL = ACID (strong consistency). NoSQL = BASE (eventual consistency).

Use Cases
SQL = Banking, ERP, structured data. NoSQL = Big data, IoT, social media.

Examples
SQL = MySQL, PostgreSQL, Oracle. NoSQL = MongoDB, Redis, Cassandra, Neo4j.

Flexibility
SQL = Less flexible, strong rules. NoSQL = Very flexible, schema-free.

Performance
SQL can slow under high traffic, NoSQL scales better with distributed data.

Together Usage
Many modern apps use SQL for transactions + NoSQL for scalability.

ACID vs BASE
ACID (SQL): Atomicity, Consistency, Isolation, Durability. Ensures reliable transactions.
Example: In banking, transferring money must debit one account and credit another together.

BASE (NoSQL): Basically Available, Soft state, Eventual consistency. Focuses on scalability and
availability.
Example: On social media, a comment might not appear instantly everywhere but syncs eventually.

Isolation Example
Without Isolation: Two transfers read the same balance (■5000), update separately, final balance
becomes wrong (■2000).
With Isolation: One transaction completes first, then the second runs on the updated balance, final
balance = ■0 (correct).

SQL vs NoSQL for Analytics


SQL is better for structured analytics (sales reports, finance).
NoSQL is better for big/unstructured data (logs, reviews, IoT).
Example: E-commerce uses SQL for sales reports, NoSQL for customer reviews and clickstream
analysis.

Performance in High Traffic


SQL: Can slow down under heavy load due to ACID constraints, scales vertically.
NoSQL: Scales horizontally, performs better for massive traffic.
Example: Banking (SQL, reliable), Social Media (NoSQL, scalable).

Types of NoSQL Databases


1. Document-based (MongoDB)
2. Key-Value (Redis, DynamoDB)
3. Column-family (Cassandra, HBase)
4. Graph (Neo4j)

Using SQL and NoSQL Together


Many projects use both (Polyglot Persistence).
Example: E-commerce → SQL for orders/payments (structured), NoSQL for reviews/clickstreams
(unstructured).

You might also like