Database Internals Flashcards

(32 cards)

1
Q

What is ACID in databases?

A

ACID describes four guarantees that keep database transactions reliable: Atomicity Consistency Isolation and Durability.

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

What is Atomicity?

A

Atomicity means a transaction either completes fully or not at all. If any step fails the database rolls everything back so partial changes never exist.

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

What is Consistency in databases?

A

Consistency means the database always moves from one valid state to another and never violates its rules such as constraints or relationships.

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

What is Isolation?

A

Isolation ensures that transactions running at the same time do not interfere with each other and appear as if they ran separately.

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

What is Durability?

A

Durability means once a transaction is committed the data is permanently saved even if the system crashes.

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

What is BASE in distributed systems?

A

BASE stands for Basically Available Soft state Eventually consistent and is a model used by some distributed systems that trade strict consistency for scalability.

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

What is eventual consistency?

A

Eventual consistency means data may temporarily differ across nodes but will eventually become consistent once updates propagate.

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

What is a transaction?

A

A transaction is a sequence of database operations treated as a single unit of work that must either fully succeed or fail.

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

What is Write-Ahead Logging (WAL)?

A

Write-Ahead Logging records changes in a log before applying them to the database so the system can recover data after crashes.

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

Why do databases use Write-Ahead Logging?

A

Because if the system crashes the log can replay operations and restore the database to a consistent state.

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

What is MVCC?

A

MVCC stands for Multi Version Concurrency Control and allows multiple transactions to read and write data simultaneously without blocking each other.

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

How does MVCC improve performance?

A

Instead of locking rows it creates multiple versions of data so readers can access a stable snapshot while writers update newer versions.

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

What is a database lock?

A

A lock temporarily prevents other transactions from modifying certain data while a transaction is running.

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

What is a shared lock?

A

A shared lock allows multiple transactions to read the same data but prevents modifications.

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

What is an exclusive lock?

A

An exclusive lock prevents other transactions from reading or writing a row while it is being modified.

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

What are transaction isolation levels?

A

Isolation levels define how much transactions can see each other’s intermediate changes.

17
Q

What is Read Uncommitted isolation?

A

It allows transactions to see changes that other transactions have not yet committed which can lead to dirty reads.

18
Q

What is Read Committed isolation?

A

Transactions only see data that has been committed preventing dirty reads.

19
Q

What is Repeatable Read isolation?

A

Once a transaction reads a row it will always see the same value even if other transactions modify it later.

20
Q

What is Serializable isolation?

A

Serializable is the strictest level where transactions behave as if they ran one after another with no overlap.

21
Q

What is a dirty read?

A

A dirty read happens when a transaction reads data that another transaction has changed but not yet committed.

22
Q

What is a non repeatable read?

A

A non repeatable read occurs when a transaction reads the same row twice but gets different values because another transaction modified it.

23
Q

What is a phantom read?

A

A phantom read occurs when new rows appear in a query result because another transaction inserted data.

24
Q

What is a B-tree index?

A

A B-tree is a balanced tree structure used by databases to store indexes so searches can find values quickly without scanning entire tables.

25
Why are B-trees efficient for databases?
Because they keep data sorted and allow searches inserts and deletions in logarithmic time.
26
What is an LSM tree?
An LSM tree stores writes in fast memory structures and periodically merges them into larger sorted files making it efficient for write-heavy systems.
27
Where are LSM trees commonly used?
They are common in systems like Cassandra RocksDB and LevelDB where very high write throughput is required.
28
What is a buffer cache?
The buffer cache is memory where frequently accessed database pages are stored so they can be read quickly without disk access.
29
Why is disk access slow compared to memory?
Disk operations require physical or large storage access while memory access happens electronically and is thousands of times faster.
30
What is checkpointing in databases?
Checkpointing periodically writes in-memory changes to disk so recovery after crashes becomes faster.
31
What is replication in databases?
Replication copies data from one database server to others so systems remain available if one server fails.
32
What is sharding?
Sharding splits data across multiple database servers so the system can scale horizontally.