Skip to content
Home/Resources/Software Development/DBMS interview questions
Interview prep ยท Software Development

DBMS Interview Questions and Answers for Freshers: 32 Model Answers

Younus FardeenBy Younus FardeenUpdated 1 Dec 202611 min read
Short answer

DBMS interviews test the relational model, keys, normalization up to BCNF, ACID transactions and isolation levels, indexing, joins, SQL versus NoSQL and deadlocks. These 32 answers are two to four sentences each, grouped by topic, with one runnable SQLite script that proves the joins, NULL, foreign key, rollback and index claims.

On this pageCore concepts (Q1 to Q8)Keys and constraints (Q9 to Q14)Normalization (Q15 to Q20)Transactions, ACID and concurrency (Q21 to Q27)Joins, indexing and SQL versus NoSQL (Q28 to Q32)How to use this listFrequently asked questions

For B.Tech, BCA and MCA students preparing for campus placements and fresher interviews, where DBMS is a standard theory round next to SQL. Every answer is short enough to say aloud in under a minute. The SQLite script in the first section was run on Python 3.9.6 and the output quoted is what it printed. Engine-specific behaviour is kept to the PostgreSQL manual, which we opened on 1 December 2026.

Trends India shows interview-question searches for Java, Python, SQL, React and Node peaking from January to March, and those pages rank among the hub's recurring winners. The Search Console export of 26 November 2026 has no direct row for this page, so the "most asked" picks below are our reading, not data. Pair this with SQL interview questions for query practice.

Core concepts (Q1 to Q8)

  • Q1. What is a DBMS, and how is it better than a file system? A DBMS is software that stores, queries and protects data for many users. Compared with plain files it adds a query language, constraints, concurrent access, crash recovery and access control, and it reduces duplicated data.
  • Q2. What is the difference between DBMS and RDBMS? An RDBMS is a DBMS built on the relational model: data in tables of rows and columns, linked by keys and queried with SQL. MySQL, PostgreSQL and SQLite are relational. Older hierarchical and network systems are DBMSs but not relational.
  • Q3. What are the three levels of data abstraction? Physical (how bytes are stored), logical (tables, columns, relationships) and view (what a given user sees). Changing storage without touching the logical level is physical data independence.
  • Q4. DDL, DML, DCL and TCL: what are they? DDL defines structure (CREATE, ALTER, DROP), DML changes data (INSERT, UPDATE, DELETE), DCL controls access (GRANT, REVOKE) and TCL controls transactions (COMMIT, ROLLBACK). SELECT is often listed as DQL.
  • Q5. What is a schema versus an instance? The schema is the design of the database: table names, columns, types and constraints. The instance is the data held at one moment. The schema changes rarely, the instance changes constantly.
  • Q6. What is an ER diagram? It models entities (things), attributes (their properties) and relationships (one-to-one, one-to-many, many-to-many) before any table exists. A many-to-many relationship becomes a separate junction table with two foreign keys.
  • Q7. What is a view, and what is a materialized view? A view is a saved query that behaves like a table and stores no data. A materialized view stores the result and must be refreshed, trading freshness for speed. Support differs by engine, so name the one you used.
  • Q8. What is NULL? NULL means unknown or missing, not zero or empty text. Any comparison with NULL is unknown, so = NULL matches nothing and you must write IS NULL. Aggregates such as SUM and AVG skip NULLs.

The script below builds a three-table practice database in memory and checks the NULL, join, foreign key, rollback and index claims that appear in the answers.

import sqlite3
c = sqlite3.connect(":memory:", isolation_level=None)
c.executescript("""
CREATE TABLE dept (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE emp (id INTEGER PRIMARY KEY, name TEXT, dept_id INTEGER REFERENCES dept(id), salary INTEGER);
INSERT INTO dept VALUES (1,'Sales'),(2,'Tech'),(3,'Legal');
INSERT INTO emp VALUES (1,'Asha',1,50000),(2,'Ravi',2,90000),(3,'Meera',2,80000),(4,'Imran',NULL,60000);
""")
q = lambda s: c.execute(s).fetchall()
print("inner", len(q("SELECT * FROM emp e JOIN dept d ON e.dept_id=d.id")))
print("left", len(q("SELECT * FROM emp e LEFT JOIN dept d ON e.dept_id=d.id")))
print("no match", q("SELECT d.name FROM dept d LEFT JOIN emp e ON e.dept_id=d.id WHERE e.id IS NULL"))
print("= NULL", len(q("SELECT * FROM emp WHERE dept_id = NULL")), "IS NULL", len(q("SELECT * FROM emp WHERE dept_id IS NULL")))
print("2nd highest", q("SELECT MAX(salary) FROM emp WHERE salary < (SELECT MAX(salary) FROM emp)"))
print("dept avg", q("SELECT d.name, AVG(salary) FROM emp e JOIN dept d ON e.dept_id=d.id GROUP BY d.name HAVING AVG(salary) > 60000"))
try:
    c.execute("PRAGMA foreign_keys=ON"); c.execute("INSERT INTO emp VALUES (9,'X',99,1)")
