0% found this document useful (0 votes)
4 views19 pages

DBMS Questions

The document contains a series of interview questions and answers related to Database Management Systems (DBMS). It covers topics such as the advantages of DBMS, key concepts like primary and foreign keys, normalization, SQL commands, and the differences between various database elements. Additionally, it discusses advanced topics like triggers, stored procedures, transactions, and indexing, providing a comprehensive overview for DBMS interviews.

Uploaded by

Ajit s Adin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views19 pages

DBMS Questions

The document contains a series of interview questions and answers related to Database Management Systems (DBMS). It covers topics such as the advantages of DBMS, key concepts like primary and foreign keys, normalization, SQL commands, and the differences between various database elements. Additionally, it discusses advanced topics like triggers, stored procedures, transactions, and indexing, providing a comprehensive overview for DBMS interviews.

Uploaded by

Ajit s Adin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

TOP 50 QUESTIONS:

https://www.edureka.co/blog/interview-questions/dbms-interview-questions

https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions-
set-2/?ref=asr1
Interviewer: What are the advantages of DBMS over traditional file-based
systems?

Interviewee: A Database Management System (DBMS) addresses many of the limitations


associated with traditional file-based systems. Here’s how:

1. Data Redundancy and Inconsistency: Unlike traditional systems where the same
data might be duplicated across multiple files, DBMS centralizes data, ensuring
minimal redundancy and consistency across the system.
2. Easier Data Access: DBMS provides query languages like SQL, making data
retrieval simpler and more efficient compared to manually scanning files.
3. Data Isolation: Traditional systems often store data in different formats across
separate files. DBMS integrates these, offering a unified format for easier
manipulation.
4. Integrity Maintenance: DBMS enforces data integrity through constraints, ensuring
valid and accurate data.
5. Atomicity of Updates: It ensures that a transaction is either fully completed or fully
rolled back, maintaining data consistency during failures.
6. Concurrent Access: DBMS allows multiple users to access and manipulate the same
data concurrently while ensuring data consistency.
7. Enhanced Security: DBMS includes robust security mechanisms like user
authentication, authorization, and role-based access control.

Interviewer: Can you explain super, primary, candidate, and foreign keys?

Interviewee: Sure!

1. Super Key:
A super key is a combination of one or more attributes that can uniquely identify a
row in a table. For example, in a student database, attributes like {StudentID,
Email} together can act as a super key.
2. Candidate Key:
It’s a minimal super key, meaning no attribute in it can be removed without losing the
ability to uniquely identify a row. For instance, if StudentID alone is sufficient to
identify a row, it’s a candidate key.
3. Primary Key:
A primary key is a specific candidate key chosen to uniquely identify rows in a table.
It must be unique and cannot contain NULL values. Each table can have only one
primary key.
4. Foreign Key:
A foreign key in one table is a reference to the primary key in another table. It
establishes a relationship between the two tables. For example, in an Order table, the
CustomerID might act as a foreign key referencing the Customer table.
Interviewer: What is the difference between a primary key and a unique
constraint?

Interviewee: Both ensure uniqueness, but there are key differences:

 Primary Key:
o Ensures that a column or a set of columns is unique and cannot have NULL
values.
o There can only be one primary key in a table.
 Unique Constraint:
o Ensures uniqueness but allows NULL values (although NULL values are
treated as distinct).
o A table can have multiple unique constraints on different columns.

Interviewer: What is database normalization?

Interviewee:
Normalization is the process of structuring a database to reduce redundancy and improve data
integrity. It involves decomposing larger tables into smaller ones and defining relationships
between them.

The primary goals are:

1. Minimizing Redundancy: Eliminates duplicate data, saving storage and reducing


inconsistencies.
2. Reducing Anomalies: Prevents insertion, deletion, and update anomalies, ensuring
data reliability.

For example, in a student-course database, separating Student and Course into different
tables with a relationship avoids storing the same course data repeatedly.

Interviewer: Why is the use of DBMS recommended?

Interviewee:
DBMS offers several advantages over traditional systems:

1. Controlled Redundancy: Centralized data storage reduces duplication.


