Top 40 DBMS Interview Questions and Answers for Freshers (2026)

DBMS is asked in almost every fresher interview, from service companies to product companies. The good news: the same 40 to 50 questions repeat. Learn these, and practise the 5 SQL queries at the end.
Basics
1. What is a DBMS?
Software that stores, manages and retrieves data in an organised way. Examples: MySQL, PostgreSQL, Oracle, SQL Server.
2. DBMS vs file system?
A DBMS gives less redundancy, data consistency, security, concurrent access, backup and recovery. A file system gives none of these by itself.
3. What is an RDBMS?
A DBMS that stores data in tables (relations) with rows and columns and links tables using keys.
4. What are the three levels of data abstraction?
Physical (how data is stored), logical (what data is stored and how it is related) and view (what a user sees).
5. What is data independence?
Changing the schema at one level without changing the level above it. Physical data independence is easier to get than logical.
6. What is a schema and an instance?
The schema is the structure of the database (design). An instance is the data in it at a given moment.
Keys
7. What is a primary key?
A column (or set of columns) that uniquely identifies each row. It cannot be NULL and there is only one per table.
8. Candidate key vs super key?
A super key is any set of columns that uniquely identifies a row. A candidate key is a minimal super key. The primary key is chosen from the candidate keys.
9. What is a foreign key?
A column that refers to the primary key of another table and keeps referential integrity.
10. What is a composite key?
A primary key made of two or more columns.
11. Primary key vs unique key?
Both are unique. A primary key cannot be NULL and there is one per table; a unique key allows one NULL (in most databases) and there can be many.
ER model
12. What is an ER diagram?
A diagram showing entities, attributes and relationships. It is used to design the database before creating tables.
13. What is a weak entity?
An entity that cannot be identified by its own attributes and depends on a strong entity, such as Dependent depending on Employee.
14. What are the types of relationships?
One-to-one, one-to-many and many-to-many.
Normalization
15. What is normalization?
Organising tables to reduce redundancy and avoid insert, update and delete anomalies.
16. Explain 1NF, 2NF, 3NF and BCNF.
- 1NF: every column holds atomic (single) values.
- 2NF: 1NF plus no partial dependency (no non-key column depends on part of a composite key).
- 3NF: 2NF plus no transitive dependency (non-key columns depend only on the key).
- BCNF: for every functional dependency X -> Y, X must be a super key.
17. What is a functional dependency?
X -> Y means the value of X decides the value of Y, for example RollNo -> Name.
18. What is denormalization?
Adding some redundancy on purpose to make read queries faster, often used in reporting systems.
SQL
19. DDL, DML, DCL and TCL?
DDL: CREATE, ALTER, DROP, TRUNCATE. DML: SELECT, INSERT, UPDATE, DELETE. DCL: GRANT, REVOKE. TCL: COMMIT, ROLLBACK, SAVEPOINT.
20. DELETE vs TRUNCATE vs DROP?
| DELETE | TRUNCATE | DROP |
|---|---|---|
| Removes chosen rows (WHERE allowed) | Removes all rows | Removes the whole table |
| Can be rolled back | Usually cannot be rolled back | Cannot be rolled back |
| Slower | Faster | Table structure is gone |
21. WHERE vs HAVING?
WHERE filters rows before grouping; HAVING filters groups after GROUP BY.
22. What are joins?
- Inner join: only matching rows from both tables.
- Left join: all rows from the left table plus matches.
- Right join: all rows from the right table plus matches.
- Full join: all rows from both tables.
- Self join: a table joined with itself.
23. UNION vs UNION ALL?
UNION removes duplicates; UNION ALL keeps them and is faster.
24. What is a view?
A virtual table based on a query. It stores no data itself and is used for security and simpler queries.
25. What is a subquery?
A query inside another query. A correlated subquery uses values from the outer query and runs once per row.
26. What is an index?
A data structure (usually a B+ tree) that speeds up searches on a column, at the cost of extra storage and slower inserts.
27. Clustered vs non-clustered index?
A clustered index decides the physical order of rows; only one per table. A non-clustered index is a separate structure pointing to rows; there can be many.
28. What is a stored procedure and a trigger?
A stored procedure is saved SQL code you call by name. A trigger runs automatically on INSERT, UPDATE or DELETE.
Transactions
29. What is a transaction?
A group of operations that runs as one unit: all succeed or none do, for example a money transfer.
30. What are the ACID properties?
Atomicity (all or nothing), Consistency (valid state to valid state), Isolation (transactions do not disturb each other), Durability (committed data survives a crash).
31. What are the states of a transaction?
Active, partially committed, committed, failed and aborted.
32. What problems happen without concurrency control?
Dirty read, lost update, non-repeatable read and phantom read.
33. What is a deadlock in DBMS?
Two transactions wait for locks held by each other. The DBMS detects it and rolls one back.
34. What is two-phase locking (2PL)?
A transaction first acquires all locks (growing phase), then releases them (shrinking phase). It guarantees serializability.
35. What is serializability?
A schedule of concurrent transactions is serializable if its result is the same as some serial order.
Modern topics
36. SQL vs NoSQL?
SQL databases are relational with a fixed schema (MySQL, PostgreSQL). NoSQL databases are schema-flexible and scale horizontally (MongoDB, Cassandra, Redis).
37. What is sharding?
Splitting a large database across many servers by a key, for example users by region.
38. What is replication?
Keeping copies of data on multiple servers for availability and faster reads.
39. What is the CAP theorem?
A distributed system can guarantee only two of Consistency, Availability and Partition tolerance at the same time.
40. OLTP vs OLAP?
OLTP handles many short transactions (banking, orders). OLAP handles complex analysis on large historical data (reports, data warehouses).
5 SQL queries every fresher must write
- Second highest salary:
SELECT MAX(salary) FROM emp WHERE salary < (SELECT MAX(salary) FROM emp); - Nth highest salary:
SELECT DISTINCT salary FROM emp ORDER BY salary DESC LIMIT 1 OFFSET N-1; - Duplicate rows:
SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1; - Employees with their manager:
SELECT e.name, m.name AS manager FROM emp e LEFT JOIN emp m ON e.manager_id = m.id; - Department-wise average salary:
SELECT dept, AVG(salary) FROM emp GROUP BY dept;
Next, revise Operating System interview questions, the OOPs interview questions and our Data Warehousing and Data Mining notes.




Doubts? Ask here