NoSQL Flashcards

(18 cards)

1
Q

What are the fundamental differences between SQL and NoSQL?

A

SQL: Fixed schema, table-based, ACID compliance, vertical scaling
NoSQL: Flexible schema, various models (document/key-value/column/graph), eventual consistency, horizontal scaling
Key: SQL enforces structure upfront; NoSQL provides runtime flexibility

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does CAP theorem affect database choice?

A

SQL: Usually CA (Consistency + Availability), sacrificing partition tolerance
NoSQL: Often AP (Availability + Partition tolerance) or CP (Consistency + Partition tolerance)
Impact: SQL may go down during network issues; NoSQL stays up but may serve stale data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do data modeling approaches differ?

A

SQL: Normalized tables with foreign keys and JOINs
Document: Embedded JSON-like structures (MongoDB)
Key-Value: Simple key-based lookup (Redis, DynamoDB)
Column-Family: Wide rows, time-series friendly (Cassandra)
Graph: Nodes and relationships (Neo4j)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What consistency options exist?

A

SQL: Strong consistency (immediate across all nodes)
NoSQL:

Eventual consistency (will be consistent later)
Strong consistency (immediate but impacts availability)
Session consistency (consistent per user session)

Choose based on: Business needs for freshness vs availability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do scaling approaches differ?

A

SQL: Vertical scaling, read replicas, complex manual sharding
NoSQL: Horizontal scaling, automatic data distribution, linear growth
Performance: SQL optimized for complex queries; NoSQL for simple operations at scale
Sharding: Manual in SQL; automatic in most NoSQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Compare querying between SQL and NoSQL.

A

SQL: Standardized language, complex JOINs, subqueries, aggregations
NoSQL: Vendor-specific languages, limited JOINs, requires denormalization
Examples: SQL for complex reports; NoSQL for simple lookups and aggregations
Trade-off: SQL more expressive; NoSQL faster for targeted operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do schema changes work?

A

SQL: Requires DDL migrations, potential downtime, strong typing
NoSQL: Schema-on-read, no downtime for new fields, app-level validation
Development: NoSQL enables faster iteration; SQL provides stronger guarantees
Best Practice: Version your schemas in NoSQL applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What transaction support exists?

A

SQL: Full ACID across multiple tables, complex rollbacks
NoSQL:

Document: Single-document atomicity (MongoDB has limited multi-doc)
Key-Value: Atomic single-key operations
Column: Row-level atomicity
Graph: Full ACID (Neo4j)

Trend: More NoSQL systems adding ACID support

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When to use SQL vs NoSQL?

A

SQL: Complex business logic, financial systems, reporting, stable schemas
Document: Content management, user profiles, catalogs
Key-Value: Caching, sessions, real-time recommendations
Column: Time-series, IoT, logging
Graph: Social networks, recommendations, fraud detection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do operational aspects compare?

A

SQL: Mature tooling, established DBA practices, standardized procedures
NoSQL: Vendor-specific practices, automatic cluster management, different monitoring needs
Backup: SQL has point-in-time recovery; NoSQL uses distributed snapshots
Cloud: Managed services reduce complexity for both

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is data integrity handled?

A

SQL: Foreign keys, constraints, triggers, type enforcement
NoSQL: App-level validation, eventual consistency risks, optional schema validation
Risk: NoSQL denormalization can cause data anomalies
Best Practice: Comprehensive app-layer validation for NoSQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the cost implications?

A

SQL: Higher hardware costs, licensing fees, specialized expertise
NoSQL: Commodity hardware, often open-source, higher storage due to denormalization
Cloud: NoSQL pricing models often favor distributed workloads
Consider: Development velocity vs operational complexity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do security approaches differ?

A

SQL: Row/column-level permissions, mature RBAC, SQL injection risks
NoSQL: Document/collection-level security, app-level auth, NoSQL injection risks
Encryption: Both support at-rest and in-transit encryption
Best Practice: Defense-in-depth regardless of type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are key tuning differences?

A

SQL: Index optimization, query plans, partitioning, connection pooling
NoSQL: Data model optimization, shard key selection, consistency tuning
Monitoring: SQL focuses on queries; NoSQL on cluster health
Approach: SQL tunes queries; NoSQL tunes data distribution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to migrate between SQL and NoSQL?

A

SQL to NoSQL: Denormalize model, implement app-level joins, dual-write pattern
NoSQL to SQL: Normalize structures, extract relationships, add constraints
Pattern: Strangler Fig - gradually replace old system
Key: Maintain data consistency during transition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are SQL and NoSQL converging?

A

SQL Evolution: JSON columns, horizontal scaling solutions, cloud-native designs
NoSQL Evolution: ACID transactions, SQL-like queries, strong consistency options
NewSQL: Distributed SQL with horizontal scaling (CockroachDB, Spanner)
Multi-model: Single systems supporting multiple data models

17
Q

When should you choose SQL?

A
  • If you need ACID transactions, strict data consistency
  • Structured data whose schema won’t change much
  • Complex queries with joins
  • Mature tooling, predictable performance
  • Data integrity
18
Q

When should you choose NoSQL?

A
  • Unstructured data, flexible schema
  • Massive scale - horizontal scaling is easier
  • Fast lookups/writes
  • Fast development - schema can evolve rapidly