SQL vs NoSQL Flashcards

(22 cards)

1
Q

What are the primary types of NoSQL dbs?

A
  1. Key value stores
  2. Document databases
  3. Wide-Columnar Databases
  4. Graph databases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an example of a NoSQL key-value store?

A

Dynamo & Redis

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

What is an example of a NoSQL Document DB?

A

MongoDB

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

What is an example of a NoSQL Wide Columnar DB?

A

Cassandra & HBase

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

What are use cases for a wide columnar database?

A

Log data
IoT (Internet of Things) sensor data
Time-series data, such as temperature monitoring or financial trading data
Attribute-based data, such as user preferences or equipment features
Real-time analytics

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

What is the difference between a row based DB vs a column based DB?

A

Columns are stored together on disk vs rows

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

What are columnar databases good for?

A

Columnar databases are great for data analytics. They scan fewer rows and process less data than row-oriented databases.

Because only the necessary columns are read from storage, I/O costs and time are minimized, providing an edge over traditional row-based databases in analytics scenarios.

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

What is an example of a NoSQL graph database and what’s a good use case?

A

Neo4J, movie recommendations

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

What is the difference in scalability between NoSQL vs SQL dbs?

A

SQL dbs are vertically scaleable, but horizontally scaling is very challenging. NoSQL dbs are horizontally scalable.

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

What is the different in data integreity guarantees between NoSQL and SQL?

A

Reliability or ACID Compliancy (Atomicity, Consistency, Isolation, Durability): The vast majority of relational databases are ACID compliant. So, when it comes to data reliability and safe guarantee of performing transactions, SQL databases are still the better bet.

Most of the NoSQL solutions sacrifice ACID compliance for performance and scalability.

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

What is atomicity?

A

Atomicity guarantees that each transaction is treated as a single “unit”, which either succeeds completely or fails completely

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

What is consistency?

A

Consistency ensures that a transaction can only bring the database from one consistent state to another, preserving database invariants:

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

What is isolation?

A

Isolation ensures that concurrent execution of transactions leaves the database in the same state that would have been obtained if the transactions were executed sequentially

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

What is durability?

A

Durability guarantees that once a transaction has been committed, it will remain committed even in the case of a system failure (e.g., power outage or crash)

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

Why use a relational DB?

A

We need to ensure ACID compliance and data is structured and unchanging (scaling not needed).

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

Why choose NoSQL db?

A

Storing large volumes of data that often have little to no structure.

Making the most of cloud computing and storage. Cloud-based storage is an excellent cost-saving solution but requires data to be easily spread across multiple servers to scale up.

Rapid development. NoSQL is extremely useful for rapid development as it doesn’t need to be prepped ahead of time

17
Q

Compare ACID vs BASE.

A

ACID prioritizes correctness (strong consistency, transactions).

BASE prioritizes availability and scale (eventual consistency, partition tolerance).

18
Q

What is BASE?

A

BASE (Basically Available, Soft state, Eventual consistency)

Used by large distributed NoSQL systems (Cassandra, DynamoDB, Riak).

BASE systems are usually AP under CAP (favor availability and partition tolerance over strong consistency).

19
Q

What is ACID?

A

ACID (Atomicity, Consistency, Isolation, Durability)

Used by traditional relational databases (PostgreSQL, MySQL, Oracle).

ACID systems typically choose CP in the CAP theorem (sacrifice availability during partitions to maintain consistency).

20
Q

When would you use BASE databases?

A

BASE (AP, eventually consistent) systems are ideal when you need:
High write throughput
* They accept writes even under node failures or partitions.
* No global locking or coordination slows them down.

High availability
* Writes must succeed even if some replicas are down.

Massive scale
* Partitioned/replicated horizontally with ease.
* Tolerance for temporary inconsistency
* Reads may return stale data for a short time.
* System is okay with eventual convergence.

In short: Write-heavy, latency-sensitive workloads fit BASE well.

21
Q

Use cases for ACID databases?

A

Bank accounts / ledgers
* Must never read an old balance or double-spend.

Payments
* Atomicity and correctness > availability.

Inventory with tight constraints
* Must prevent overselling limited stock (tickets, seats, etc.).

Booking systems
* Two people cannot book the same hotel room.

User identity & authentication data
* Must ensure unique usernames, consistent token state.

Critical configuration / metadata stores
* Raft-backed systems (etcd, ZooKeeper) ensure correctness.

22
Q

What ACID is necessary for real time banking?

A

Multi-item transactions with isolation:

ACID databases let you update multiple rows together atomically and prevent other operations from seeing partial results.

Strong consistency across partitions:

ACID systems give a single global order of all writes across all keys; BASE systems only guarantee ordering within a single key or partition.