What is ACID in databases?
ACID describes four guarantees that keep database transactions reliable: Atomicity Consistency Isolation and Durability.
What is Atomicity?
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.
What is Consistency in databases?
Consistency means the database always moves from one valid state to another and never violates its rules such as constraints or relationships.
What is Isolation?
Isolation ensures that transactions running at the same time do not interfere with each other and appear as if they ran separately.
What is Durability?
Durability means once a transaction is committed the data is permanently saved even if the system crashes.
What is BASE in distributed systems?
BASE stands for Basically Available Soft state Eventually consistent and is a model used by some distributed systems that trade strict consistency for scalability.
What is eventual consistency?
Eventual consistency means data may temporarily differ across nodes but will eventually become consistent once updates propagate.
What is a transaction?
A transaction is a sequence of database operations treated as a single unit of work that must either fully succeed or fail.
What is Write-Ahead Logging (WAL)?
Write-Ahead Logging records changes in a log before applying them to the database so the system can recover data after crashes.
Why do databases use Write-Ahead Logging?
Because if the system crashes the log can replay operations and restore the database to a consistent state.
What is MVCC?
MVCC stands for Multi Version Concurrency Control and allows multiple transactions to read and write data simultaneously without blocking each other.
How does MVCC improve performance?
Instead of locking rows it creates multiple versions of data so readers can access a stable snapshot while writers update newer versions.
What is a database lock?
A lock temporarily prevents other transactions from modifying certain data while a transaction is running.
What is a shared lock?
A shared lock allows multiple transactions to read the same data but prevents modifications.
What is an exclusive lock?
An exclusive lock prevents other transactions from reading or writing a row while it is being modified.
What are transaction isolation levels?
Isolation levels define how much transactions can see each other’s intermediate changes.
What is Read Uncommitted isolation?
It allows transactions to see changes that other transactions have not yet committed which can lead to dirty reads.
What is Read Committed isolation?
Transactions only see data that has been committed preventing dirty reads.
What is Repeatable Read isolation?
Once a transaction reads a row it will always see the same value even if other transactions modify it later.
What is Serializable isolation?
Serializable is the strictest level where transactions behave as if they ran one after another with no overlap.
What is a dirty read?
A dirty read happens when a transaction reads data that another transaction has changed but not yet committed.
What is a non repeatable read?
A non repeatable read occurs when a transaction reads the same row twice but gets different values because another transaction modified it.
What is a phantom read?
A phantom read occurs when new rows appear in a query result because another transaction inserted data.
What is a B-tree index?
A B-tree is a balanced tree structure used by databases to store indexes so searches can find values quickly without scanning entire tables.