2. Data Sharing: Multiple users and applications can simultaneously access the same
data.
3. Backup and Recovery: Automated processes ensure data is recoverable in case of
failures.
4. Integrity Constraints: Validates data with rules like foreign keys or unique
constraints.
5. Data Independence: Changes in database structure do not affect application
programs.
These features make DBMS a robust and efficient tool for data management.

Interviewer: Can you differentiate DDL, DML, and DCL in SQL?

Interviewee:

1. DDL (Data Definition Language):


Commands like CREATE, ALTER, DROP define or modify database schema.
Example: Creating a table with CREATE TABLE Students.
2. DML (Data Manipulation Language):
Commands like SELECT, INSERT, UPDATE, DELETE handle data operations.
Example: Retrieving data with SELECT * FROM Students.
3. DCL (Data Control Language):
Commands like GRANT and REVOKE control permissions for database access.
Example: Granting access with GRANT SELECT ON Students TO User.

Interviewer: What’s the difference between the HAVING and WHERE


clauses?

Interviewee:

 WHERE Clause: Filters rows before grouping. It applies conditions to individual


rows.
 HAVING Clause: Filters rows after grouping. It applies conditions to grouped data
or aggregate functions.

Example:

sql
Copy code
SELECT Department, COUNT(*)
FROM Employees
WHERE Salary > 50000 -- Applies to individual rows
GROUP BY Department
HAVING COUNT(*) > 5; -- Applies to grouped data

Interviewer: How can you print duplicate rows in a table?

Interviewee:
To find duplicates, you can use a query with GROUP BY and HAVING clauses. For instance:

sql
Copy code
SELECT ColumnName, COUNT(*)
FROM TableName
GROUP BY ColumnName
HAVING COUNT(*) > 1;
This shows rows with duplicate values in ColumnName.

Interviewer: What is a Join in SQL?

Interviewee:
A join combines data from two or more tables based on a common field. For example,
consider:

Student Table:

EnrollNo StudentName Address

StudentCourse Table:
| CourseID | EnrollNo |

An inner join retrieves students with course details:

sql
Copy code
SELECT StudentCourse.CourseID, Student.StudentName
FROM StudentCourse
INNER JOIN Student
ON StudentCourse.EnrollNo = Student.EnrollNo;

Interviewer: What is an identity column?

Interviewee:
An identity column auto-generates unique numeric values for new rows. By default, it starts
at 1 and increments by 1.

Example:

sql
Copy code
CREATE TABLE Employees (
ID INT IDENTITY(1,1),
Name VARCHAR(50)
);

This ensures each row has a unique ID value without manual input.

Interviewer: What is a view in SQL?

Interviewee:
A view is a virtual table created from the result of a query. It doesn’t store data itself but
provides a simplified way to access data.
Example:

sql
Copy code
CREATE VIEW ActiveStudents AS
SELECT * FROM Students WHERE Status = 'Active';

You can use the view as if it’s a table:

sql
Copy code
SELECT * FROM ActiveStudents;

Interviewer: What is a trigger?

Interviewee: A trigger is a special type of stored procedure that is automatically executed in


response to specific events on a table, such as INSERT, UPDATE, or DELETE. Triggers are
primarily used to enforce business rules, maintain data integrity, and perform actions
automatically when a specific operation occurs in the database. For example, if we want to
log every deletion in a table, we can create a trigger for the DELETE operation to insert details
into a log table.

Interviewer: What is a stored procedure?

Interviewee: A stored procedure is a precompiled set of SQL statements that can be executed
as a single unit. It is essentially a function stored in the database, designed to perform specific
tasks, like retrieving or modifying data. Stored procedures help improve performance by
reducing network traffic and reusing code. For example, if an application frequently needs to
calculate the total sales for a given product, a stored procedure can encapsulate the SQL logic
for this task, allowing it to be executed efficiently with a single call.

Interviewer: What is the difference between a trigger and a stored procedure?

Interviewee: The main difference is in how they are invoked:

 Stored Procedures are explicitly called by the user or an application. For example,
you can execute a stored procedure using a SQL command like EXEC
procedureName.
 Triggers, on the other hand, are automatically executed in response to specific
