DBMS Question
DBMS Question
9. What is Join?
An SQL Join is used to combine data from two or more tables, based on a
common field between them. For example, consider the following two tables.
Table – Student Table
EnrollNoStudentNameAddress
1000 geek1 geeksquiz1
1001 geek2 geeksquiz2
1002 geek3 geeksquiz3
Table – StudentCourse Table
CourseIDEnrollNo
1 1000
2 1000
3 1000
1 1002
2 1003
Following is a join query that shows the names of students enrolled in
different courseIDs.
SELECT StudentCourse.CourseID, Student.StudentName
FROM StudentCourse
INNER JOIN Student
ON StudentCourse.EnrollNo = Student.EnrollNo
ORDER BY StudentCourse.CourseID;
The above query would produce the following result.
CourseIDStudentName
1 geek1
1 geek3
2 geek1
3 geek1
9. What is Identity?
Identity (or AutoNumber) is a column that automatically generates numeric
values. A start and increment value can be set, but most DBA leave these at
1. A GUID column also generates numbers; the value of this cannot be
controlled. Identity/GUID columns do not need to be indexed.
10.What is a view in SQL? How to create a view?
A view is a virtual table based on the result-set of an SQL statement. We
can create using create view syntax.
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
11.What are the uses of view?
1. Views can represent a subset of the data contained in a table;
consequently, a view can limit the degree of exposure of the underlying
tables to the outer world: a given user may have permission to query the
view, while denied access to the rest of the base table.
2. Views can join and simplify multiple tables into a single virtual table.
3. Views can act as aggregated tables, where the database engine
aggregates data (sum, average, etc.) and presents the calculated results as
part of the data.
4. Views can hide the complexity of data.
5. Views take very little space to store; the database contains only the
definition of a view, not a copy of all the data which it presents.
6. Depending on the SQL engine used, views can provide extra security.
12. What is a Trigger?
A Trigger is a code associated with insert, update or delete operations. The
code is executed automatically whenever the associated query is executed
on a table. Triggers can be useful to maintain integrity in the database.
13. What is a stored procedure?
A stored procedure is like a function that contains a set of operations
compiled together. It contains a set of operations that are commonly used in
an application to do some common database tasks.
14. What is the difference between Trigger and Stored Procedure?
Unlike Stored Procedures, Triggers cannot be called directly. They can only
be associated with queries.
15. What is a transaction? What are ACID properties?
A Database Transaction is a set of database operations that must be treated
as a whole, which means either all operations are executed or none of
them. An example can be a bank transaction from one account to another
account. Either both debit and credit operations must be executed or none of
them. ACID (Atomicity, Consistency, Isolation, Durability) is a set of
properties that guarantee that database transactions are processed reliably.
The main difference between the Primary key and the Unique key is that the
Primary key can never have a null value while the Unique key may consist of
a null value.
In each table, there can be only one primary key while there can be more
than one unique key in a table.
28. What is the concept of sub-query in terms of SQL?
Sub-query is basically the query that is included inside some other query and
can also be called an inner query which is found inside the outer query.
29. What is the use of the DROP command and what are the differences
between DROP, TRUNCATE and DELETE commands?
DROP command is a DDL command which is used to drop/delete the
existing table, database, index, or view from the database.
The major difference between DROP, TRUNCATE and DELETE commands
are:
DROP and TRUNCATE commands are the DDL commands which are used
to delete tables from the database and once the table gets deleted, all the
privileges and indexes that are related to the table also get deleted. These 2
operations cannot be rolled back and so should be used only when
necessary.
DELETE command, on the other hand, is a DML Command which is also
used to delete rows from the table and this can be rolled back.
30. What is the main difference between UNION and UNION ALL?
UNION and UNION ALL are used to join the data from 2 or more tables but
UNION removes duplicate rows and picks the rows which are distinct after
combining the data from the tables whereas UNION ALL does not remove
the duplicate rows, it just picks all the data from the tables.
31. What is Correlated Subquery in DBMS?
A Subquery is also known as a nested query i.e. a query written inside some
query. When a Subquery is executed for each of the rows of the outer query
then it is termed as a Correlated Subquery.
An example of Non-Correlated Subquery is:
Here, the inner query is not executed for each of the rows of the outer query.
32. Explain Entity, Entity Type, and Entity Set in DBMS?
The entity is an object, place, or thing which has its independent existence in
the real world and about which data can be stored in a database. For
Example, any person, book, etc.
Entity Type is a collection of entities that have the same attributes. For
Example, the STUDENT table contains rows in which each row is an entity
holding the attributes like name, age, and id of the students, hence
STUDENT is an Entity Type that holds the entities having the same
attributes.
Entity Set is a collection of entities of the same type. For Example, A
collection of the employees of a firm.
33. What are the different levels of abstraction in the DBMS?
If you want to fetch the even numbers, then the following query can be used:
SELECT * from Emp
WHERE name like ‘hans_’;
The database design is divided into several phases. The logical database
design and physical database design are two of them. This separation is
generally based on the concept of the three-level architecture of DBMS,
which provides data independence. Therefore, we can say that this
separation leads to data independence because the output of the logical
database design is the conceptual and external level schemas of
the database system which is independent of the output of the physical
database design that is an internal schema.
53. What are temporary tables? When are they useful?
Temporary tables exist solely for a particular session, or whose data
persists for the duration of the transaction. The temporary tables are
generally used to support specialized rollups or specific application
processing requirements. Unlike a permanent table, space is not allocated to
a temporary table when it is created. Space will be dynamically allocated for
the table as rows are inserted. The CREATE GLOBAL TEMPORARY TABLE
command is used to create a temporary table in Oracle.
54. Explain different types of failures that occur in the Oracle database.
Types of Failures – In the Oracle database following types of failures can
occur:
Statement Failure·
Bad data type
Insufficient space
Insufficient Privileges (e.g., object privileges to a role)
User Process Failure
The user performed an abnormal disconnect
The user’s session was abnormally terminated
The user’s program raised an address exception
User Error
The user drops a table
User damages data by modification
Instance Failure
Media Failure
The user drops a table
User damages data by modification
Alert Logs
Records informational and error messages
All Instance startups and shutdowns are recorded in
the log
55. What is the main goal of RAID technology?
RAID stands for Redundant Array of Inexpensive (or sometimes
“Independent”)Disks.
RAID is a method of combining several hard disk drives into one logical unit
(two or more disks grouped together to appear as a single device to the host
system). RAID technology was developed to address the fault-tolerance and
performance limitations of conventional disk storage. It can offer fault
tolerance and higher throughput levels than a single hard drive or group of
independent hard drives. While arrays were once considered complex and
relatively specialized storage solutions, today they are easy to use and
essential for a broad spectrum of client/server applications.
Q1. What is DBMS?
Ans. Database Management System (DBMS) is a collection of
programs that enables users to store, retrieve, update, and
delete information from a database.
Optimistic approach
Pessimistic approach
select
project
union
set difference
Entity Integrity
Referential Integrity
Q37. Explain VDL and SDL.
Ans. VDL stands for View Definition Language. It describes
user views and their mapping to the conceptual schema. SDL is
short for Storage Definition Language. It represents the
mapping between two schemas.
It deletes only those rows which have the It removes all the rows from
WHERE clause.
Conclusion
So, this is all about DBMS interview questions and answers. We
hope these database interview questions and answers will help
you ace your next interview.