Skip to content
Interview questions

DBMS interview questions

Practise explaining databases and SQL clearly, like you would in a real interview.

Categories

Showing 60 of 60

Mode

01

DBMS foundations and architecture

What is a DBMS, and why do applications use one?

02

DBMS foundations and architecture

How is a DBMS better than storing data directly in files?

03

DBMS foundations and architecture

What is the difference between a database schema and a database instance?

04

DBMS foundations and architecture

What does the three-schema architecture try to achieve?

05

DBMS foundations and architecture

What makes a relational DBMS different from a general DBMS?

06

Relational model, keys and constraints

What do relation, tuple, attribute, and domain mean in the relational model?

07

Relational model, keys and constraints

How do a super key, candidate key, and primary key differ?

08

Relational model, keys and constraints

What is the difference between a primary key and a UNIQUE constraint?

09

Relational model, keys and constraints

What does a foreign key guarantee?

10

Relational model, keys and constraints

Why should important validation also exist as database constraints?

11

Relational model, keys and constraints

Why can NULL produce unexpected SQL results?

12

ER modelling and schema design

What are entities, attributes, and relationships in an ER model?

13

ER modelling and schema design

What is the difference between cardinality and participation?

14

ER modelling and schema design

What is a weak entity, and how would you model it?

15

ER modelling and schema design

How do you represent a many-to-many relationship in a relational database?

16

ER modelling and schema design

When would you choose a surrogate key over a natural key?

17

SQL filtering, grouping and aggregation

What is the difference between WHERE and HAVING?

18

SQL filtering, grouping and aggregation

What rule do you follow when writing a GROUP BY query?

19

SQL filtering, grouping and aggregation

How do COUNT(*) and COUNT(column) differ?

20

SQL filtering, grouping and aggregation

How would you find duplicate email addresses in a users table?

21

SQL filtering, grouping and aggregation

How would you find the second-highest distinct salary?

22

SQL filtering, grouping and aggregation

How would you count completed and pending orders in one query?

23

SQL filtering, grouping and aggregation

What is the difference between DELETE, TRUNCATE, and DROP?

24

Joins, subqueries, views and CTEs

How do INNER, LEFT, RIGHT, and FULL joins differ?

25

Joins, subqueries, views and CTEs

Why can moving a condition from ON to WHERE change a LEFT JOIN result?

26

Joins, subqueries, views and CTEs

How would you show each employee with their manager's name?

27

Joins, subqueries, views and CTEs

What is a correlated subquery?

28

Joins, subqueries, views and CTEs

When would you use EXISTS instead of IN?

29

Joins, subqueries, views and CTEs

How would you find customers who have never placed an order?

30

Joins, subqueries, views and CTEs

How would you find employees earning above their department average?

31

Joins, subqueries, views and CTEs

How do a CTE, a view, and a materialized view differ?

32

Functional dependencies and normalization

What is a functional dependency?

33

Functional dependencies and normalization

What problems does normalization try to prevent?

34

Functional dependencies and normalization

What does First Normal Form require?

35

Functional dependencies and normalization

When does a table violate Second Normal Form?

36

Functional dependencies and normalization

How would you explain the difference between 3NF and BCNF?

37

Functional dependencies and normalization

What do lossless join and dependency preservation mean?

38

Functional dependencies and normalization

When would you intentionally denormalize a schema?

39

Transactions, ACID and isolation levels

What is a database transaction?

40

Transactions, ACID and isolation levels

Can you explain the ACID properties with practical meaning?

41

Transactions, ACID and isolation levels

What is the difference between atomicity and durability?

42

Transactions, ACID and isolation levels

What are dirty reads, non-repeatable reads, and phantom reads?

43

Transactions, ACID and isolation levels

How do you choose a transaction isolation level?

44

Transactions, ACID and isolation levels

What is MVCC, and does it remove the need for locks?

45

Transactions, ACID and isolation levels

How do you decide where a transaction should begin and end?

46

Concurrency, locking and deadlocks

What is the difference between shared and exclusive locks?

47

Concurrency, locking and deadlocks

What is two-phase locking, and what does strict 2PL add?

48

Concurrency, locking and deadlocks

How does a database deadlock happen, and how should an application handle it?

49

Concurrency, locking and deadlocks

When would you use optimistic versus pessimistic locking?

50

Concurrency, locking and deadlocks

How would you prevent two requests from overwriting each other's update?

51

Indexing, storage and query optimization

What is an index, and why not index every column?

52

Indexing, storage and query optimization

When is a B-tree index more useful than a hash index?

53

Indexing, storage and query optimization

What is the difference between clustered and nonclustered indexes?

54

Indexing, storage and query optimization

Why does column order matter in a composite index?

55

Indexing, storage and query optimization

Why might the optimizer ignore an available index?

56

Indexing, storage and query optimization

How do you use an execution plan to improve a query?

57

Recovery and practical scenarios

A query became slow in production. How would you investigate it?

58

Recovery and practical scenarios

An order was created but inventory was not reserved. How would you prevent that state?

59

Recovery and practical scenarios

How do write-ahead logging and checkpoints help crash recovery?

60

Recovery and practical scenarios

How would you paginate a very large, frequently changing table?