database events (e.g., INSERT, UPDATE, or DELETE) and cannot be directly invoked.

Triggers are more event-driven, while stored procedures are user-driven.


Interviewer: What is a transaction? What are ACID properties?

Interviewee: A transaction is a sequence of one or more database operations that are


executed as a single unit of work. The key principle of a transaction is that all operations
must succeed or none of them will take effect, ensuring data integrity. For example,
transferring money from one bank account to another involves two operations: debiting one
account and crediting another. Both operations must succeed for the transaction to be
completed.

The ACID properties ensure the reliability of database transactions:

1. Atomicity: Ensures that a transaction is all-or-nothing.


2. Consistency: Guarantees that a transaction transforms the database from one valid
state to another.
3. Isolation: Ensures that concurrently executed transactions do not interfere with each
other.
4. Durability: Ensures that once a transaction is committed, it remains so, even in the
event of a system failure.

Interviewer: What are indexes in a database?

Interviewee: An index is a data structure that enhances the speed of data retrieval operations
on a database table. Without indexes, the database has to scan the entire table to locate the
required data, which can be slow, especially for large tables.

Indexes are like a book’s index, where you can quickly find a topic by looking it up in the
index rather than searching through every page. However, maintaining indexes requires
additional storage and can slow down INSERT, UPDATE, and DELETE operations due to the
overhead of keeping the index up-to-date.

Interviewer: Can you explain clustered and non-clustered indexes?

Interviewee: Sure!

 Clustered Index:
A clustered index determines the physical order of data in a table. There can be only
one clustered index per table because data can only be physically ordered in one way.
For example, if you create a clustered index on the ID column, the rows will be stored
on the disk in the order of the ID values.
 Non-clustered Index:
A non-clustered index creates a separate data structure that provides a logical order
for the data. The data itself remains stored in its original order, and the index contains
pointers to the data. For example, a non-clustered index on a Name column will
maintain a sorted list of names and point to the corresponding rows in the table.
Interviewer: What is denormalization?

Interviewee: Denormalization is a database optimization technique where redundancy is


intentionally introduced into a database design. This is done to improve read performance by
reducing the number of joins required for queries.

For example, in a normalized database, customer information might be stored in one table,
and order information in another, requiring a join to retrieve customer orders. In a
denormalized design, customer data might be included in the orders table itself, making it
faster to retrieve but increasing storage requirements.

Interviewer: What is a clause in SQL?

Interviewee: A clause in SQL is a part of a query that modifies or filters the data being
retrieved. Clauses are used to customize query results. For example:

 The WHERE clause filters rows based on a condition.


 The ORDER BY clause sorts the results.
 The GROUP BY clause groups rows with the same values into summary rows.

For instance:

sql
Copy code
SELECT * FROM employees WHERE department = 'HR';

Here, WHERE department = 'HR' is the clause that filters the results to only include
employees in the HR department.

Interviewer: What is a livelock?

Interviewee: A livelock occurs when two or more processes continuously change their states
in response to each other but fail to make any progress. Unlike a deadlock, where processes
are stuck waiting for each other indefinitely, in a livelock, processes are actively running but
unable to accomplish their goals.

For example, imagine two people trying to avoid each other in a hallway: they both move
left, then right, then left again, but neither is able to pass. Similarly, in a database, processes
might keep retrying operations due to conflicts without ever completing them.

Let me know if you need further elaboration or examples!


Interviewer: What is QBE?

Interviewee: QBE, or Query-By-Example, is a graphical or visual approach for querying


databases. Instead of writing complex SQL statements, users can use query templates, called
skeleton tables, to visually specify the information they want. Example values are entered
directly into these templates, allowing users to construct queries without needing
programming knowledge.

QBE has two distinct features:

1. It uses a two-dimensional syntax, so queries resemble tables.


2. It simplifies database access for users unfamiliar with query languages.

For example, in many personal database systems, you can filter and retrieve data using a
point-and-click interface rather than writing SQL commands.

Interviewer: Why are cursors necessary in embedded SQL?

Interviewee: Cursors are essential in embedded SQL because they act as a pointer to a result
set and allow row-by-row processing. While SQL operations typically work on entire
datasets, many host programming languages (e.g., C, Java) operate one row at a time.

