Dbms
Dbms
Sign In
Databases SQL MySQL PostgreSQL PL/SQL MongoDB SQL Cheat Sheet SQL Interview Questions MySQL Interview Questions PL/SQL Interview Questions Learn SQL and Database
Next Article: Top 60 DBMS Interview Questions with Answers for 2025
Commonly asked DBMS Last Updated : 28 Apr, 2025
Interview Questions | Set 2
A Database Management System (DBMS) is the backbone of modern data storage and
management. Understanding DBMS concepts is critical for anyone looking to work with databases.
Whether you're preparing for your first job in database management or advancing in your career,
being well-prepared for a DBMS interview can make all the difference.
In this article, we've covered a list of DBMS interview questions that cover everything from basic
to advanced topics. These questions will help us build a solid understanding of DBMS concepts,
from how databases are structured to complex query optimization. Start your preparation today to
secure your dream role in database management!
A Database Management System (DBMS) is software that is used to manage and organize
databases. It provides an interface to interact with the data stored in a database. The DBMS is
responsible for tasks such as storing, retrieving, and updating data, ensuring data integrity,
security, and managing concurrency. Examples include MySQL, PostgreSQL, Oracle, and SQL
Server.
DBMS (Database Management System): A system that allows users to create, store, modify,
and delete data. It does not require a relational structure for data organization. Examples:
Microsoft Access, XML databases.
RDBMS (Relational Database Management System): A subset of DBMS that stores data in a
structured format, using tables (relations), and supports relational operations like joins. It
enforces data integrity through keys and supports SQL for querying. Examples: MySQL, Oracle,
SQL Server.
A relation in DBMS is a table that consists of rows and columns. Each row represents a record,
and each column represents an attribute or property of the entity being described. Relations are
defined by a schema, which specifies the attributes (columns) of the table.
A table in DBMS is a collection of data organized in rows and columns. It is the primary structure
for storing data in a relational database. Each row represents an entity (record), and each column
represents an attribute of that entity.
Rows (Tuples): A row represents a single record or entity. Each row contains values for each
attribute (column).
Columns (Attributes): A column represents a property or characteristic of the entity. Each
column has a data type, such as integer, string, etc
A Primary Key is a unique identifier for each record in a table. It ensures that no two records have
the same value for the primary key field. It cannot contain NULL values. Example: In a STUDENT
table, ROLL_NO could be the primary key because each student has a unique roll number.
1 Ram Delhi
2 Suresh Delhi
A Foreign Key is an attribute in a table that links to the primary key in another table. It creates a
relationship between two tables, ensuring referential integrity. Example: In a STUDENT table, the
BRANCH_CODE could be a foreign key referencing the primary key BRANCH_CODE in the BRANCH table.
Student Table
1 Ram CS
2 Suresh IT
BRANCH Table
BRANCH_CODE BRANCH_NAME
CS Computer Science
IT Information Technology
Normalization is the process of organizing data in a way that reduces redundancy and
dependency. It involves dividing large tables into smaller ones and defining relationships between
them to ensure data integrity.
Importance:
Difference:
A Candidate Key is a set of one or more attributes that can uniquely identify a tuple in a relation. A
relation can have multiple candidate keys, and one of them is chosen as the primary key.
The SELECT statement is used to query data from one or more tables. It allows you to retrieve
specific columns or all columns, optionally applying filters (WHERE), sorting (ORDER BY), and
joining multiple tables.
Example:
A View is a virtual table created by querying one or more base tables. It does not store data
physically but dynamically retrieves it when queried. Unlike a table, a view does not store its own
data but presents data from other tables.
One-to-One (1:1): A record in one table is associated with a single record in another table.
One-to-Many (1:M): A record in one table is associated with multiple records in another table.
Many-to-Many (M:M): Multiple records in one table are associated with multiple records in
another table.
A schema in DBMS is the structure that defines the organization of data in a database. It includes
tables, views, relationships, and other elements. A schema defines the tables and their columns,
along with the constraints, keys, and relationships.
Constraints in DBMS are rules that limit the type of data that can be inserted into a table to
ensure data integrity and consistency. Common types of constraints include: NOT NULL, PRIMARY
KEY, FOREIGN KEY, UNIQUE, CHECK, DEFAULT.
DELETE: Deletes specific rows from a table based on a condition. It logs each row deletion and
can be rolled back.
TRUNCATE: Removes all rows from a table without logging individual row deletions. It cannot
be rolled back and is faster than DELETE.
An index is a data structure that improves the speed of data retrieval operations on a database
table. It works like a table of contents in a book, allowing the database to quickly find the location
of a record based on a column value.
A Database Administrator (DBA) is responsible for managing and overseeing the entire database
environment. Their key responsibilities include:
Database Design: Structuring the database for optimal storage and performance.
Backup and Recovery: Ensuring regular backups and providing recovery solutions in case of
failures.
Performance Tuning: Monitoring and optimizing the database's performance.
Security Management: Managing user access, privileges, and enforcing security policies.
Data Integrity: Ensuring data consistency and integrity through constraints and checks.
Upgrades and Patches: Keeping the database software up-to-date with patches and
upgrades.
Troubleshooting: Identifying and resolving database-related issues.
Example of ERD:
A Student entity might have attributes like ID, Name, and Age.
A Course entity might have attributes like CourseID, CourseName.
A relationship Enrolls connects Student and Course with attributes like EnrollmentDate.
23. What is a join in SQL? Name and explain different types of joins.
A JOIN in SQL is an operation that combines columns from two or more tables based on a related
column between them. Joins are used to query data from multiple tables in a relational database.
1. INNER JOIN: Returns only the rows where there is a match in both tables.
Example:
2. LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table and the matching rows
from the right table. If there is no match, NULL values will be returned for columns from the right
table.
Example:
3. RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the right table and the matching
rows from the left table. If there is no match, NULL values will be returned for columns from the
left table.
Example:
4. FULL JOIN (or FULL OUTER JOIN): Returns all rows when there is a match in either the left or
the right table. If there is no match, NULL values will be returned for the columns of the table
without a match.
Example:
5. CROSS JOIN: Returns the Cartesian product of two tables, i.e., every combination of rows from
both tables.
Example:
6. SELF JOIN: A SELF JOIN is a join where a table is joined with itself. It is used when we need to
compare rows within the same table. To differentiate the two instances of the same table, aliases
are used.
Example:
A subquery in SQL is a query embedded within another query. It is used to retrieve data that will
be used in the outer query. Subqueries can be used in SELECT, INSERT, UPDATE, or DELETE
statements.
Example of a subquery: To find the names of students who have a higher age than the average
age:
Aggregate functions in SQL are functions that operate on a set of values (or a group of rows) and
return a single result. They are often used in conjunction with the GROUP BY clause. Here are a
few commonly used aggregate functions in SQL:
Example:
Example:
Example:
Example:
Example:
A transaction in DBMS is a sequence of one or more SQL operations executed as a single unit of
work. A transaction ensures data integrity, consistency, and isolation, and it guarantees that the
database reaches a valid state, regardless of errors or system failures.
Atomicity: All operations within the transaction are completed successfully, or none are applied
(i.e., the transaction is atomic).
Consistency: The transaction brings the database from one valid state to another valid state.
Isolation: The operations of one transaction are isolated from others; intermediate results are
not visible to other transactions.
Durability: Once a transaction is committed, its effects are permanent, even in the event of a
system crash.
ACID stands for Atomicity, Consistency, Isolation, and Durability, which are the key properties
that guarantee reliable transaction processing:
Atomicity: All operations in a transaction are treated as a single unit. If one operation fails, the
entire transaction fails and the database state remains unchanged.
Consistency: Ensures the database starts and ends in a consistent state, with all rules and
constraints enforced.
Isolation: Transactions are executed independently, and the intermediate states of a transaction
are invisible to other transactions.
Durability: Once a transaction is committed, its changes are permanent, even if a system failure
occurs.
A stored procedure is a precompiled collection of one or more SQL statements stored in the
database. Stored procedures allow users to execute a series of operations as a single unit,
improving performance and reusability. They can accept input parameters, perform operations, and
return results.
Example:
A trigger is a special kind of stored procedure that automatically executes (or "fires") in response
to certain events on a table, such as insertions, updates, or deletions. Triggers are used to enforce
business rules, maintain consistency, or log changes.
Example:
30. What is the difference between UNION and UNION ALL in SQL?
UNION: Combines the result of two queries and removes duplicate rows.
UNION ALL: Combines the result of two queries but does not remove duplicates, thus it is
faster than UNION.
Example:
Indexing is a technique used to speed up the retrieval of records from a table by creating a data
structure that allows for faster searching. An index provides a quick lookup of data based on the
values of one or more columns.
Types of Indexes:
Single-column index: Created on one column.
Composite index: Created on multiple columns.
Unique index: Ensures that no two rows have the same values in the indexed columns.
1NF (First Normal Form): Ensures that each column contains atomic (indivisible) values, and
each record is unique.
2NF (Second Normal Form): Ensures that the table is in 1NF, and all non-key attributes are
fully functionally dependent on the primary key.
3NF (Third Normal Form): Ensures that the table is in 2NF, and no transitive dependencies
exist between non-key attributes.
BCNF (Boyce-Codd Normal Form): A stricter version of 3NF, which ensures that every
determinant is a candidate key.
33. What is the difference between INNER JOIN and OUTER JOIN?
Returns only matching rows Returns all rows from one or both tables, with NULL
Result Set
from both tables. where no match is found.
When you need only the When you need to preserve all data, even with
Use Case
intersecting data. mismatches.
Generally faster as it deals Can be slower due to handling more rows and NULL
Performance
with fewer rows. values.
Reliable for matching data Reliable when you need to retain all data, but can
Reliability
across tables. introduce NULL-related issues.
Data redundancy refers to the unnecessary repetition of data in a database. It can lead to
inconsistencies, increased storage requirements, and maintenance challenges.
Reduction methods:
A deadlock occurs when two or more transactions are blocked because each transaction is waiting
for the other to release resources. This results in a situation where none of the transactions can
proceed.
Prevention techniques:
Lock ordering: Ensuring that all transactions acquire locks in the same predefined order.
Timeouts: Automatically rolling back transactions that have been waiting too long for resources.
Deadlock detection: Periodically checking for deadlocks and aborting one of the transactions to
break the cycle.
A cursor in DBMS is a pointer to a result set of a query. It allows for row-by-row processing of
query results, which is useful when dealing with large datasets.
Types of cursors:
Implicit cursors: Automatically created by the DBMS for SELECT, INSERT, UPDATE, DELETE
operations.
Explicit cursors: Manually created by the programmer to process query results.
Example:
There are several types of locks in DBMS to ensure data consistency when multiple transactions
are involved:
Shared Lock (S Lock): Allows multiple transactions to read a resource but prevents
modification.
Exclusive Lock (X Lock): Prevents any other transaction from reading or modifying the locked
resource.
Intent Lock: Signals that a transaction intends to lock a resource.
Update Lock (U Lock): Used when a transaction intends to update a resource.
Clustered Index: Organizes the data in the table according to the index. There can only be one
clustered index per table because the data rows can only be sorted one way.
Non-clustered Index: Creates a separate structure from the table that holds pointers to the
actual data rows. Multiple non-clustered indexes can be created on a table.
COMMIT: Saves all changes made during the current transaction to the database permanently.
ROLLBACK: Reverses all changes made during the current transaction, restoring the database
to its previous state.
Both operations ensure the ACID properties of transactions: Atomicity and Durability.
Superkey: A set of one or more attributes that can uniquely identify a row in a table. It may
contain unnecessary attributes.
Candidate Key: A minimal superkey that uniquely identifies a row, with no redundant attributes.
A table can have multiple candidate keys, and one is chosen as the Primary Key.
41. What are the different types of constraints in DBMS? Give examples.
Constraints in DBMS are rules applied to the data in a database to ensure its accuracy and
integrity. The most common types of constraints are:
NOT NULL: Ensures that a column cannot have NULL values. Example: Name VARCHAR(50) NOT
NULL;
PRIMARY KEY: Uniquely identifies each record in a table. It ensures that no duplicate rows exist
and that no NULL values are allowed. Example: ID INT PRIMARY KEY;
FOREIGN KEY: Ensures referential integrity between two tables by linking a column in one
table to the primary key in another table. Example: BranchCode INT FOREIGN KEY REFERENCES
Branch(BranchCode);
UNIQUE: Ensures that all values in a column are distinct. Unlike the primary key, it allows NULL
values. Example: Email VARCHAR(100) UNIQUE;
CHECK: Ensures that values in a column satisfy a specific condition. Example: Age INT CHECK
(Age >= 18);
DEFAULT: Assigns a default value to a column if no value is provided during insertion.
Example: Status VARCHAR(10) DEFAULT 'Active';
42. Explain the difference between a primary key and a unique key.
Primary Key:
Unique Key:
Ensures that all values in a column (or a set of columns) are unique across all rows.
Can contain NULL values (unlike a primary key).
A table can have multiple unique keys.
Referential Integrity ensures that relationships between tables are maintained correctly. It
requires that the foreign key in one table must match a primary key or a unique key in another
table (or be NULL). This ensures that data consistency is maintained, and there are no orphan
records in the database.
Example: In the Orders table, if the CustomerID is a foreign key, it should match a valid CustomerID
in the Customers table or be NULL.
Concurrency control ensures that database transactions are executed in a way that prevents
conflicts, such as data inconsistency, when multiple transactions are executed simultaneously.
DBMS uses the following techniques:
Locking: Transactions acquire locks (shared or exclusive) on the data to prevent other
transactions from modifying it while one transaction is in progress. Types of Locks: Shared locks
(S-lock) and exclusive locks (X-lock).
Timestamp Ordering: Assigns a unique timestamp to each transaction and uses these
timestamps to determine the order in which transactions should be executed.
Optimistic Concurrency Control: Transactions are executed without locking data, but before
committing, the system checks whether there were conflicts with other transactions.
Two-Phase Locking: Involves two phases—growing (acquiring locks) and shrinking (releasing
locks)—to avoid deadlocks and ensure serializability.
Enforcing Data Integrity: Ensures that the value of a foreign key matches a valid primary key or
unique key, maintaining consistency.
Referential Integrity: Prevents orphaned records in the database by enforcing valid
relationships between tables.
Easy Data Maintenance: Helps with cascading updates and deletions, meaning changes in the
referenced table can automatically propagate to the referencing table (if configured with ON
UPDATE CASCADE or ON DELETE CASCADE).
Improved Query Efficiency: With foreign keys, database queries that join related tables are
more efficient and meaningful.
A transaction log is a record that keeps track of all transactions executed on a database. It
ensures that changes made by transactions are saved, and in case of a system failure, the log can
be used to recover the database to its last consistent state. The transaction log contains:
A materialized view is a database object that contains the results of a query. Unlike a regular
view, which is a virtual table (it doesn’t store data), a materialized view stores data physically,
improving query performance by precomputing and storing results.
Use Case: Materialized views are commonly used for performance optimization in data
warehousing and reporting systems, where the same data is frequently queried.
Example:
48. What are the differences between an ER diagram and a relational schema?
A conceptual blueprint that models entities, relationships, and attributes of the database. It
visually represents the structure of the database.
Used in the database design phase to understand how data entities relate to each other.
Relational Schema:
A logical schema that defines the structure of a relational database, including tables, columns,
relationships, and constraints.
Represents how data is physically organized in tables with constraints such as primary keys,
foreign keys, and data types.
The GROUP BY clause is used in SQL to group rows that have the same values in specified
columns into summary rows, often with aggregate functions like COUNT, SUM, AVG, MIN, or MAX. It is
typically used to organize data for reporting or analysis.
Example: This groups the employees by department and counts the number of employees in each
department.
A stored function is a set of SQL statements that can be executed in the database. It accepts
input parameters, performs some logic, and returns a value. Stored functions are similar to stored
procedures but differ in that they must return a value.
Example:
51. What are the various types of normalization techniques? Explain with examples.
Normalization is the process of organizing data in a database to eliminate redundancy and improve
data integrity. The primary goal is to minimize the chances of anomalies when performing
operations like insertions, deletions, and updates. There are several levels or normal forms in
normalization:
1. First Normal Form (1NF): Ensures that the data in the table is atomic, meaning each column
contains indivisible values (no multi-valued attributes).
Example:
2. Second Normal Form (2NF): 2NF is achieved when the table is in 1NF and all non-key
attributes are fully dependent on the primary key.
Here, InstructorName depends on CourseID, not on StudentID. To make it 2NF, we separate the
data:
3. Third Normal Form (3NF): A table is in 3NF if it is in 2NF and there is no transitive dependency
(non-key attributes depend on other non-key attributes).
Example:
4. Boyce-Codd Normal Form (BCNF): A stricter version of 3NF where every determinant is a
candidate key.
Example:
And the constraint is such that InstructorID determines CourseID, it would not be in BCNF
because InstructorID is not a candidate key. To achieve BCNF:
52. What are the different phases of the DBMS query processing cycle?
The DBMS query processing cycle consists of several phases that transform the high-level query
(SQL) into executable actions:
1. Parsing: The SQL query is parsed to check its syntax and semantics. The DBMS ensures that
the query is valid according to the SQL syntax and the database schema.
2. Translation: The query is translated into an internal form, such as a relational algebra
expression or an execution plan.
3. Optimization: The DBMS optimizes the query to determine the most efficient execution plan,
considering factors like indexes, joins, and available resources.
4. Execution: The optimized query plan is executed by the query processor, which accesses the
data from the database and returns the results.
Full Backup: A full backup copies the entire database, including all data and the database
structure. It is the most comprehensive but can take up a lot of storage and time.
Incremental Backup: An incremental backup only copies the data that has changed since the
last backup (either full or incremental). This saves space and time but requires the restoration
of the full backup and all incremental backups.
Differential Backup: A differential backup copies all changes made since the last full backup.
It’s faster than a full backup and simpler to restore than incremental backups.
Transaction Log Backup: A transaction log backup copies the transaction log, which records all
transactions performed on the database. This allows for point-in-time recovery.
54. What is the use of the "WITH CHECK OPTION" in SQL views?
The "WITH CHECK OPTION" is used when creating a view in SQL to ensure that any insert or
update operation on the view must adhere to the conditions defined in the view’s WHERE clause.
If the inserted or updated data violates these conditions, the operation will be rejected.
Example: Here, if a user tries to insert or update a Student record with a status other than 'Active',
the operation will fail.
A B-tree is a self-balancing tree data structure that maintains sorted data and allows searches,
insertions, deletions in logarithmic time.
B-trees are used in databases and file systems to store large amounts of data. All nodes in a
B-tree can have multiple children, which increases the efficiency of searching.
Stores data in both internal and leaf nodes.
B+ tree:
A B+ tree is an extension of the B-tree and is widely used in databases for indexing. It differs
in that it has a linked list at the leaf level and stores all records in the leaf nodes.
The internal nodes of the B+ tree store only keys and pointers to the next level of the tree,
while the leaf nodes contain actual data or pointers to the data.
Stores data only in the leaf nodes and uses the internal nodes for indexing.
A hashing technique in DBMS is used to map data (such as a key) to a fixed-size value or
address, using a hash function. It is primarily used for quick data retrieval, particularly in hash
indexes or hash tables. Example: A hash function might map a StudentID of 123 to a bucket index
of 3. The student’s record would be stored in the corresponding bucket.
How it works:
1. A hash function takes the key (e.g., a record’s ID) and calculates a hash value.
2. This hash value determines the bucket or slot where the data is stored.
3. When searching for a record, the hash function is applied again to the key to find the
corresponding bucket.
Trigger:
A trigger is an automatic action executed by the DBMS when a specific event occurs on a table,
such as an INSERT, UPDATE, or DELETE.
It cannot be invoked manually and is tied to a specific event.
Stored Procedure:
A stored procedure is a precompiled set of SQL statements that can be executed explicitly by a
user or application.
It is invoked manually, and it can accept input parameters and return output.
Data partitioning is the process of dividing large datasets into smaller, more manageable
segments (partitions) to improve performance, scalability, and availability. Each partition can be
stored and processed separately.
Types of partitioning:
1. Horizontal Partitioning: Divides data by rows. For example, splitting data by time range (e.g.,
2020 data in one partition, 2021 in another).
2. Vertical Partitioning: Divides data by columns. For example, putting frequently accessed
columns in one partition and less frequently accessed columns in another.
3. Range Partitioning: Data is divided based on a range of values (e.g., age groups, date ranges).
4. Hash Partitioning: Data is distributed across partitions based on a hash value derived from a
key column.
59. What is the role of the DBMS in handling data integrity and security?
Data Integrity: Through constraints like Primary Keys, Foreign Keys, and Check Constraints,
the DBMS ensures data consistency and accuracy.
Data Security: DBMS systems provide user authentication, access control, and encryption
mechanisms to protect data from unauthorized access and breaches. It also supports role-
based access control (RBAC), ensuring that only authorized users can perform certain actions on
the data.
Provides advanced security features like Security is managed at the file system
Security user authentication, access control, and level, which is less robust than DBMS
encryption. security features.
Conclusion
Preparing for a DBMS interview requires a strong understanding of both fundamental and
advanced concepts. From basic database operations to handling large-scale data with advanced
indexing strategies, mastering these DBMS interview questions will prepare you for a variety of
challenges you may encounter in your career. By practicing these questions, you’ll enhance your
problem-solving skills, boost your confidence, and be ready to tackle any database-related
challenges in your interview.
Similar Reads
Basic of DBMS
Relational Model
Relational Algebra
Advanced DBMS
DBMS Practice
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It !
Skip to content
Company Languages DSA Data Science & ML Web Technologies Python Tutorial
About Us DSA Tutorial HTML Python Programming
Corporate & Communications Python Data Science With Python
Examples
Address: Legal Basic DSA Problems CSS
Java Data Science For Beginner
A-143, 7th Floor, Sovereign Python Projects
Corporate Tower, Sector- 136, Privacy Policy DSA Roadmap JavaScript
C++ Machine Learning
Noida, Uttar Pradesh (201305) Python Tkinter
In Media Top 100 DSA Interview TypeScript
PHP ML Maths
Problems Python Web Scraping
Registered Address: Contact Us ReactJS
K 061, Tower K, Gulshan GoLang Data Visualisation
DSA Roadmap by Sandeep Jain OpenCV Tutorial
Vivante Apartment, Sector 137, Advertise with us NextJS
Noida, Gautam Buddh Nagar, SQL Pandas
Uttar Pradesh, 201305 All Cheat Sheets Python Interview Question
GFG Corporate Solution Bootstrap
R Language NumPy
Django
Placement Training Program Web Design
Android Tutorial NLP
Computer Science DevOps System Design Inteview Preparation School Subjects GeeksforGeeks Videos
Operating Systems Git High Level Design Competitive Programming Mathematics DSA
Computer Network Linux Low Level Design Top DS or Algo for CP Physics Python
Database Management System AWS UML Diagrams Company-Wise Recruitment Chemistry Java
Advertise with us Software Engineering Docker Interview Guide Process Biology C++
Digital Logic Design Kubernetes Design Patterns Company-Wise Preparation Social Science Web Development
Engineering Maths Azure OOAD Aptitude Preparation English Grammar Data Science
Software Development GCP System Design Bootcamp Puzzles Commerce CS Subjects
Software Testing DevOps Roadmap Interview Questions World GK
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It !