0% found this document useful (0 votes)
2 views

dbms interview question

The document provides a comprehensive list of common and advanced interview questions related to Database Management Systems (DBMS), along with their answers. Key topics include definitions of DBMS, types of DBMS, normalization, ACID properties, SQL operations, indexing, and advanced concepts like OLTP vs OLAP, database sharding, and isolation levels. This resource serves as a valuable guide for candidates preparing for database-related roles.

Uploaded by

biswajitde200
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

dbms interview question

The document provides a comprehensive list of common and advanced interview questions related to Database Management Systems (DBMS), along with their answers. Key topics include definitions of DBMS, types of DBMS, normalization, ACID properties, SQL operations, indexing, and advanced concepts like OLTP vs OLAP, database sharding, and isolation levels. This resource serves as a valuable guide for candidates preparing for database-related roles.

Uploaded by

biswajitde200
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Sure!

Here are some common DBMS (Database Management System) interview questions
along with their answers:

1. **What is DBMS?**
- **Answer**: A Database Management System (DBMS) is software that interacts with the
user, applications, and the database itself to capture and analyze data. It provides a
systematic way to create, retrieve, update, and manage data.

2. **What are the different types of DBMS?**


- **Answer**: The different types of DBMS include:
- Hierarchical DBMS
- Network DBMS
- Relational DBMS (RDBMS)
- Object-oriented DBMS (OODBMS)

3. **What is a primary key?**


- **Answer**: A primary key is a unique identifier for a record in a table. It must contain
unique values and cannot contain NULL values.

4. **What is a foreign key?**


- **Answer**: A foreign key is a field (or collection of fields) in one table that uniquely
identifies a row of another table. The foreign key creates a relationship between the two
tables.

5. **What is normalization?**
- **Answer**: Normalization is the process of organizing data to minimize redundancy. It
involves dividing a database into two or more tables and defining relationships between the
tables. The main normal forms are:
- 1NF (First Normal Form)
- 2NF (Second Normal Form)
- 3NF (Third Normal Form)
- BCNF (Boyce-Codd Normal Form)

6. **What are ACID properties?**


- **Answer**: ACID properties ensure reliable processing of database transactions:
- **Atomicity**: Ensures that each transaction is treated as a single unit, which either
succeeds completely or fails completely.
- **Consistency**: Ensures that a transaction brings the database from one valid state to
another.
- **Isolation**: Ensures that transactions occur independently without interference.
- **Durability**: Ensures that the results of a transaction are permanently stored in the
system.

7. **What is indexing?**
- **Answer**: Indexing is a technique used to optimize the performance of a database by
minimizing the number of disk accesses required when a query is processed. Indexes can
be created using one or more columns of a database table.
8. **What is SQL?**
- **Answer**: SQL (Structured Query Language) is a standard programming language
used to manage and manipulate relational databases. It includes commands such as
SELECT, INSERT, UPDATE, DELETE, and CREATE.

9. **What are joins in SQL?**


- **Answer**: Joins are SQL operations used to combine rows from two or more tables
based on a related column. Types of joins include:
- INNER JOIN: Returns records that have matching values in both tables.
- LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records
from the right table.
- RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched
records from the left table.
- FULL (OUTER) JOIN: Returns all records when there is a match in either left or right
table.

10. **What is a stored procedure?**


- **Answer**: A stored procedure is a set of SQL statements that can be stored in the
database and executed repeatedly. They allow for modular programming, can improve
performance, and ensure consistent implementation of business logic.

11. **What is a trigger in a database?**


- **Answer**: A trigger is a set of instructions that automatically executes in response to
certain events on a particular table or view. Triggers can be used for enforcing business
rules, validating input data, and maintaining audit trails.

12. **What is the difference between DELETE and TRUNCATE commands?**


- **Answer**: The DELETE command removes rows from a table based on a condition
and can be rolled back. The TRUNCATE command removes all rows from a table, but it
cannot be rolled back and is faster because it does not log individual row deletions.

13. **What is the difference between clustered and non-clustered indexes?**


- **Answer**:
- **Clustered Index**: Alters the physical order of the table and searches more efficiently.
There can be only one clustered index per table.
- **Non-Clustered Index**: Does not alter the physical order of the table and creates a
separate object within the table. A table can have multiple non-clustered indexes.

14. **What is an ER diagram?**


- **Answer**: An Entity-Relationship (ER) diagram is a visual representation of the
database structure, showing entities, attributes, and the relationships between entities.

15. **What is data integrity?**


- **Answer**: Data integrity refers to the accuracy and consistency of data stored in a
database. It is maintained through integrity constraints like primary keys, foreign keys, and
unique constraints.
These questions cover fundamental concepts in DBMS, which are commonly asked in
interviews for database-related roles.