For example, if a query returns multiple rows, a cursor enables the program to navigate
through these rows one at a time. This is especially useful for applications that need to
process or manipulate individual rows dynamically, like generating reports or updating
records based on specific conditions.

Interviewer: What is the purpose of normalization in DBMS?

Interviewee: Normalization in a database is the process of organizing data to minimize


redundancy and improve integrity.

Key purposes include:

1. Eliminating duplicate data to save storage space.


2. Reducing anomalies like insertion, deletion, and update issues.
3. Structuring large tables into smaller related tables and establishing relationships
between them.

For example, instead of storing customer details redundantly in multiple order records,
normalization separates customer data into a dedicated table linked to orders via a unique
identifier.
Interviewer: What is the difference between a database schema and a
database state?

Interviewee: The database schema is the blueprint or structure of a database, defining its
tables, columns, data types, and relationships. It is static and remains the same over time
unless modified by the database administrator.

The database state, on the other hand, represents the data stored in the database at a
particular point in time. It is dynamic and changes as data is inserted, updated, or deleted.

For example:

 Schema: Defines that a table Employee has columns ID, Name, and Department.
 State: Contains the actual rows like (1, 'John', 'HR') and (2, 'Jane',
'Finance').

Interviewer: What is the purpose of SQL?

Interviewee: SQL, or Structured Query Language, is used to interact with relational


databases. It enables users to perform various operations like:

1. Inserting new data into a table.


2. Retrieving specific data using queries.
3. Updating existing data.
4. Deleting data or entire database objects like tables.

In short, SQL provides a standard way to manage and manipulate data stored in relational
database systems.

Interviewer: Can you explain the concepts of a Primary Key and a Foreign
Key?

Interviewee: Sure!

 A Primary Key uniquely identifies each record in a database table. It cannot contain
NULL values and ensures that every row is distinct.
 A Foreign Key establishes a link between two tables by referencing the primary key
of another table.

For example:
If we have an Employee table with a primary key EmployeeID and a Department table with a
primary key DepartmentID, the Employee table might have a DepartmentID column that
acts as a foreign key linking it to the Department table.
This relationship ensures data consistency and enables us to associate employees with their
respective departments.

Interviewer: What are the main differences between a Primary Key and a
Unique Key?

Interviewee: The main differences are:

1. A Primary Key cannot have NULL values, while a Unique Key can contain one NULL
value.
2. Each table can have only one Primary Key, but it can have multiple Unique Keys.

Both are used to enforce uniqueness in a column, but primary keys are specifically used for
identifying rows in a table.

Interviewer: What is the concept of a sub-query in SQL?

Interviewee: A sub-query is a query nested inside another query. It is also called an inner
query and is used to provide results to the outer query.

For example:

sql
Copy code
SELECT Name
FROM Employees
WHERE DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name =
'HR');

Here, the inner query finds the DepartmentID for 'HR', and the outer query retrieves the
employees in that department.

Sub-queries are useful for complex queries requiring intermediate calculations or conditions.

Interviewer: What is the use of the DROP command? What are the
differences between DROP, TRUNCATE, and DELETE?

Interviewee:

 The DROP command permanently deletes a database object, such as a table or


database, along with its data and structure. It is a DDL command and cannot be rolled
back.
 TRUNCATE removes all rows from a table but retains the table structure. It is also a
DDL command and operates faster than DELETE.
 DELETE removes specific rows from a table based on a condition. It is a DML
command and can be rolled back using ROLLBACK.

Example Differences:

1. DROP TABLE Employees; permanently deletes the Employees table.


2. TRUNCATE TABLE Employees; clears all data but keeps the table structure intact.
3. DELETE FROM Employees WHERE Department = 'HR'; deletes only employees
from the HR department.

Interviewer: What is the main difference between UNION and UNION ALL?

Interviewee: Both UNION and UNION ALL combine results from two or more queries.

 UNION eliminates duplicate rows from the result set, ensuring all rows are unique.
 UNION ALL includes all rows, even duplicates, providing faster performance as no
duplicate check is performed.

