TGViewer
Coding Interview Resources Coding Interview Resources @crackingthecodinginterview ยท 52.2K subscribers
Post #2980 1.22K
๐Ÿš€ Coding Interview Questions with Answers โ€” Part 8

๐Ÿ“‚ Databases & Backend Theory

๐Ÿš€ 71. What is the difference between SQL and NoSQL?

๐Ÿ”น SQL Databases
SQL databases are:
โ€ข Relational Databases
They store data in:
โ€ข Tables
โ€ข Rows
โ€ข Columns

Examples:
โ€ข MySQL
โ€ข PostgreSQL

๐Ÿ”น Features
โœ… Structured schema
โœ… ACID compliance
โœ… Strong consistency

๐Ÿ”น NoSQL Databases
NoSQL databases are:
โ€ข Non-relational Databases

Examples:
โ€ข MongoDB
โ€ข Cassandra

๐Ÿ”น Features
โœ… Flexible schema
โœ… Horizontal scalability
โœ… High availability

๐Ÿ”น Comparison

SQL
โ€ข Structured
โ€ข Tables
โ€ข Vertical scaling
โ€ข Complex joins

NoSQL
โ€ข Flexible
โ€ข Documents/Key-Value
โ€ข Horizontal scaling
โ€ข Fast distributed access

๐Ÿ”น Interview Tip
Use:
SQL โ†’ structured transactional systems
NoSQL โ†’ large-scale distributed systems

๐Ÿš€ 72. What is ACID and where is it important?
ACID properties ensure reliable database transactions.

๐Ÿ”น ACID Meaning

A
โ€ข Meaning: Atomicity

C
โ€ข Meaning: Consistency

I
โ€ข Meaning: Isolation

D
โ€ข Meaning: Durability

๐Ÿ”น Atomicity
All or nothing
If one step fails: Entire transaction rolls back

๐Ÿ”น Consistency
Database remains valid after transaction.

๐Ÿ”น Isolation
Concurrent transactions should not interfere.

๐Ÿ”น Durability
Committed data survives crashes.

๐Ÿ”น Important In
โœ… Banking systems
โœ… Payment systems
โœ… Order processing

๐Ÿ”น Interview Tip
ACID is heavily asked in backend interviews.

๐Ÿš€ 73. What is normalization and denormalization?

๐Ÿ”น Normalization
Organizing data to:
โ€ข Reduce redundancy
โ€ข Improve consistency

๐Ÿ”น Example
Instead of repeating user info: Store user once and reference with IDs.

๐Ÿ”น Benefits
โœ… Reduces duplication
โœ… Better integrity
โœ… Easier updates

๐Ÿ”น Denormalization
Adding redundancy intentionally for: Faster reads

๐Ÿ”น Benefits
โœ… Faster queries
โœ… Better performance

๐Ÿ”น Drawbacks
โŒ Data duplication
โŒ Update complexity

๐Ÿ”น Interview Tip
Normalized โ†’ OLTP systems
Denormalized โ†’ analytics/read-heavy systems

๐Ÿš€ 74. What is indexing and when is it useful?
Indexes improve query speed.

๐Ÿ”น Without Index
Database scans: Entire table

๐Ÿ”น With Index
Database directly jumps to rows.
Similar to: Book index

๐Ÿ”น SQL Example
CREATE INDEX idx_name
ON users(name);

๐Ÿ”น Benefits
โœ… Faster SELECT queries
โœ… Faster filtering
โœ… Faster joins

๐Ÿ”น Drawbacks
โŒ Extra storage
โŒ Slower inserts/updates

๐Ÿ”น Interview Tip
Indexes optimize reads but impact writes.

๐Ÿš€ 75. What is sharding vs replication?

๐Ÿ”น Replication
Copy same database across multiple servers.

๐Ÿ”น Goal
โœ… High availability
โœ… Backup
โœ… Read scaling

๐Ÿ”น Example
Primary โ†’ Replica Servers

๐Ÿ”น Sharding
Split database into parts.
Each shard stores: Different subset of data

๐Ÿ”น Example

Shard 1
โ€ข Data: Users A-M

Shard 2
โ€ข Data: Users N-Z

๐Ÿ”น Comparison

Replication
โ€ข Copies same data
โ€ข Improves availability

Sharding
โ€ข Splits data
โ€ข Improves scalability

๐Ÿ”น Interview Tip
Large-scale systems often use both.

๐Ÿš€ 76. What is the difference between strong and eventual consistency?

๐Ÿ”น Strong Consistency
Every read gets: Latest data immediately

๐Ÿ”น Example
Banking systems.

๐Ÿ”น Eventual Consistency
Updates propagate gradually.
Eventually: All nodes become consistent

๐Ÿ”น Example
Social media likes/views.

๐Ÿ”น Comparison

Strong
โ€ข Immediate accuracy
โ€ข Slower

Eventual
โ€ข Temporary inconsistency
โ€ข Faster/scalable

๐Ÿ”น Interview Tip
Distributed systems often trade consistency for scalability.

๐Ÿš€ 77. What is a transaction and when do you roll it back?
Transaction: Group of operations executed together

๐Ÿ”น Example
Bank transfer:
1. Debit sender
2. Credit receiver

Both must succeed.

๐Ÿ”น Rollback Happens When
โœ… Error occurs
โœ… Constraint fails
โœ… System crash
โœ… Validation failure
  • โค 1
More from @crackingthecodinginterview
  1. Oct 7, 2026๐Ÿš€ DSA Topics Every Programmer Should Know ๐Ÿ’ป๐Ÿ”ฅ ๐Ÿ“ฆ 1. Arrays โœ” Traversal โœ” Searching โœ” Sorโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  4. Sep 29, 2026โœ… Daily Coding Habits That Make You a Better Developer ๐Ÿง ๐Ÿ’ปโœจ 1๏ธโƒฃ Code Every Day (Even 30 Mโ€ฆ
  5. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
  6. Sep 28, 2026Hereโ€™s a DSA problem-solving cheat sheet that will help you solve 90โ€“95% of questions thatโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’