Skip to main content

Interview questions · Book 04

Databases interview questions

200 questions from 50 pages, each with a short answer. Say your answer first, then open the question to check it.

p. 1 · 4 questions

ACID

Full page
  1. 1

    What is ACID?

    ACID is a set of four guarantees, atomicity, consistency, isolation, and durability, that keep database transactions reliable even when errors or crashes occur.

  2. 2

    Are NoSQL databases ACID compliant?

    Some are. Many document and key-value databases now support ACID transactions, either within a single record or across several records with some limits, while others choose weaker guarantees for scale and speed. Check each database's documentation for exactly what it guarantees.

  3. 3

    What is the difference between ACID and BASE?

    ACID prioritizes correctness: every transaction is all-or-nothing and leaves the data immediately consistent. BASE, short for basically available, soft state, eventually consistent, prioritizes availability and allows copies of data to disagree briefly before they converge.

  4. 4

    What are transaction isolation levels?

    Isolation levels control how much concurrent transactions can see of each other's changes. The SQL standard defines four, from weakest to strongest: read uncommitted, read committed, repeatable read, and serializable. Stronger levels prevent more anomalies but can reduce throughput.

p. 2 · 4 questions

BASE

Full page
  1. 1

    What is BASE in databases?

    BASE describes distributed databases that favor availability over immediate consistency: they keep answering and let copies of data briefly disagree.

  2. 2

    What is the difference between ACID and BASE?

    ACID guarantees that every transaction is all-or-nothing and that reads see committed data right away. BASE gives up that immediate consistency so the system can stay available and scale across many servers, with replicas agreeing eventually.

  3. 3

    Is BASE the same as eventual consistency?

    Eventual consistency is one of its three parts. BASE is the broader description of a system that also stays basically available and tolerates soft, changing state while replicas catch up.

  4. 4

    Which databases follow BASE?

    Many NoSQL databases do by default, such as Apache Cassandra, Amazon DynamoDB and CouchDB, along with DNS and most caching layers. Most of them can also be configured for stronger consistency on specific requests.

p. 3 · 4 questions

CAP Theorem

Full page
  1. 1

    What is the CAP theorem?

    The CAP theorem says that if a network failure splits a distributed database, the system must choose between consistency and availability; it can't have both.

  2. 2

    Which is more important, consistency or availability?

    It depends on the data. Bank balances and inventory counts usually need consistency, while social feeds, view counts, and shopping carts can tolerate brief staleness in exchange for staying available.

  3. 3

    Does the CAP theorem apply to a single-server database?

    Not really. CAP applies to data replicated across multiple networked nodes; a single server has no partition between copies to worry about, although it can still simply go down.

  4. 4

    What is eventual consistency?

    Eventual consistency means that if no new updates are made, all copies of the data will eventually become identical. It is the typical guarantee of AP systems, which stay available during partitions and reconcile differences afterward.

p. 4 · 4 questions

Connection Pool

Full page
  1. 1

    What is a connection pool?

    A connection pool is a cache of open database connections that an application reuses across requests, avoiding the cost of opening a new connection every time.

  2. 2

    Why use a connection pool?

    Opening a new database connection for every request adds latency and puts extra load on the database. Reusing a small set of open connections makes queries start faster and keeps the number of connections under control.

  3. 3

    How big should a connection pool be?

    Usually smaller than people expect: start with a few connections per CPU core on the database server, then tune with load tests. Remember that the total across all application instances must stay below the database's connection limit.

  4. 4

    What happens when all connections in the pool are busy?

    New requests wait in a queue until a connection is returned. If none frees up before the configured timeout, the request fails with an error, which is often a sign of slow queries or a connection leak.

p. 5 · 4 questions

Data Lake

Full page
  1. 1

    What is a data lake?

    A data lake is a central storage repository that holds large amounts of raw data in its original format, structured or not, until someone needs to analyze it.

  2. 2

    What is the difference between a data lake and a data warehouse?

    A data lake stores raw data of any type cheaply and applies structure only when it is read. A data warehouse stores cleaned, structured data with a schema defined up front, which makes it faster and more reliable for business reporting.

  3. 3

    What is a data lakehouse?

    A lakehouse keeps data in open file formats on lake storage but adds a table layer with transactions, schemas, and fast SQL queries. It aims to give warehouse-style reliability without copying data into a separate warehouse.

  4. 4

    What is a data swamp?

    A data swamp is a data lake that has become disorganized, with undocumented, duplicated, or low-quality data that nobody can find or trust. Catalogs, ownership, and quality checks prevent it.

p. 6 · 4 questions

Data Warehouse

Full page
  1. 1

    What is a data warehouse?

    A data warehouse is a central database built for analytics that collects historical data from many sources so teams can run large reporting queries quickly.

  2. 2

    What is the difference between a data warehouse and a database?

    A data warehouse is a type of database, but it is designed for large analytical queries over historical data. A regular application database is designed for many small, fast reads and writes that keep an app running.

  3. 3

    What is the difference between a data warehouse and a data lake?

    A data lake stores raw data of any kind, such as logs, images, and JSON files, usually in cheap object storage. A data warehouse stores cleaned, structured data with a defined schema, so it is easier and faster to query.

  4. 4

    What is ETL?

    ETL stands for extract, transform, load: data is pulled from source systems, cleaned and reshaped, and then loaded into the warehouse. In ELT, the raw data is loaded first and transformed inside the warehouse.

p. 7 · 4 questions

Database

Full page
  1. 1

    What is a database?

    A database is an organized collection of data stored on a computer, managed by software that lets applications save, search, and update it efficiently.

  2. 2

    What is the difference between a database and a DBMS?

    The database is the organized data itself, while the DBMS (database management system) is the software, such as MySQL or PostgreSQL, that stores, queries, and protects that data.

  3. 3

    What is the difference between a database and a spreadsheet?

    A spreadsheet is designed for a person to view and calculate on a fairly small amount of data. A database is designed for applications and many users to store and query large amounts of data safely, with rules that keep the data consistent.

  4. 4

    What are the main types of databases?

    The two main families are relational (SQL) databases, which store data in tables, and NoSQL databases, which include document, key-value, wide-column, and graph databases.

p. 8 · 4 questions

Database Index

Full page
  1. 1

    What is a database index?

    A database index is a data structure that helps a database find rows quickly without scanning a whole table, much like the index at the back of a book.

  2. 2

    Why not index every column?

    Each index uses disk space and must be updated on every insert, update, and delete, so too many indexes slow down writes. Index the columns that your frequent queries filter, join, or sort on.

  3. 3

    What is the difference between a clustered and a non-clustered index?

    A clustered index determines the order in which the table's rows are physically stored, so a table can have only one. A non-clustered index is a separate structure that points to the rows, and a table can have many.

  4. 4

    What is a composite index?

    A composite index covers more than one column, such as (customer_id, created_at). It helps queries that filter on the first column, or on the first and second columns together, because the columns are sorted in that order.

More

Settings