Certainly! Here are more advanced and technical DBMS interview questions with their
answers:

16. **What is the difference between OLTP and OLAP?**


- **Answer**:
- **OLTP (Online Transaction Processing)**: Systems designed for managing
transaction-oriented applications. It focuses on query processing and maintaining data
integrity in multi-access environments. Examples include banking systems, order entry
systems.
- **OLAP (Online Analytical Processing)**: Systems designed for analysis and reporting,
typically used for data mining and business intelligence. It focuses on complex queries and
data aggregation. Examples include data warehouses and decision support systems.

17. **Explain the concept of a database schema.**


- **Answer**: A database schema is a blueprint or architecture of a database that defines
the way data is organized and how relationships among them are associated. It includes
definitions of tables, columns, data types, indexes, views, and procedures.

18. **What is denormalization, and why is it used?**


- **Answer**: Denormalization is the process of combining tables to reduce the complexity
of joins and improve read performance. It is used in situations where read performance is
critical, even at the cost of data redundancy.

19. **What is a cursor in SQL?**


- **Answer**: A cursor is a database object used to retrieve, manipulate, and navigate
through a result set one row at a time. Cursors are used when row-by-row processing is
required, which cannot be accomplished using SQL set operations alone.

20. **What is a view in a database?**


- **Answer**: A view is a virtual table based on the result of a SQL query. It contains rows
and columns just like a real table but does not store data physically. Views can simplify
complex queries, enhance security by restricting access to specific data, and present data in
a particular format.

21. **What are database locks, and what types are there?**
- **Answer**: Database locks are mechanisms to manage concurrent access to database
resources, ensuring data integrity and consistency. Types include:
- **Shared Lock (S)**: Allows concurrent read access but prevents writes.
- **Exclusive Lock (X)**: Prevents both read and write access by others.
- **Update Lock (U)**: Used to prevent deadlock situations during updates.

22. **What is a transaction log?**


- **Answer**: A transaction log is a file that records all transactions and modifications
made to the database. It ensures that the database can be restored to a consistent state in
case of a system failure by replaying or rolling back transactions.
23. **What is an index scan and a table scan?**
- **Answer**:
- **Index Scan**: Involves searching through an index to find the desired rows. It's
efficient when searching a small number of rows.
- **Table Scan**: Involves scanning all rows in a table to find the desired rows. It's
generally less efficient and used when no appropriate index is available.

24. **Explain the concept of referential integrity.**


- **Answer**: Referential integrity ensures that relationships between tables remain
consistent. It means that a foreign key in one table must always refer to a valid, existing
primary key in another table. If a record in the parent table is deleted or updated,
corresponding changes must be made to related records in the child table.

25. **What is database sharding?**


- **Answer**: Database sharding is a technique of partitioning a large database into
smaller, more manageable pieces called shards. Each shard is stored on a separate
database server to improve performance, manageability, and availability.

26. **What is the purpose of a sequence in a database?**


- **Answer**: A sequence is a database object that generates a sequence of unique
numeric values, often used for auto-incrementing primary keys. It ensures that unique
identifiers can be created without conflict or duplication.

27. **What is the difference between UNION and UNION ALL?**


- **Answer**:
- **UNION**: Combines the results of two queries and removes duplicate rows from the
result set.
- **UNION ALL**: Combines the results of two queries without removing duplicates,
which can be faster as it does not require duplicate-checking.

28. **What are materialized views, and how do they differ from regular views?**
- **Answer**: Materialized views are views that store the result of the query physically,
providing faster access to data compared to regular views which always compute the data
dynamically. They are used to enhance performance by storing precomputed results.

29. **What is a deadlock, and how can it be resolved?**


- **Answer**: A deadlock occurs when two or more transactions are waiting for each other
to release resources, causing all involved transactions to halt indefinitely. Deadlock
resolution strategies include:
- **Deadlock Prevention**: Implementing strategies to avoid circular wait conditions.
- **Deadlock Detection and Recovery**: Regularly checking for deadlocks and rolling
back one or more transactions to break the cycle.

30. **What are the different isolation levels in SQL?**


- **Answer**: Isolation levels define the degree to which transactions are isolated from
each other. The common isolation levels are:
- **Read Uncommitted**: Lowest level, allows reading uncommitted changes.
- **Read Committed**: Default level, prevents reading uncommitted changes.
- **Repeatable Read**: Ensures that if a transaction reads a row, it can read that same
row again with the same value.
- **Serializable**: Highest level, ensures complete isolation by locking the entire data set,
preventing other transactions from making changes.

These questions cover a broader range of DBMS concepts, including advanced features and
techniques used in managing and optimizing databases.

You might also like