For example:
If two tables have overlapping data, UNION returns only distinct rows, while UNION ALL
returns all rows, including duplicates.

Interviewer: What is a Correlated Subquery in DBMS?

Interviewee: A correlated subquery is a type of subquery where the inner query is executed
for each row processed by the outer query. Unlike a normal subquery, which runs
independently of the outer query, a correlated subquery refers to columns of the outer query
in its condition. This means that the subquery is evaluated repeatedly for each row returned
by the outer query.

For example:

sql
Copy code
SELECT * FROM EMP E
WHERE EXISTS (SELECT 1 FROM DEPT D WHERE D.EMPID = E.EMPID);

In this case, the subquery checks each employee (E) to see if there is a matching EMPID in the
DEPT table, making it correlated.

Interviewer: Can you explain the terms Entity, Entity Type, and Entity Set in DBMS?

Interviewee: Sure! In a DBMS:


 Entity refers to any object or thing in the real world that has an independent existence
and can be represented by data in the database. For example, a Student or a Book is
an entity.
 Entity Type is a collection of entities that share the same attributes. For instance, the
STUDENT table can be an entity type where each record represents a student and has
attributes like Name, Age, ID, etc.
 Entity Set is simply a collection of entities of the same type. For example, the set of
all students in a university can be considered an entity set, where each student is an
individual entity.

Interviewer: What are the different levels of abstraction in DBMS?

Interviewee: There are three primary levels of abstraction in DBMS:

1. Physical Level: This level deals with how data is stored on the hardware. It’s about
the low-level details like file storage, indexing, etc.
2. Logical Level: This level defines what data is stored in the database and the
relationships between the data. It focuses on how the data is logically structured, such
as tables and their columns.
3. View Level: This is the highest level, where users interact with the database. It only
shows relevant parts of the database to the user based on their access needs. For
example, a user might only see a subset of columns or rows, not the entire database.

Interviewer: What integrity rules exist in DBMS?

Interviewee: There are two key integrity rules in DBMS:

1. Entity Integrity: This rule ensures that every table has a primary key, and that
primary key values must be unique and non-null. This prevents duplicate or
incomplete records from being inserted into the table.
2. Referential Integrity: This rule ensures that foreign keys in a table either point to a
valid primary key in another table or are null. It helps maintain consistency between
related tables, ensuring that relationships between them remain valid.

Interviewer: What is the E-R model in DBMS?

Interviewee: The Entity-Relationship (E-R) Model is a conceptual framework used to


design databases. It represents entities (objects) in the real world and the relationships
between them. An entity is any object or thing that has data stored about it, and a
relationship shows how two or more entities are associated with each other.

For example, in an E-R diagram, a Student might be related to a Course, and the relationship
might be "enrolled in." Each entity will have attributes, such as Name, Age, and ID for the
Student.
Interviewer: What is a Functional Dependency in DBMS?

Interviewee: A functional dependency describes a relationship between two attributes in a


table, where one attribute (or set of attributes) uniquely determines another attribute. For
instance, if you have a table with attributes StudentID and StudentName, StudentID
functionally determines StudentName, because each StudentID corresponds to only one
StudentName.

For example:

rust
Copy code
StudentID -> StudentName

This means knowing the StudentID allows you to determine the StudentName.

Interviewer: Can you explain the different Normal Forms in DBMS, starting with 1NF?

Interviewee: Yes! Let’s start with First Normal Form (1NF). A table is in 1NF if:

 All columns contain atomic (indivisible) values.


 There are no repeating groups or arrays within columns.

For example, if you have a table where a column holds multiple values (like a list of phone
numbers), that’s not in 1NF. You would need to break that column down so each entry has a
single value.

Interviewer: How about the Second Normal Form (2NF)?

Interviewee: Second Normal Form (2NF) builds on 1NF. A table is in 2NF if:

1. It is in 1NF.
2. Every non-prime attribute is fully dependent on the entire primary key.

For example, if a table has a composite primary key, all non-key attributes must depend on
both parts of that key. If an attribute depends only on one part of the composite key, the table
is not in 2NF.

Interviewer: What is Third Normal Form (3NF)?

Interviewee: A table is in Third Normal Form (3NF) if:


1. It is in 2NF.
2. No non-prime attribute is transitively dependent on the primary key. In simpler terms,
non-prime attributes (attributes that are not part of the primary key) should depend
only on the primary key, not on other non-prime attributes.

For example, if you have a table with StudentID, CourseID, and InstructorName, where
InstructorName depends on CourseID, that would be a transitive dependency. To bring it to
3NF, you would need to separate InstructorName into a different table.

Interviewer: Can you explain Boyce-Codd Normal Form (BCNF)?

Interviewee: Boyce-Codd Normal Form (BCNF) is a stricter version of 3NF. A table is in


BCNF if:

1. It is in 3NF.
2. For every functional dependency X -> Y, X must be a superkey.

This means that even if a table is in 3NF, it may not be in BCNF if any functional
dependency exists where the determinant (X) is not a superkey. BCNF ensures the highest
level of normalization and eliminates potential redundancy and anomalies.

Interviewer: What is a CLAUSE in SQL?

Interviewee: A clause in SQL is a part of a query that specifies certain conditions or


operations to be applied on the data. Common SQL clauses include:

 WHERE: Filters records based on a specified condition.


 HAVING: Filters groups of records based on a condition, often used with aggregate
functions.
 ORDER BY: Sorts the result set by specified columns.

For example, in the query:

sql
Copy code
SELECT * FROM EMPLOYEES WHERE SALARY > 50000;

The WHERE clause is used to filter the employees whose salary is greater than 50,000.

Interviewer: How can you retrieve alternate records from a table in SQL?

Interviewee: To retrieve alternate records from a table, you can use the ROWNUM or
ROW_NUMBER() function along with the MOD operator to differentiate between odd and even
rows.
For odd-numbered records (1st, 3rd, 5th, etc.), the query would look like this:

sql
Copy code
SELECT EmpId FROM (
SELECT ROW_NUMBER() OVER (ORDER BY EmpId) AS rowno, EmpId
FROM Emp
) WHERE MOD(rowno, 2) = 1;

For even-numbered records (2nd, 4th, 6th, etc.), you can adjust the condition like this:

sql
Copy code
SELECT EmpId FROM (
SELECT ROW_NUMBER() OVER (ORDER BY EmpId) AS rowno, EmpId
FROM Emp
) WHERE MOD(rowno, 2) = 0;

Interviewer: How is pattern matching done in SQL?

Interviewee: In SQL, pattern matching is done using the LIKE operator. The LIKE operator
allows us to match specific patterns in string data.

 The % symbol represents zero or more characters.


 The _ symbol represents a single character.

For example:

 To find employees whose name starts with "b":

sql
Copy code
SELECT * FROM Emp WHERE name LIKE 'b%';

 To find employees whose name is four characters long and starts with "hans":

sql
Copy code
SELECT * FROM Emp WHERE name LIKE 'hans_';

Interviewer: Can you explain what a JOIN is in SQL?

Interviewee: A JOIN in SQL is used to combine rows from two or more tables based on a
related column between them. The common column or field is usually a key that exists in
both tables. There are different types of joins that help you retrieve data in various ways.

Interviewer: What are the different types of joins in SQL?

Interviewee: There are four main types of joins in SQL:

1. INNER JOIN: Retrieves only the rows where there is a match in both tables. If no
match is found, those rows are not returned.
sql
Copy code
SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;

2. LEFT JOIN (or LEFT OUTER JOIN): Retrieves all rows from the left table, and
matching rows from the right table. If there is no match, NULL values are returned
for columns from the right table.

sql
Copy code
SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id;

3. RIGHT JOIN (or RIGHT OUTER JOIN): Retrieves all rows from the right table,
and matching rows from the left table. If there is no match, NULL values are returned
for columns from the left table.

sql
Copy code
SELECT * FROM table1 RIGHT JOIN table2 ON table1.id = table2.id;

4. FULL JOIN (or FULL OUTER JOIN): Retrieves all rows from both tables. If there
is no match, NULL values are returned for the columns from the missing table.

sql
Copy code
SELECT * FROM table1 FULL JOIN table2 ON table1.id = table2.id;