except sqlite3.IntegrityError as e: print("FK blocked:", e)
c.execute("BEGIN"); c.execute("UPDATE emp SET salary=0"); c.execute("ROLLBACK")
print("after rollback", q("SELECT SUM(salary) FROM emp"))
print(q("EXPLAIN QUERY PLAN SELECT * FROM emp WHERE salary=1")[0][3])
c.execute("CREATE INDEX ix_sal ON emp(salary)")
print(q("EXPLAIN QUERY PLAN SELECT * FROM emp WHERE salary=1")[0][3])

Output:

inner 3
left 4
no match [('Legal',)]
= NULL 0 IS NULL 1
2nd highest [(80000,)]
dept avg [('Tech', 85000.0)]
FK blocked: FOREIGN KEY constraint failed
after rollback [(280000,)]
SCAN emp
SEARCH emp USING INDEX ix_sal (salary=?)

Keys and constraints (Q9 to Q14)

KeyUniqueNULL allowedHow many per table
Super keyYesDependsAny set of columns that is unique
Candidate keyYes, minimalNo (as a key)One or more
Primary keyYesNoExactly one
Unique keyYesUsually yesMany
Foreign keyNoYesMany
  • Q9. Super key, candidate key and primary key: how do they relate? A super key is any column set that identifies a row. A candidate key is a super key with no spare column. The primary key is the candidate key you pick.
  • Q10. What is a foreign key, and what is referential integrity? A foreign key points at a key in another table. Referential integrity means no row can reference a parent that does not exist. In the script, inserting an employee with department 99 failed with a foreign key error. SQLite enforces this only after PRAGMA foreign_keys=ON.
  • Q11. What are ON DELETE CASCADE and ON DELETE SET NULL? They decide what happens to child rows when the parent is deleted. CASCADE deletes them too, SET NULL clears the foreign key and the default blocks the delete.
  • Q12. What is a composite key? A key made of two or more columns, common in junction tables such as (student_id, course_id). Neither column is unique alone but the pair is.
  • Q13. Primary key versus unique key? A table has one primary key, which identifies rows. It can have many unique constraints, and most engines let a unique column hold NULL. Treat NULL handling in unique columns as engine-specific.
  • Q14. Natural key or surrogate key? A natural key is real data such as an email. A surrogate key is a meaningless generated number. Surrogates stay stable when real-world data changes, which is why most designs use them as primary keys.

Normalization (Q15 to Q20)

Normalization removes redundancy by splitting tables so each fact is stored once. The full walkthrough is in normalization in DBMS explained. These are the questions interviewers ask about it.

FormRule in one lineAnomaly it removes
1NFOne value per cell, no repeating groupsMulti-valued fields you cannot query
2NF1NF and no partial dependency on part of a composite keyUpdate anomaly on partial keys
3NF2NF and no non-key column depends on another non-key columnTransitive dependency
BCNFEvery determinant is a candidate keyLeftover 3NF anomalies
  • Q15. Why normalize? To avoid insert, update and delete anomalies. If a customer's city is repeated on every order row, changing it means editing many rows, and missing one leaves the data inconsistent.
  • Q16. What is a functional dependency? A -> B means a value of A determines exactly one value of B, as emp_id -> name. All normal forms are defined with dependencies.
  • Q17. Explain 1NF, 2NF and 3NF with one example. A table orders(order_id, product_id, product_name, qty) has key (order_id, product_id). product_name depends on product_id alone, a partial dependency, so 2NF moves it to a products table. If products also held supplier_city that depends on supplier, 3NF moves that out.
  • Q18. What is BCNF, and how is it different from 3NF? BCNF is stricter: for every dependency X -> Y, X must be a candidate key. 3NF allows a few exceptions when Y is part of a key. The difference only shows up with overlapping candidate keys.
  • Q19. What is denormalization, and when would you use it? Adding redundancy on purpose to avoid costly joins, usually in reporting tables or read-heavy systems. You pay with extra storage and the job of keeping copies in sync.
  • Q20. Is normalization always good? No. Past 3NF the gains are small and queries need more joins. Most transactional designs stop at 3NF or BCNF and denormalize only where a measured query is slow.

Transactions, ACID and concurrency (Q21 to Q27)

The detailed version is in ACID properties in DBMS explained. Interviewers usually want a definition, a bank-transfer example and the isolation anomalies.

