Dbms Viva Questions
Dbms Viva Questions
DBMS RDBMS
Provides an organized way of managing,
Provides the same as that of DBMS, but
retrieving, and storing from a collection of
it provides relational integrity
logically related information
Q2. Explain the terms database and DBMS. Also, mention the different
types of DBMS.
• Sharing of Data: Multiple users can use data from the same database
simultaneously.
• Integrity constraints: These constraints allow the data to be stored in a
database in a refined manner.
• Redundancy control: Supports a mechanism to control the redundancy of
data by integrating all the data into a single database.
• Data Independence: Allows to change the structure of the data without
affecting the structure of any of the running application programs.
• Provide backup and recovery facility: Provides a feature of ‘backup and
recovery’ to automatically create the data backup and restore the data as and
when required.
Query optimization is the phase that identifies a plan for evaluation query that has
the least estimated cost. This phase comes into the picture when there are a lot of
algorithms and methods to execute the same task.
A NULL value is not at all same as that of zero or a blank space. The NULL value
represents a value which is unavailable, unknown, assigned or not applicable
whereas zero is a number and blank space is a character.
Aggregation Atomicity
This property states that a database
This is a feature of the E-R model which modification must either follow all the
allows a relationship set to participate in rules or nothing at all. So, if one part of
another relationship set. the transaction fails, then the entire
transaction fails.
Q8. What are the different levels of abstraction in the DBMS?
• Physical Level: It is the lowest level of abstraction and describes how the
data is stored.
• Logical Level: This is the next level of abstraction after the Physical level.
This layer determines what data is stored in the database, and what is the
relationship between the data points.
• View Level: The View Level is the highest level of abstraction and it
describes only a part of the entire database.
Q9. What is an entity-relationship model?
Q10. What do you understand by the terms Entity, Entity Type, and
Entity Set in DBMS?
• Entity: An entity is a real-world object having attributes, which are nothing but
characteristics of that particular object. For example, an employee can be an
entity. This particular entity can have attributes such as empid, empname, etc.
• Entity Type: Entity type is nothing but a collection of entities, having the
same attributes. Generally, an entity type refers to one or more related tables
in a particular database. So, you can understand, entity type as a
characteristic which uniquely identifies the entity. For example, An employee
can have attributes such as empid, empname, department, etc.
• Entity Set: An entity set is the collection of all the entities of a particular entity
type in a database. For example, a set of employees, a set of companies, and
a set of people can come under an entity set.
A relationship in DBMS is the scenario where two entities are related to each other.
In such a scenario, the table consisting of foreign key references to that of a primary
key of the other table.
The process of organizing data to avoid any duplication of data and redundancy is
known as Normalization. There are many successive levels of normalization which
are known as normal forms. Each consecutive normal form depends on the
previous one. The following are the first three normal forms. Apart from these, you
have higher normal forms such as BCNF.
There are mainly 7 types of Keys, that can be considered in a database. I am going
to consider the below tables to explain to you the various keys.
Fig 1: Different Types of Keys in Database – DBMS Interview Questions
A correlated subquery is also a sort of subquery reliant on another query. So, when
subqueries are executed for each of the rows of outer queries, then they are termed
as correlated subqueries. Each subquery is executed a single time for every row of
the outer query.
You can also understand correlated subqueries as those queries, which are used for
row-by-row processing by the parent statement. Here, the parent statement can be
SELECT, UPDATE or DELETE statement.
Data partitioning is the process of dividing a logical database into independent units
for the betterment of availability, performance, and manageability.
Example: Consider a relation “A1” having attributes X, Y and Z. Now, X->Z is said to
hold transitive dependency, only if the following functional dependencies holds true:
• X -> Y
• Y doesn’t ->X
• Y -> Z
Q20. Mention the differences between Unique Key and Primary Key
A checkpoint is a mechanism where all the previous logs are removed from the
system and are permanently stored on the storage disk. So, basically, checkpoints
are those points from where the transaction log record can be used to recover all the
committed data up to the point of crash.
Indexes are data structures responsible for improving the speed of data retrieval
operations on a table. This data structure uses more storage space to maintain extra
copies of data by using additional writes. So, indexes are mainly used for searching
algorithms, where you wish to retrieve data in a quick manner.
A cursor is a database object which helps in manipulating data, row by row and
represents a result set.
When you say an application has data independence, it implies that the application is
independent of the storage structure and data access strategies of data.
Q30. What are the different integrity rules present in the DBMS?
• Entity Integrity: This rule states that the value of the primary key can never
be NULL. So, all the tuples in the column identified as the primary key should
have a value.
• Referential Integrity: This rule states that either the value of the foreign key
is NULL or it should be the primary key of any other relation.
Q31. What does Fill Factor concept mean with respect to indexes?
Fill Factor is used to mention the percentage of space left on every leaf-level page,
which is packed with data. Usually, the default value is 100.
Q32. What is Index hunting and how does it help in improving query
performance?
The process of boosting a collection of indexes is known as Index hunting. This is
done as indexes improve the query performance and the speed at which they are
processed.
Deadlock is a situation which occurs when two transactions wait on a resource which
is locked or other transaction holds. Deadlocks can be prevented by making all the
transactions acquire all the locks at the same instance of time. So, once deadlock
occurs, the only way to cure is to abort one of the transactions and remove the
partially completed work.
Q35. What are the differences between an exclusive lock and a shared
lock?
SQL aka Structured Query Language is the core of the relational database which is
used for accessing and managing the databases. This language is used to
manipulate and retrieve data from a structured data format in the form of tables and
holds relationships between those tables. So, in layman terms, you can use SQL to
communicate with the database.
A subquery is a query inside another query where a query is defined to retrieve data
or information back from the database. In a subquery, the outer query is called as
the main query whereas the inner query is called subquery. Subqueries are always
executed first and the result of the subquery is passed on to the main query. It can
be nested inside a SELECT, UPDATE or any other query. A subquery can also use
any comparison operators such as >,< or =.
CLAUSE in SQL is used to limit the result set by mentioning a condition to the query.
So, you can use a CLAUSE to filter rows from the entire set of records.
HAVING WHERE
Used only with SELECT statement Used in a GROUP BY clause
Used with the GROUP BY function in a Applied to each row before they are a
query part of the GROUP BY function in a query
Note: Whenever GROUP BY is not used, HAVING behaves like a WHERE clause.
Q7. How can you perform pattern matching in SQL?
You can perform pattern matching in SQL by using the LIKE operator. With the LIKE
operator, you can use the following symbols:
Example:
Syntax: LOWER(‘string’)
Syntax: UPPER(‘string’)
INITCAP: This function returns the string with the first letter in uppercase and the
rest of the letters in lowercase.
Syntax: INITCAP(‘string’)
Q9. What are joins in SQL and what are the different types of joins?
A JOIN clause is used to combine rows from two or more tables, based on a related
column between them. It is used to merge two tables or retrieve data from there.
There are 4 joins in SQL namely:
• Inner Join
• Right Join
• Left Join
• Full Join
Q10. What do you understand by the view and mention the steps to
create, update and drop a view?
A view in SQL is a single table, which is derived from other tables. So, a view
contains rows and columns similar to a real table and has fields from one or more
table.
To create a view, use the following syntax:
Consider you have a table named Customers, having details such as CustomerID,
CustomerName and so on. Now, if you want to create a duplicate table named
‘DuplicateCustomer’ with the data present in it, you can mention the following query:
To write a query to calculate the even and odd records from a table, you can write
two different queries by using the MOD function.
So, if you want to retrieve the even records from a table, you can write a query as
follows:
To remove duplicate rows from a table, you have to initially select the duplicate rows
from the table without using the DISTINCT keyword. So, to select the duplicate rows
from the table, you can write a query as follows:
1 SELECT CustomerNumber FROM Customers WHERE ROWID (SELECT MAX (rowid) FROM Cu
Now, to delete the duplicate records from the Customers table, mention the following
query:
DELETE FROM Customers WHERE ROWID(SELECT MAX (rowid) FROM Customers C WHERE
1 CustomerNumber = C.CustomerNumber);
Q4. Mention a query to add email validation to your database
Well, there are multiple ways to add email validation to your database, but one out
the lot is as follows:
Q5. Write a query to retrieve the last day of next month in Oracle.
To write a query to retrieve the last day of the next month in Oracle, you can write a
query as follows: