DBMS Interview Questions
DBMS Interview Questions
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/12
30. What are views in SQL, and how are they different from tables?
31. What are materialized views?
32. Explain NoSQL databases and their types.
33. What is the difference between SQL and NoSQL?
34. What is CAP theorem in distributed databases?
35. What is eventual consistency?
36. What is database replication, and what are its types?
Here are the answers to all 47 DBMS interview questions with examples:
A DBMS is software that allows users to create, manage, and manipulate databases efficiently. It
provides tools to store, retrieve, update, and delete data.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/12
2. Network DBMS – Uses a graph structure with multiple parent-child relationships.
Example: Integrated Data Store (IDS).
3. Relational DBMS (RDBMS) – Uses tables to store data with relationships.
Example: MySQL, PostgreSQL.
4. Object-Oriented DBMS – Stores data as objects, similar to OOPs.
Example: ObjectDB, db4o.
A primary key is a column (or set of columns) that uniquely identifies each row in a table.
Example:
sql
A foreign key is a column in one table that refers to the primary key of another table.
Example:
sql
sql
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/12
Email VARCHAR(100),
PhoneNumber VARCHAR(15),
PRIMARY KEY (EmpID),
UNIQUE (Email, PhoneNumber)
);
A composite key is a combination of two or more columns that uniquely identifies a row.
Example:
sql
A super key is a set of one or more columns that uniquely identifies a row.
A unique key ensures all values in a column are unique but allows NULL values.
Example:
sql
Example:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/12
sql
sql
-- DDL Example
CREATE TABLE Users (UserID INT PRIMARY KEY, Name VARCHAR(50));
-- DML Example
INSERT INTO Users VALUES (1, 'John');
-- DCL Example
GRANT SELECT ON Users TO 'user1';
-- TCL Example
BEGIN TRANSACTION;
UPDATE Users SET Name='Alice' WHERE UserID=1;
COMMIT;
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/12
15. What is Denormalization?
sql
SELECT MAX(Salary) FROM Employees WHERE Salary < (SELECT MAX(Salary) FROM Employees);
sql
SELECT Name, COUNT(*) FROM Students GROUP BY Name HAVING COUNT(*) > 1;
sql
sql
Would you like detailed answers for a specific question, or should I continue answering all in detail?
A transaction is a unit of work that is executed as a whole. It consists of multiple operations that must
be executed entirely or not at all.
Example:
sql
BEGIN TRANSACTION;
UPDATE Accounts SET Balance = Balance - 500 WHERE AccountID = 1;
UPDATE Accounts SET Balance = Balance + 500 WHERE AccountID = 2;
COMMIT;
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/12
4. Serializable: Highest isolation level, prevents all inconsistencies.
sql
A deadlock occurs when two transactions wait indefinitely for each other to release locks.
Prevention Techniques:
sql
Sharding is splitting a large database into smaller, manageable parts across different servers to
improve scalability.
Partitioning divides a database into smaller pieces based on a criterion like range or hash.
sql
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 8/12
30. What are Views in SQL?
sql
sql
Types:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 9/12
In distributed databases, eventual consistency ensures data synchronizes over time instead of
immediately.
Example: DNS updates across servers.
Types:
Master-Slave Replication
Multi-Master Replication
sql
A trigger is an automatic action executed before/after events like INSERT, UPDATE, DELETE.
sql
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 10/12
Cascading DELETE: Deleting a record deletes dependent records.
Cascading UPDATE: Updating a primary key updates foreign keys.
sql
sql
Example:
Use Indexing
**Avoid SELECT ***
Use Joins efficiently
sql
bash
This completes all 47 DBMS questions with detailed answers and examples. Would you like further
explanations on any specific question? 🚀
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 12/12