Isolation levelDirty readNon-repeatable readPhantom read
READ UNCOMMITTEDPossiblePossiblePossible
READ COMMITTEDNoPossiblePossible
REPEATABLE READNoNoPossible in the SQL standard
SERIALIZABLENoNoNo
  • Q21. What is a transaction? A group of statements treated as one unit: all take effect on COMMIT or none do on ROLLBACK. In the script, setting every salary to 0 and rolling back left the total at 280,000.
  • Q22. Explain ACID. Atomicity: all or nothing. Consistency: constraints hold before and after. Isolation: concurrent transactions do not see each other's half-done work. Durability: committed data survives a crash, usually through a write-ahead log.
  • Q23. Give a bank-transfer example. Moving 500 from A to B needs a debit and a credit. If the system fails between them, atomicity rolls the debit back. Without isolation, a second transfer could read A's balance mid-way and overdraw it.
  • Q24. What are dirty, non-repeatable and phantom reads? A dirty read sees uncommitted data. A non-repeatable read gets a different value for the same row on a second read. A phantom read gets a different set of rows for the same condition. The table above shows which level allows which.
  • Q25. What is the default isolation level? It depends on the engine. PostgreSQL's manual says its default is READ COMMITTED, and that its REPEATABLE READ also prevents phantoms. Do not quote one default as universal.
  • Q26. What is a deadlock, and how is it handled? Two transactions each hold a lock the other needs, so neither can proceed. Databases detect the cycle and abort one transaction, and your code retries. Taking locks in a consistent order and keeping transactions short prevents most deadlocks. The operating-system version is in deadlock in operating system explained.
  • Q27. Pessimistic or optimistic locking? Pessimistic locking locks rows before editing and blocks others, which suits high contention. Optimistic locking lets everyone read, then checks a version number at write time and retries on conflict, which suits low contention.

Joins, indexing and SQL versus NoSQL (Q28 to Q32)

  • Q28. What are the join types? INNER keeps matching rows only. LEFT keeps every left row and fills NULL where nothing matches. RIGHT mirrors it and FULL keeps both sides. In the script, employees to departments gave 3 rows inner and 4 left, and Legal had no employee. See SQL joins explained with examples.
  • Q29. What is an index, and what does it cost? A sorted structure, usually a B-tree, that finds rows without scanning the table. It speeds reads but takes space and slows writes. In the script, the plan changed from SCAN emp to SEARCH emp USING INDEX. More in indexing in databases explained.
  • Q30. Clustered versus non-clustered index? A clustered index decides the physical order of the rows, so a table has one. A non-clustered index is a separate structure pointing to the rows, so a table can have many. Engines implement this differently, so state which one you mean.
  • Q31. SQL or NoSQL? Choose relational when data is structured, relationships matter and you need transactions. NoSQL families (document, key-value, column, graph) fit flexible schemas or very large scale on a simple access pattern. Many products use both.
  • Q32. What is the CAP theorem? A distributed store facing a network partition must choose between consistency (every read sees the latest write) and availability (every request gets an answer). It does not say you can have only two of three at all times.

How to use this list

  1. Learn the table of isolation levels and the normal forms table by heart: both are asked in written tests.
  2. For each answer, prepare one example from a mini-project. A library or hostel database with three tables is enough. See backend project ideas.
  3. Practise four queries aloud: second-highest salary, duplicates, a join with no match and a GROUP BY with HAVING. The script above covers three of them.
  4. Revise by topic: normalization and ACID are the two where interviewers ask follow-ups, so read the two linked explainers last.

Next, move to query practice with SQL interview questions and then operating system interview questions, the other theory subject placement rounds usually pair with DBMS.

Frequently asked questions

What are the most asked DBMS interview questions?

No company publishes its question bank, so this is our reading. Expect normalization with an example, ACID with a bank transfer, primary versus foreign key, the join types, indexing and deadlock. Questions 15 to 18, 22, 24, 28 and 29 above are the ones to master first.

How do I prepare DBMS for a fresher interview?

Learn the keys table, the normal forms and the isolation levels, then write ten queries on a small schema yourself. Pair each theory answer with an example from a project. A week of daily one-hour revision covers the topics on this page.

What is the difference between DBMS and SQL?

A DBMS is the software that stores and manages data. SQL is the language you use to talk to a relational DBMS. MySQL is a DBMS, and the commands you type into it are SQL. The hub's SQL vs MySQL page covers the comparison in more detail.

Is normalization asked in every DBMS interview?

It is among the most common topics in fresher rounds, usually as 'explain 1NF, 2NF and 3NF with an example'. Know the rule, the anomaly it removes and one small table you can split on a whiteboard.

Do I need to know NoSQL for a fresher DBMS interview?

Know the four families (document, key-value, column, graph), one example of each and when you would pick NoSQL over relational. Deep tuning is not expected from freshers, but a clear SQL versus NoSQL answer is.

Should I learn DBMS or SQL first?

Learn SQL basics first because you can see results, then read the theory (keys, normalization, transactions) with queries to test it. The theory answers stick better when you have already written a join and a transaction.

Learn this with mentors

Programmes for builders and engineers with admissions open: live classes, mentors and project work.

Continue learning

Interview prep

SQL interview questions

40 questions, one practice schema, every result run on SQLite

11 min read
Concept

Normalization in DBMS

One messy table taken to 3NF and BCNF, with executed SQL and real anomalies

8 min read
Concept

ACID properties in DBMS

ACID and isolation levels shown with real rollback, crash and lock output

8 min read