Are you preparing for your upcoming database interviews and looking for the most trusted resources? This post compiles the top DBMS GFG interview questions, frequently asked in top tech company interviews. Whether you are revising DBMS interview questions GFG for campus placements or experienced-level interviews, these detailed explanations with examples will strengthen your fundamentals and practical understanding.
These GFG DBMS interview questions cover everything from normalization, indexing, transactions, SQL queries, and ER models to advanced database concepts. Read till the end to ensure you crack your next database management systems interview confidently.
1. What is DBMS?
Answer:
DBMS (Database Management System) is software that stores, retrieves, and manages data in databases efficiently.
Example:
MySQL, Oracle, PostgreSQL are popular DBMSs.
2. What is the difference between DBMS and RDBMS?
DBMS | RDBMS |
Stores data as files | Stores data in tables |
No relationship constraints | Supports relationships between tables |
Example: File system | Example: MySQL, PostgreSQL |
3. What is SQL?
Answer:
SQL (Structured Query Language) is used to communicate with relational databases for data querying and manipulation.
Example:
SELECT * FROM employees;
4. Define schema.
Answer:
Schema is the logical structure of a database, defining tables, views, relationships, constraints, etc.
5. What is a primary key?
Answer:
A column or combination of columns that uniquely identifies each row.
Example:
CREATE TABLE students (
roll_no INT PRIMARY KEY,
name VARCHAR(50)
);
6. What is a foreign key?
Answer:
A key that references the primary key of another table to enforce referential integrity.
Example:
CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(id)
);
7. What is normalization?
Answer:
Process to organize data to reduce redundancy and improve integrity.
8. Explain 1NF, 2NF, 3NF with examples.
- 1NF: Atomic values
Example: No multiple values in a single cell. - 2NF: 1NF + no partial dependency
Example: Non-key attribute depends on the whole primary key. - 3NF: 2NF + no transitive dependency
Example: Non-key attribute depends only on primary key.
9. What is denormalization?
Answer:
Adding redundant data to improve read performance.
10. Define candidate key.
Answer:
Any attribute(s) that can uniquely identify a row. One is chosen as the primary key.
11. Define super key.
Answer:
Any combination of attributes that uniquely identifies a row. Candidate keys are minimal super keys.
12. What is an alternate key?
Answer:
Candidate keys not chosen as primary key.
13. What is a composite key?
Answer:
Primary key composed of multiple columns.
14. What is a unique key?
Answer:
Enforces uniqueness for column values but allows one NULL.
15. Difference between primary key and unique key.
Primary Key | Unique Key |
No NULL | Allows one NULL |
Single per table | Multiple allowed |
16. What are constraints?
Answer:
Rules to enforce data integrity (e.g., NOT NULL, UNIQUE, CHECK, DEFAULT, FOREIGN KEY).
17. Explain DDL and DML.
DDL (Data Definition Language) | DML (Data Manipulation Language) |
Defines schema | Manipulates data |
CREATE, ALTER, DROP | SELECT, INSERT, UPDATE, DELETE |
18. What is DCL and TCL?
- DCL: Data Control Language (GRANT, REVOKE)
- TCL: Transaction Control Language (COMMIT, ROLLBACK, SAVEPOINT)
19. What is a view?
Answer:
A virtual table based on a query.
Example:
CREATE VIEW high_salary AS
SELECT name, salary FROM employees WHERE salary > 50000;
20. Difference between view and table.
View | Table |
Virtual table | Physical storage |
No data storage | Stores data |
21. What is an index?
Answer:
Data structure to speed up data retrieval.
22. Types of indexes.
- Clustered index: Alters physical order
- Non-clustered index: Separate from physical order
23. What is a transaction?
Answer:
Logical unit of work that is atomic, consistent, isolated, durable (ACID properties).
24. Explain ACID properties.
- Atomicity: All or none
- Consistency: Valid state
- Isolation: Concurrent transactions don’t interfere
- Durability: Changes persist after commit
25. What is a deadlock?
Answer:
Two transactions waiting for each other’s resources, causing infinite waiting.
26. How to resolve deadlocks?
- Timeouts
- Transaction ordering
- Deadlock detection algorithms
27. What is the difference between delete, truncate, and drop?
DELETE | TRUNCATE | DROP |
Deletes rows | Deletes all rows | Deletes table |
WHERE clause possible | No WHERE | Removes structure |
Slower | Faster | Destroys table |
28. Explain JOIN and its types.
- INNER JOIN: Matching rows
- LEFT JOIN: All left + matching right
- RIGHT JOIN: All right + matching left
- FULL JOIN: All rows
- SELF JOIN: Join table to itself
29. What is a subquery?
Answer:
Query within another query.
30. What is a correlated subquery?
Answer:
Subquery that uses outer query’s column values.
31. Explain UNION and UNION ALL.
UNION | UNION ALL |
Removes duplicates | Includes duplicates |
32. What is the difference between HAVING and WHERE?
WHERE | HAVING |
Filters rows | Filters groups |
Used before GROUP BY | Used after GROUP BY |
33. Explain GROUP BY with example.
Example:
SELECT department, COUNT(*) FROM employees GROUP BY department;
34. What is the purpose of ORDER BY?
Answer:
Sorts result set.
35. What is ER model?
Answer:
Entity-Relationship model represents entities and their relationships.
36. Define entity and entity set.
- Entity: Real-world object
- Entity set: Collection of similar entities
37. What is an attribute?
Answer:
Property of an entity.
38. Types of attributes.
- Simple, composite, derived, multi-valued, key attribute.
39. What is cardinality?
Answer:
Defines the number of entities related between sets (1:1, 1:N, M:N).
40. Explain generalization and specialization.
- Generalization: Bottom-up approach
- Specialization: Top-down approach
41. What is aggregation in ER modeling?
Answer:
Treating relationship as an entity for abstraction.
42. What is relational algebra?
Answer:
Procedural query language with operations like select, project, union, set difference, cartesian product, join.
43. What is relational calculus?
Answer:
Non-procedural query language (tuple and domain calculus).
44. What is a trigger?
Answer:
Procedure that executes automatically on events (INSERT, UPDATE, DELETE).
45. Example of trigger.
CREATE TRIGGER update_salary BEFORE UPDATE ON employees
FOR EACH ROW EXECUTE FUNCTION audit_salary();
46. What is a stored procedure?
Answer:
Precompiled SQL code saved in database.
47. What is cursor?
Answer:
Pointer for retrieving query results row by row.
48. Types of cursor.
- Implicit
- Explicit
49. What is normalization anomaly?
Answer:
Issues like insertion, deletion, update anomalies due to poor design.
50. What is BCNF?
Answer:
Boyce-Codd Normal Form: advanced version of 3NF with stricter rules.
51. Explain functional dependency.
Answer:
Relationship where one attribute determines another.
52. What is transitive dependency?
Answer:
Non-prime attribute depends on another non-prime attribute.
53. What is indexing?
Answer:
Technique to optimize query performance by creating index structures.
54. What is hashing in DBMS?
Answer:
Technique for fast data retrieval using hash functions.
55. Explain clustering in DBMS.
Answer:
Storing related records together for faster access.
56. What is RAID in DBMS?
Answer:
Redundant Array of Independent Disks for fault tolerance and performance.
57. What is data independence?
Answer:
Ability to change schema without affecting applications.
- Logical independence: Change logical schema
- Physical independence: Change physical schema
58. What is 4NF?
Answer:
Fourth Normal Form removes multi-valued dependencies.
59. What are integrity constraints?
Answer:
Rules to ensure valid data (e.g., entity integrity, referential integrity).
60. What is a lock?
Answer:
Mechanism to control concurrent access.
61. Types of locks.
- Shared lock
- Exclusive lock
62. What is two-phase locking protocol?
Answer:
Ensures serializability using growing and shrinking phases.
63. What is serializability?
Answer:
Schedule of transactions produces same result as some serial schedule.
64. What is schedule?
Answer:
Sequence of transaction operations.
65. What is dirty read?
Answer:
Reading uncommitted data from other transaction.
66. Explain phantom read.
Answer:
Rows added/removed by another transaction during a query execution.
67. What is starvation?
Answer:
Transaction never gets resources due to other long transactions.
68. What is shadow paging?
Answer:
Recovery mechanism using shadow copies.
69. What is log-based recovery?
Answer:
Uses transaction logs to recover database state.
70. Difference between file system and DBMS.
File System | DBMS |
No consistency checks | Ensures data integrity |
Redundant data | Minimal redundancy |
71. What is hashing collision?
Answer:
Two keys producing the same hash value.
72. What is extendible hashing?
Answer:
Dynamic hashing technique to reduce collisions.
73. What is B+ tree index?
Answer:
Balanced tree structure for indexing with fast retrieval and range queries.
74. What is query optimization?
Answer:
Process to determine the most efficient execution plan for a query.
75. What is distributed database?
Answer:
Database distributed across multiple locations but logically unified.
Mastering these DBMS GFG interview questions will build your clarity on core and advanced topics, ensuring you tackle any database question confidently in interviews. The DBMS interview questions GFG discussed here are designed for quick revision and conceptual clarity with practical examples to relate to real-world applications.
Keep practicing these GFG DBMS interview questions to enhance your problem-solving skills and strengthen your database design knowledge. If this post helped you, share it with your peers preparing for DBMS interviews to support their journey as well.
👉 Explore related interview guides to level up your preparation:
- Top 100 SQL Query Interview Questions and Answers
- Oracle Interview Questions and Answers
- Top 50 MySQL Interview Questions and Answers
- 75 Most Common SystemVerilog Interview Questions
- Top Interview Questions and Answers to Crack Your Next Job Interview