Interviewer: Can you explain what a Stored Procedure is?

Interviewee: A Stored Procedure is a group of SQL statements stored in the database that
can be executed as a single unit. It is stored in the database and can be reused whenever
needed. A stored procedure allows for encapsulating logic in the database, improving
performance, and reducing the need for repeated code.

For example, a stored procedure might insert a new employee into the Emp table:

sql
Copy code
CREATE PROCEDURE AddEmployee (IN emp_name VARCHAR(100), IN emp_age INT)
BEGIN
INSERT INTO Emp (name, age) VALUES (emp_name, emp_age);
END;

Interviewer: What is RDBMS?

Interviewee: An RDBMS (Relational Database Management System) is a database


management system that uses a relational model to store and manage data. Data is stored in
tables, and relationships between tables are defined using keys. Examples of RDBMS include
MySQL, PostgreSQL, and Oracle.

Interviewer: What are the different types of relationships in DBMS?


Interviewee: In DBMS, relationships describe how tables are linked. The three primary types
are:

1. One-to-One: One record in a table is associated with only one record in another table.
Example: A Person table and a Passport table where each person has one passport.
2. One-to-Many: One record in a table is associated with multiple records in another
table. Example: A Department table with multiple employees in the Employee table.
3. Many-to-Many: Multiple records in one table are associated with multiple records in
another table. Example: A Student table and a Course table where students can
enroll in many courses, and courses can have many students. This is typically
implemented with a junction table.

Interviewer: What do you mean by Entity Type Extension?

Interviewee: Entity Type Extension refers to the process of grouping similar entities into
one entity type, which is then grouped into an entity set. This extension allows for more
efficient organization and management of data.

Interviewer: Can you explain what conceptual design is in DBMS?

Interviewee: Conceptual Design is the process of designing a database that is independent


of any physical constraints or database software. It focuses on defining the high-level
structure of the database, including the entities, their attributes, and the relationships between
them, without worrying about how the data will be physically stored or accessed. The result
is a conceptual model, often represented as an Entity-Relationship (ER) diagram.

Interviewer: Can you differentiate between logical database design and


physical database design? How does this separation lead to data
independence?

Interviewee:

 Logical Database Design: This focuses on the high-level structure of the database. It
defines entities, relationships, and constraints without regard to how the data will be
physically stored or accessed. It results in a conceptual model or schema.
 Physical Database Design: This phase defines how the data will actually be stored,
including indexing, file organization, and record placement.

This separation leads to data independence, meaning that changes made in the physical
database design (such as changing the storage structure) do not affect the logical schema. As
a result, the logical design remains independent of physical storage details.

Interviewer: What are temporary tables? When are they useful?

Interviewee: Temporary Tables are used to store intermediate results during a session or
transaction. They exist only for the duration of the session or transaction and are
automatically dropped when the session ends. These tables are useful for complex queries
where intermediate results are needed, such as when performing calculations or aggregating
data.
In Oracle, you can create a temporary table with:

sql
Copy code
CREATE GLOBAL TEMPORARY TABLE temp_table (...);

Interviewer: Can you explain the different types of failures in Oracle


databases?

Interviewee: There are several types of failures in Oracle databases:

1. Statement Failure: Caused by issues like bad data types, insufficient space, or lack
of privileges.
2. User Process Failure: Occurs when a user’s session is abnormally terminated or
disconnected.
3. User Error: Happens when a user unintentionally drops a table or modifies data
incorrectly.
4. Instance Failure: Occurs when the Oracle instance crashes, affecting all sessions.
5. Media Failure: Happens when physical storage, like a disk or drive, fails.
6. Alert Logs: Record error and informational messages about database failures.

Interviewer: What is the main goal of RAID technology?

Interviewee: The main goal of RAID (Redundant Array of Inexpensive Disks) technology
is to combine multiple hard drives into a single logical unit to improve data redundancy, fault
tolerance, and performance. It helps in increasing throughput and providing fault tolerance by
duplicating data across multiple disks. RAID allows for continued operation even in the case
of disk failure.

RAID can be implemented in various configurations, such as RAID 1 (mirroring) and RAID
5 (striping with parity).

4o mini

You might also like