Sunteți pe pagina 1din 41

DBMS Interview Questions

A list of top frequently asked DBMS interview questions and answers are given below.

1) What is DBMS?
DBMS is a collection of programs that facilitates users to create and maintain a
database. In other words, DBMS provides us an interface or tool for performing different
operations such as the creation of a database, inserting data into it, deleting data from
it, updating the data, etc. DBMS is a software in which data is stored in a more secure
way as compared to the file-based system. Using DBMS, we can overcome many
problems such as- data redundancy, data inconsistency, easy access, more organized
and understandable, and so on. There is the name of some popular Database
Management System- MySQL, Oracle, SQL Server, Amazon simple DB (Cloud-based),
etc.

Working of DBMS is defined in the figure below.

2) What is a database?
A Database is a logical, consistent and organized collection of data that it can easily be
accessed, managed and updated. Databases, also known as electronic databases are
structured to provide the facility of creation, insertion, updating of the data efficiently
and are stored in the form of a file or set of files, on the magnetic disk, tapes and
another sort of secondary devices. Database mostly consists of the objects (tables), and
tables include of the records and fields. Fields are the basic units of data storage, which
contain the information about a particular aspect or attribute of the entity described by
the database. DBMS is used for extraction of data from the database in the form of the
queries.

For more information: Click here

3) What is a database system?


The collection of database and DBMS software together is known as a database system.
Through the database system, we can perform many activities such as-
The data can be stored in the database with ease, and there are no issues of data
redundancy and data inconsistency.

The data will be extracted from the database using DBMS software whenever required.
So, the combination of database and DBMS software enables one to store, retrieve and
access data with considerate accuracy and security.

4) What are the advantages of DBMS?


o Redundancy control
o Restriction for unauthorized access
o Provides multiple user interfaces
o Provides backup and recovery
o Enforces integrity constraints
o Ensure data consistency
o Easy accessibility
o Easy data extraction and data processing due to the use of queries

For more information: Click here

5) What is a checkpoint in DBMS?


The Checkpoint is a type of mechanism where all the previous logs are removed from the
system and permanently stored in the storage disk.

There are two ways which can help the DBMS in recovering and maintaining the ACID
properties, and they are- maintaining the log of each transaction and maintaining
shadow pages. So, when it comes to log based recovery system, checkpoints come into
existence. Checkpoints are those points to which the database engine can recover after a
crash as a specified minimal point from where the transaction log record can be used to
recover all the committed data up to the point of the crash.

6) When does checkpoint occur in DBMS?


A checkpoint is like a snapshot of the DBMS state. Using checkpoints, the DBMS can
reduce the amount of work to be done during a restart in the event of subsequent
crashes. Checkpoints are used for the recovery of the database after the system crash.
Checkpoints are used in the log-based recovery system. When due to a system crash we
need to restart the system then at that point we use checkpoints. So that, we don't have
to perform the transactions from the very starting.
7) What do you mean by transparent DBMS?
The transparent DBMS is a type of DBMS which keeps its physical structure hidden from
users. Physical structure or physical storage structure implies to the memory manager of
the DBMS, and it describes how the data stored on disk.

8) What are the unary operations in Relational Algebra?


PROJECTION and SELECTION are the unary operations in relational algebra. Unary
operations are those operations which use single operands. Unary operations are
SELECTION, PROJECTION, and RENAME.

As in SELECTION relational operators are used for example - =,<=,>=, etc.

9) What is RDBMS?
RDBMS stands for Relational Database Management Systems. It is used to maintain the
data records and indices in tables. RDBMS is the form of DBMS which uses the structure
to identify and access data concerning the other piece of data in the database. RDBMS is
the system that enables you to perform different operations such as- update, insert,
delete, manipulate and administer a relational database with minimal difficulties. Most of
the time RDBMS use SQL language because it is easily understandable and is used for
often.

10) How many types of database languages are?


There are four types of database languages:

o Data Definition Language (DDL) e.g., CREATE, ALTER, DROP, TRUNCATE,


RENAME, etc. All these commands are used for updating the data that?s why they
are known as Data Definition Language.
o Data Manipulation Language (DML) e.g., SELECT, UPDATE, INSERT, DELETE,
etc. These commands are used for the manipulation of already updated data
that's why they are the part of Data Manipulation Language.
o DATA Control Language (DCL) e.g., GRANT and REVOKE. These commands
are used for giving and removing the user access on the database. So, they are
the part of Data Control Language.
o Transaction Control Language (TCL) e.g., COMMIT, ROLLBACK, and
SAVEPOINT. These are the commands used for managing transactions in the
database. TCL is used for managing the changes made by DML.
Database language implies the queries that are used for the update, modify and
manipulate the data.

11) What do you understand by Data Model?


The Data model is specified as a collection of conceptual tools for describing data, data
relationships, data semantics and constraints. These models are used to describe the
relationship between the entities and their attributes.

There is the number of data models:

o Hierarchical data model


o network model
o relational model
o Entity-Relationship model and so on.

12) Define a Relation Schema and a Relation.


A Relation Schema is specified as a set of attributes. It is also known as table schema. It
defines what the name of the table is. Relation schema is known as the blueprint with
the help of which we can explain that how the data is organized into tables. This
blueprint contains no data.

A relation is specified as a set of tuples. A relation is the set of related attributes with
identifying key attributes

See this example:

Let r be the relation which contains set tuples (t1, t2, t3, ..., tn). Each tuple is an
ordered list of n-values t=(v1,v2, ...., vn).

13) What is a degree of Relation?


The degree of relation is a number of attribute of its relation schema. A degree of
relation is also known as Cardinality it is defined as the number of occurrence of one
entity which is connected to the number of occurrence of other entity. There are three
degree of relation they are one-to-one(1:1), one-to-many(1:M), many-to-one(M:M).

14) What is the Relationship?


The Relationship is defined as an association among two or more entities. There are
three type of relationships in DBMS-
One-To-One: Here one record of any object can be related to one record of another
object.

One-To-Many (many-to-one): Here one record of any object can be related to many
records of other object and vice versa.

Many-to-many: Here more than one records of an object can be related to n number of
records of another object.

15) What are the disadvantages of file processing systems?


o Inconsistent
o Not secure
o Data redundancy
o Difficult in accessing data
o Data isolation
o Data integrity
o Concurrent access is not possible
o Limited data sharing
o Atomicity problem

16) What is data abstraction in DBMS?


Data abstraction in DBMS is a process of hiding irrelevant details from users. Because
database systems are made of complex data structures so, it makes accessible the user
interaction with the database.

For example: We know that most of the users prefer those systems which have a
simple GUI that means no complex processing. So, to keep the user tuned and for
making the access to the data easy, it is necessary to do data abstraction. In addition to
it, data abstraction divides the system in different layers to make the work specified and
well defined.

17) What are the three levels of data abstraction?


Following are three levels of data abstraction:

Physical level: It is the lowest level of abstraction. It describes how data are stored.

Logical level: It is the next higher level of abstraction. It describes what data are
stored in the database and what the relationship among those data is.
View level: It is the highest level of data abstraction. It describes only part of the entire
database.

For example- User interacts with the system using the GUI and fill the required details,
but the user doesn't have any idea how the data is being used. So, the abstraction level
is entirely high in VIEW LEVEL.

Then, the next level is for PROGRAMMERS as in this level the fields and records are
visible and the programmers have the knowledge of this layer. So, the level of
abstraction here is a little low in VIEW LEVEL.

And lastly, physical level in which storage blocks are described.

18) What is DDL (Data Definition Language)?


Data Definition Language (DDL) is a standard for commands which defines the different
structures in a database. Most commonly DDL statements are CREATE, ALTER, and
DROP. These commands are used for updating data into the database.

19) What is DML (Data Manipulation Language)?


DData Manipulation Language (DML) is a language that enables the user to access or
manipulate data as organized by the appropriate data model. For example- SELECT,
UPDATE, INSERT, DELETE.

There is two type of DML:

Procedural DML or Low level DML: It requires a user to specify what data are needed
and how to get those data.

Non-Procedural DML or High level DML:It requires a user to specify what data are
needed without specifying how to get those data.

20) Explain the functionality of DML Compiler.


The DML Compiler translates DML statements in a query language that the query
evaluation engine can understand. DML Compiler is required because the DML is the
family of syntax element which is very similar to the other programming language which
requires compilation. So, it is essential to compile the code in the language which query
evaluation engine can understand and then work on those queries with proper output.

21) What is Relational Algebra?


Relational Algebra is a Procedural Query Language which contains a set of operations
that take one or two relations as input and produce a new relationship. Relational
algebra is the basic set of operations for the relational model. The decisive point of
relational algebra is that it is similar to the algebra which operates on the number.

There are few fundamental operations of relational algebra:

o select
o project
o set difference
o union
o rename,etc.

22) What is Relational Calculus?


Relational Calculus is a Non-procedural Query Language which uses mathematical
predicate calculus instead of algebra. Relational calculus doesn't work on mathematics
fundamentals such as algebra, differential, integration, etc. That's why it is also known
as predicate calculus.

There is two type of relational calculus:

o Tuple relational calculus


o Domain relational calculus

23) What do you understand by query optimization?


The term query optimization specifies an efficient execution plan for evaluating a query
that has the least estimated cost. The concept of query optimization came into the frame
when there were a number of methods, and algorithms existed for the same task then
the question arose that which one is more efficient and the process of determining the
efficient way is known as query optimization.

There are many benefits of query optimization:

o It reduces the time and space complexity.


o More queries can be performed as due to optimization every query comparatively
takes less time.
o User satisfaction as it will provide output fast

24) What do you mean by durability in DBMS?


Once the DBMS informs the user that a transaction has completed successfully, its effect
should persist even if the system crashes before all its changes are reflected on disk.
This property is called durability. Durability ensures that once the transaction is
committed into the database, it will be stored in the non-volatile memory and after that
system failure cannot affect that data anymore.

25) What is normalization?


Normalization is a process of analysing the given relation schemas according to their
functional dependencies. It is used to minimize redundancy and also used to minimize
insertion, deletion and update distractions. Normalization is considered as an essential
process as it is used to avoid data redundancy, insertion anomaly, updation anomaly,
deletion anomaly.

There most commonly used normal forms are:

o First Normal Form(1NF)


o Second Normal Form(2NF)
o Third Normal Form(3NF)
o Boyce & Codd Normal Form(BCNF)

26) What is Denormalization?


Denormalization is the process of boosting up database performance and adding of
redundant data which helps to get rid of complex data. Denormalization is a part of
database optimization technique. This process is used to avoid the use of complex and
costly joins. Denormalization doesn't refer to the thought of not to normalize instead of
that denormalization takes place after normalization. In this process, firstly the
redundancy of the data will be removed using normalization process than through
denormalization process we will add redundant data as per the requirement so that we
can easily avoid the costly joins.

27) What is functional Dependency?


Functional Dependency is the starting point of normalization. It exists when a relation
between two attributes allow you to determine the corresponding attribute's value
uniquely. The functional dependency is also known as database dependency and defines
as the relationship which occurs when one attribute in a relation uniquely determines
another attribute. It is written as A->B which means B is functionally dependent on A.

28) What is the E-R model?


E-R model is a short name for the Entity-Relationship model. This model is based on the
real world. It contains necessary objects (known as entities) and the relationship among
these objects. Here the primary objects are the entity, attribute of that entity,
relationship set, an attribute of that relationship set can be mapped in the form of E-R
diagram.

In E-R diagram, entities are represented by rectangles, relationships are represented by


diamonds, attributes are the characteristics of entities and represented by ellipses, and
data flow is represented through a straight line.

29) What is an entity?


The Entity is a set of attributes in a database. An entity can be a real-world object which
physically exists in this world. All the entities have their attribute which in the real world
considered as the characteristics of the object.

For example: In the employee database of a company, the employee, department, and
the designation can be considered as the entities. These entities have some
characteristics which will be the attributes of the corresponding entity.

30) What is an Entity type?


An entity type is specified as a collection of entities, having the same attributes. Entity
type typically corresponds to one or several related tables in the database. A
characteristic or trait which defines or uniquely identifies the entity is called entity type.

For example, a student has student_id, department, and course as its characteristics.

31) What is an Entity set?


The entity set specifies the collection of all entities of a particular entity type in the
database. An entity set is known as the set of all the entities which share the same
properties.

For example, a set of people, a set of students, a set of companies, etc.

32) What is an Extension of entity type?


An extension of an entity type is specified as a collection of entities of a particular entity
type that are grouped into an entity set.
33) What is Weak Entity set?
An entity set that doesn't have sufficient attributes to form a primary key is referred to
as a weak entity set. The member of a weak entity set is known as a subordinate entity.
Weak entity set does not have a primary key, but we need a mean to differentiate
among all those entries in the entity set that depend on one particular strong entity set.

34) What is an attribute?


An attribute refers to a database component. It is used to describe the property of an
entity. An attribute can be defined as the characteristics of the entity. Entities can be
uniquely identified using the attributes. Attributes represent the instances in the row of
the database.

For example: If a student is an entity in the table then age will be the attribute of that
student.

35) What are the integrity rules in DBMS?


Data integrity is one significant aspect while maintaining the database. So, data integrity
is enforced in the database system by imposing a series of rules. Those set of integrity is
known as the integrity rules.

There are two integrity rules in DBMS:

Entity Integrity : It specifies that "Primary key cannot have a NULL value."

Referential Integrity: It specifies that "Foreign Key can be either a NULL value or
should be the Primary Key value of other relation

36) What do you mean by extension and intension?


Extension: The Extension is the number of tuples present in a table at any instance. It
changes as the tuples are created, updated and destroyed. The actual data in the
database change quite frequently. So, the data in the database at a particular moment in
time is known as extension or database state or snapshot. It is time dependent.

Intension: Intension is also known as Data Schema and defined as the description of
the database, which is specified during database design and is expected to remain
unchanged. The Intension is a constant value that gives the name, structure of tables
and the constraints laid on it.
37) What is System R? How many of its two major
subsystems?
System R was designed and developed from 1974 to 1979 at IBM San Jose Research
Centre. System R is the first implementation of SQL, which is the standard relational
data query language, and it was also the first to demonstrate that RDBMS could provide
better transaction processing performance. It is a prototype which is formed to show
that it is possible to build a Relational System that can be used in a real-life environment
to solve real-life problems.

Following are two major subsystems of System R:

o Research Storage
o System Relational Data System

38) What is Data Independence?


Data independence specifies that "the application is independent of the storage structure
and access strategy of data." It makes you able to modify the schema definition at one
level without altering the schema definition in the next higher level.

It makes you able to modify the schema definition in one level should not affect the
schema definition in the next higher level.

There are two types of Data Independence:

Physical Data Independence: Physical data is the data stored in the database. It is in
the bit-format. Modification in physical level should not affect the logical level.

For example: If we want to manipulate the data inside any table that should not change
the format of the table.

Logical Data Independence: Logical data in the data about the database. It basically
defines the structure. Such as tables stored in the database. Modification in logical level
should not affect the view level.

For example: If we need to modify the format of any table, that modification should not
affect the data inside it.

NOTE: Logical Data Independence is more difficult to achieve.

39) What are the three levels of data abstraction?


Following are three levels of data abstraction:
Physical level: It is the lowest level of abstraction. It describes how data are stored.

Logical level: It is the next higher level of abstraction. It describes what data are
stored in the database and what relationship among those data.

View level: It is the highest level of data abstraction. It describes only part of the entire
database.

For example- User interact with the system using the GUI and fill the required details,
but the user doesn't have any idea how the data is being used. So, the abstraction level
is absolutely high in VIEW LEVEL.

Then, the next level is for PROGRAMMERS as in this level the fields and records are
visible and the programmer has the knowledge of this layer. So, the level of abstraction
here is a little low in VIEW LEVEL.

And lastly, physical level in which storage blocks are described.

40) What is Join?


The Join operation is one of the most useful activities in relational algebra. It is most
commonly used way to combine information from two or more relations. A Join is always
performed on the basis of the same or related column. Most complex queries of SQL
involve JOIN command.

There are following types of join:

o Inner joins: Inner join is of 3 categories. They are:


o Theta join
o Natural join
o Equi join
o Outer joins: Outer join have three types. They are:
o Left outer join
o Right outer join
o Full outer join

41) What is 1NF?


1NF is the First Normal Form. It is the simplest type of normalization that you can
implement in a database. The primary objectives of 1NF are to:

o Every column must have atomic (single value)


o To Remove duplicate columns from the same table
o Create separate tables for each group of related data and identify each row with a
unique column

42) What is 2NF?


2NF is the Second Normal Form. A table is said to be 2NF if it follows the following
conditions:

o The table is in 1NF, i.e., firstly it is necessary that the table should follow the
rules of 1NF.
o Every non-prime attribute is fully functionally dependent on the primary key, i.e.,
every non-key attribute should be dependent on the primary key in such a way
that if any key element is deleted, then even the non_key element will still be
saved in the database.

43) What is 3NF?


3NF stands for Third Normal Form. A database is called in 3NF if it satisfies the
following conditions:

o It is in second normal form.


o There is no transitive functional dependency.
o For example: X->Z

Where:
X->Y
Y does not -> X
Y->Z so, X->Z

44) What is BCNF?


BCMF stands for Boyce-Codd Normal Form. It is an advanced version of 3NF, so it is
also referred to as 3.5NF. BCNF is stricter than 3NF.

A table complies with BCNF if it satisfies the following conditions:

o It is in 3NF.
o For every functional dependency X->Y, X should be the super key of the table. It
merely means that X cannot be a non-prime attribute if Y is a prime attribute.
45) Explain ACID properties
ACID properties are some basic rules, which has to be satisfied by every transaction to
preserve the integrity. These properties and rules are:

ATOMICITY: Atomicity is more generally known as ?all or nothing rule.' Which implies
all are considered as one unit, and they either run to completion or not executed at all.

CONSISTENCY: This property refers to the uniformity of the data. Consistency implies
that the database is consistent before and after the transaction.

ISOLATION: This property states that the number of the transaction can be executed
concurrently without leading to the inconsistency of the database state.

DURABILITY: This property ensures that once the transaction is committed it will be
stored in the non-volatile memory and system crash can also not affect it anymore.

46) What is stored procedure?


A stored procedure is a group of SQL statements that have been created and stored in
the database. The stored procedure increases the reusability as here the code or the
procedure is stored into the system and used again and again that makes the work easy,
takes less time in processing and decreases the complexity of the system. So, if you
have a code which you need to use again and again then save that code and call that
code whenever it is required.

47) What is the difference between a DELETE command and


TRUNCATE command?
DELETE command: DELETE command is used to delete rows from a table based on the
condition that we provide in a WHERE clause.

o DELETE command delete only those rows which are specified with the WHERE
clause.
o DELETE command can be rolled back.
o DELETE command maintain a log, that's why it is slow.
o DELETE use row lock while performing DELETE function.

TRUNCATE command: TRUNCATE command is used to remove all rows (complete


data) from a table. It is similar to the DELETE command with no WHERE clause.

o The TRUNCATE command removes all the rows from the table.
o The TRUNCATE command cannot be rolled back.
o The TRUNCATE command doesn't maintain a log. That's why it is fast.
o TRUNCATE use table log while performing the TRUNCATE function.

48) What is 2-Tier architecture?


The 2-Tier architecture is the same as basic client-server. In the two-tier architecture,
applications on the client end can directly communicate with the database at the server
side.
49) What is the 3-Tier architecture?
The 3-Tier architecture contains another layer between the client and server.
Introduction of 3-tier architecture is for the ease of the users as it provides the GUI,
which, make the system secure and much more accessible. In this architecture, the
application on the client-end interacts with an application on the server which further
communicates with the database system.
50) How do you communicate with an RDBMS?
You have to use Structured Query Language (SQL) to communicate with the RDBMS.
Using queries of SQL, we can give the input to the database and then after processing of
the queries database will provide us the required output.

51) What is the difference between a shared lock and exclusive


lock?
Shared lock: Shared lock is required for reading a data item. In the shared lock, many
transactions may hold a lock on the same data item. When more than one transaction is
allowed to read the data items then that is known as the shared lock.

Exclusive lock: When any transaction is about to perform the write operation, then the
lock on the data item is an exclusive lock. Because, if we allow more than one
transaction then that will lead to the inconsistency in the database.

52) Describe the types of keys?


There are following types of keys:

Primary key: The Primary key is an attribute in a table that can uniquely identify each
record in a table. It is compulsory for every table.

Candidate key: The Candidate key is an attribute or set of an attribute which can
uniquely identify a tuple. The Primary key can be selected from these attributes.

Super key: The Super key is a set of attributes which can uniquely identify a tuple.
Super key is a superset of the candidate key.

Foreign key: The Foreign key is a primary key from one table, which has a relationship
with another table. It acts as a cross-reference between tables.

Top 50 SQL Interview Questions &


Answers
1. What is DBMS?
A Database Management System (DBMS) is a program that controls
creation, maintenance and use of a database. DBMS can be termed as File
Manager that manages data in a database rather than saving it in file
systems.

2. What is RDBMS?

RDBMS stands for Relational Database Management System. RDBMS


store the data into the collection of tables, which is related by common
fields between the columns of the table. It also provides relational operators
to manipulate the data stored into the tables.

Example: SQL Server.

3. What is SQL?

SQL stands for Structured Query Language , and it is used to communicate


with the Database. This is a standard language used to perform tasks such
as retrieval, updation, insertion and deletion of data from a database.

Standard SQL Commands are Select.

4. What is a Database?

Database is nothing but an organized form of data for easy access, storing,
retrieval and managing of data. This is also known as structured form of
data which can be accessed in many ways.

Example: School Management Database, Bank Management Database.

5. What are tables and Fields?

A table is a set of data that are organized in a model with Columns and
Rows. Columns can be categorized as vertical, and Rows are horizontal. A
table has specified number of column called fields but can have any
number of rows which is called record.

Example:.

Table: Employee.

Field: Emp ID, Emp Name, Date of Birth.

Data: 201456, David, 11/15/1960.

6. What is a primary key?


A primary key is a combination of fields which uniquely specify a row. This
is a special kind of unique key, and it has implicit NOT NULL constraint. It
means, Primary key values cannot be NULL.

7. What is a unique key?

A Unique key constraint uniquely identified each record in the database.


This provides uniqueness for the column or set of columns.

A Primary key constraint has automatic unique constraint defined on it. But
not, in the case of Unique Key.

There can be many unique constraint defined per table, but only one
Primary key constraint defined per table.

8. What is a foreign key?

A foreign key is one table which can be related to the primary key of
another table. Relationship needs to be created between two tables by
referencing foreign key with the primary key of another table.

9. What is a join?

This is a keyword used to query data from more tables based on the
relationship between the fields of the tables. Keys play a major role when
JOINs are used.

10. What are the types of join and explain each?

There are various types of join which can be used to retrieve data and it
depends on the relationship between tables.

 Inner Join.

Inner join return rows when there is at least one match of rows between the
tables.

 Right Join.

Right join return rows which are common between the tables and all rows
of Right hand side table. Simply, it returns all the rows from the right hand
side table even though there are no matches in the left hand side table.

 Left Join.
Left join return rows which are common between the tables and all rows of
Left hand side table. Simply, it returns all the rows from Left hand side table
even though there are no matches in the Right hand side table.

 Full Join.

Full join return rows when there are matching rows in any one of the tables.
This means, it returns all the rows from the left hand side table and all the
rows from the right hand side table.

11. What is normalization?

Normalization is the process of minimizing redundancy and dependency by


organizing fields and table of a database. The main aim of Normalization is
to add, delete or modify field that can be made in a single table.

12. What is Denormalization.

DeNormalization is a technique used to access the data from higher to


lower normal forms of database. It is also process of introducing
redundancy into a table by incorporating data from the related tables.

13. What are all the different normalizations?

The normal forms can be divided into 5 forms, and they are explained
below -.

 First Normal Form (1NF):.

This should remove all the duplicate columns from the table. Creation of
tables for the related data and identification of unique columns.

 Second Normal Form (2NF):.

Meeting all requirements of the first normal form. Placing the subsets of
data in separate tables and Creation of relationships between the tables
using primary keys.

 Third Normal Form (3NF):.

This should meet all requirements of 2NF. Removing the columns which
are not dependent on primary key constraints.

 Fourth Normal Form (3NF):.


Meeting all the requirements of third normal form and it should not have
multi- valued dependencies.

14. What is a View?

A view is a virtual table which consists of a subset of data contained in a


table. Views are not virtually present, and it takes less space to store. View
can have data of one or more tables combined, and it is depending on the
relationship.

15. What is an Index?

An index is performance tuning method of allowing faster retrieval of


records from the table. An index creates an entry for each value and it will
be faster to retrieve data.

16. What are all the different types of indexes?

There are three types of indexes -.

 Unique Index.

This indexing does not allow the field to have duplicate values if the column
is unique indexed. Unique index can be applied automatically when primary
key is defined.

 Clustered Index.

This type of index reorders the physical order of the table and search
based on the key values. Each table can have only one clustered index.

 NonClustered Index.

NonClustered Index does not alter the physical order of the table and
maintains logical order of data. Each table can have 999 nonclustered
indexes.

17. What is a Cursor?

A database Cursor is a control which enables traversal over the rows or


records in the table. This can be viewed as a pointer to one row in a set of
rows. Cursor is very much useful for traversing such as retrieval, addition
and removal of database records.

18. What is a relationship and what are they?


Database Relationship is defined as the connection between the tables in a
database. There are various data basing relationships, and they are as
follows:.

 One to One Relationship.


 One to Many Relationship.
 Many to One Relationship.
 Self-Referencing Relationship.

19. What is a query?

A DB query is a code written in order to get the information back from the
database. Query can be designed in such a way that it matched with our
expectation of the result set. Simply, a question to the Database.

20. What is subquery?

A subquery is a query within another query. The outer query is called as


main query, and inner query is called subquery. SubQuery is always
executed first, and the result of subquery is passed on to the main query.

21. What are the types of subquery?

There are two types of subquery – Correlated and Non-Correlated.

A correlated subquery cannot be considered as independent query, but it


can refer the column in a table listed in the FROM the list of the main
query.

A Non-Correlated sub query can be considered as independent query and


the output of subquery are substituted in the main query.

22. What is a stored procedure?

Stored Procedure is a function consists of many SQL statement to access


the database system. Several SQL statements are consolidated into a
stored procedure and execute them whenever and wherever required.

23. What is a trigger?

A DB trigger is a code or programs that automatically execute with


response to some event on a table or view in a database. Mainly, trigger
helps to maintain the integrity of the database.
Example: When a new student is added to the student database, new
records should be created in the related tables like Exam, Score and
Attendance tables.

24. What is the difference between DELETE and TRUNCATE


commands?

DELETE command is used to remove rows from the table, and WHERE
clause can be used for conditional set of parameters. Commit and Rollback
can be performed after delete statement.

TRUNCATE removes all rows from the table. Truncate operation cannot be
rolled back.

25. What are local and global variables and their differences?

Local variables are the variables which can be used or exist inside the
function. They are not known to the other functions and those variables
cannot be referred or used. Variables can be created whenever that
function is called.

Global variables are the variables which can be used or exist throughout
the program. Same variable declared in global cannot be used in functions.
Global variables cannot be created whenever that function is called.

26. What is a constraint?

Constraint can be used to specify the limit on the data type of table.
Constraint can be specified while creating or altering the table statement.
Sample of constraint are.

 NOT NULL.
 CHECK.
 DEFAULT.
 UNIQUE.
 PRIMARY KEY.
 FOREIGN KEY.

27. What is data Integrity?

Data Integrity defines the accuracy and consistency of data stored in a


database. It can also define integrity constraints to enforce business rules
on the data when it is entered into the application or database.

28. What is Auto Increment?


Auto increment keyword allows the user to create a unique number to be
generated when a new record is inserted into the table. AUTO
INCREMENT keyword can be used in Oracle and IDENTITY keyword can
be used in SQL SERVER.

Mostly this keyword can be used whenever PRIMARY KEY is used.

29. What is the difference between Cluster and Non-Cluster Index?

Clustered index is used for easy retrieval of data from the database by
altering the way that the records are stored. Database sorts out rows by the
column which is set to be clustered index.

A nonclustered index does not alter the way it was stored but creates a
complete separate object within the table. It point back to the original table
rows after searching.

30. What is Datawarehouse?

Datawarehouse is a central repository of data from multiple sources of


information. Those data are consolidated, transformed and made available
for the mining and online processing. Warehouse data have a subset of
data called Data Marts.

31. What is Self-Join?

Self-join is set to be query used to compare to itself. This is used to


compare values in a column with other values in the same column in the
same table. ALIAS ES can be used for the same table comparison.

32. What is Cross-Join?

Cross join defines as Cartesian product where number of rows in the first
table multiplied by number of rows in the second table. If suppose, WHERE
clause is used in cross join then the query will work like an INNER JOIN.

33. What is user defined functions?

User defined functions are the functions written to use that logic whenever
required. It is not necessary to write the same logic several times. Instead,
function can be called or executed whenever needed.

34. What are all types of user defined functions?

Three types of user defined functions are.


 Scalar Functions.
 Inline Table valued functions.
 Multi statement valued functions.

Scalar returns unit, variant defined the return clause. Other two types return
table as a return.

35. What is collation?

Collation is defined as set of rules that determine how character data can
be sorted and compared. This can be used to compare A and, other
language characters and also depends on the width of the characters.

ASCII value can be used to compare these character data.

36. What are all different types of collation sensitivity?

Following are different types of collation sensitivity -.

 Case Sensitivity – A and a and B and b.


 Accent Sensitivity.
 Kana Sensitivity – Japanese Kana characters.
 Width Sensitivity – Single byte character and double byte character.

37. Advantages and Disadvantages of Stored Procedure?

Stored procedure can be used as a modular programming – means create


once, store and call for several times whenever required. This supports
faster execution instead of executing multiple queries. This reduces
network traffic and provides better security to the data.

Disadvantage is that it can be executed only in the Database and utilizes


more memory in the database server.

38. What is Online Transaction Processing (OLTP)?

Online Transaction Processing (OLTP) manages transaction based


applications which can be used for data entry, data retrieval and data
processing. OLTP makes data management simple and efficient. Unlike
OLAP systems goal of OLTP systems is serving real-time transactions.

Example – Bank Transactions on a daily basis.

39. What is CLAUSE?


SQL clause is defined to limit the result set by providing condition to the
query. This usually filters some rows from the whole set of records.

Example – Query that has WHERE condition

Query that has HAVING condition.

40. What is recursive stored procedure?

A stored procedure which calls by itself until it reaches some boundary


condition. This recursive function or procedure helps programmers to use
the same set of code any number of times.

41. What is Union, minus and Interact commands?

UNION operator is used to combine the results of two tables, and it


eliminates duplicate rows from the tables.

MINUS operator is used to return rows from the first query but not from the
second query. Matching records of first and second query and other rows
from the first query will be displayed as a result set.

INTERSECT operator is used to return rows returned by both the queries.

42. What is an ALIAS command?

ALIAS name can be given to a table or column. This alias name can be
referred in WHERE clause to identify the table or column.

Example-.

Select st.StudentID, Ex.Result from student st, Exam as Ex where st.studentID = Ex


. StudentID

Here, st refers to alias name for student table and Ex refers to alias name
for exam table.

43. What is the difference between TRUNCATE and DROP


statements?

TRUNCATE removes all the rows from the table, and it cannot be rolled
back. DROP command removes a table from the database and operation
cannot be rolled back.

44. What are aggregate and scalar functions?


Aggregate functions are used to evaluate mathematical calculation and
return single values. This can be calculated from the columns in a table.
Scalar functions return a single value based on the input value.

Example -.

Aggregate – max(), count - Calculated with respect to numeric.

Scalar – UCASE(), NOW() – Calculated with respect to strings.

45. How can you create an empty table from an existing table?

Example will be -.

Select * into studentcopy from student where 1=2

Here, we are copying student table to another table with the same structure
with no rows copied.

46. How to fetch common records from two tables?

Common records result set can be achieved by -.

Select studentID from student. <strong>INTERSECT </strong> Select StudentID from E


xam

47. How to fetch alternate records from a table?

Records can be fetched for both Odd and Even row numbers -.

To display even numbers-.

Select studentId from (Select rowno, studentId from student) where mod(rowno,2)=0

To display odd numbers-.

Select studentId from (Select rowno, studentId from student) where mod(rowno,2)=1

from (Select rowno, studentId from student) where mod(rowno,2)=1.[/sql]

48. How to select unique records from a table?

Select unique records from a table by using DISTINCT keyword.

Select DISTINCT StudentID, StudentName from Student.


49. What is the command used to fetch first 5 characters of the
string?

There are many ways to fetch first 5 characters of the string -.

Select SUBSTRING(StudentName,1,5) as studentname from student


Select RIGHT(Studentname,5) as studentname from student

50. Which operator is used in query for pattern matching?

LIKE operator is used for pattern matching, and it can be used as -.

1. % - Matches zero or more characters.


2. _(Underscore) – Matching exactly one character.

Example -.

Select * from Student where studentname like 'a%'


Select * from Student where studentname like 'ami_'

DBMS Interview Questions-DBMS Interview Questions updated on Aug 2019


629948

1. What is database?

A database is a collection of information that is organized. So that it can easily be accessed,


managed, and updated.
2. What is DBMS?

DBMS stands for Database Management System. It is a collection of programs that enables user to
create and maintain a database.

3. What is a Database system?

The database and DBMS software together is called as Database system.

4. What are the advantages of DBMS?

I. Redundancy is controlled.

II. Providing multiple user interfaces.

III. Providing backup and recovery

IV. Unauthorized access is restricted.

V. Enforcing integrity constraints.

5. What is normalization?

It is a process of analysing the given relation schemas based on their Functional Dependencies
(FDs) and primary key to achieve the properties
(1).Minimizing redundancy, (2). Minimizing insertion, deletion and update anomalies.

6. What is Data Model?


A collection of conceptual tools for describing data, data relationships data semantics and
constraints.

7. What is E-R model?

This data model is based on real world that consists of basic objects called entities and of
relationship among these objects. Entities are described in a database by a set of attributes.

8. What is Object Oriented model?

This model is based on collection of objects. An object contains values stored in instance variables
with in the object. An object also contains bodies of code that operate on the object. These bodies
of code are called methods. Objects that contain same types of values and the same methods are
grouped together into classes.

9. What is an Entity?
An entity is a thing or object of importance about which data must be captured.

10. What is DDL (Data Definition Language)?

A data base schema is specifies by a set of definitions expressed by a special language called DDL.

11. What is DML (Data Manipulation Language)?

This language that enable user to access or manipulate data as organised by appropriate data
model. Procedural DML or Low level: DML requires a user to specify what data are needed and how
to get those data. Non-Procedural DML or High level: DML requires a user to specify what data are
needed without specifying how to get those data

12. What is DML Compiler?

It translates DML statements in a query language into low-level instruction that the query
evaluation engine can understand.

13. What is Query evaluation engine?

It executes low-level instruction generated by compiler.

14. What is Functional Dependency?

Functional Dependency is the starting point of normalization. Functional Dependency exists when a
relation between two attributes allows you to uniquely determine the corresponding attribute’ s
value.

15. What is 1 NF (Normal Form)?

The first normal form or 1NF is the first and the simplest type of normalization that can be
implemented in a database. The main aims of 1NF are to:

1. Eliminate duplicative columns from the same table.

2. Create separate tables for each group of related data and identify each row with a unique
column (the primary key).

16. What is Fully Functional dependency?

A functional dependency X Y is full functional dependency if removal of any attribute A from X


means that the dependency does not hold any more.

17. What is 2NF?

A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully


functionally dependent on primary key.

18. What is 3NF?

A relation is in third normal form if it is in Second Normal Form and there are no functional
(transitive) dependencies between two (or more) non-primary key attributes.

19. What is BCNF (Boyce-Codd Normal Form)?

A table is in Boyce-Codd normal form (BCNF) if and only if it is in 3NF and every determinant is a
candidate key.

20. What is 4NF?

Fourth normal form requires that a table be BCNF and contain no multi-valued dependencies.

21. What is 5NF?


A table is in fifth normal form (5NF) or Project-Join Normal Form (PJNF) if it is in 4NF and it cannot
have a lossless decomposition into any number of smaller tables.

22. What is a query?

A query with respect to DBMS relates to user commands that are used to interact with a data
base.

23. What is meant by query optimization?

The phase that identifies an efficient execution plan for evaluating a query that has the least
estimated cost is referred to as query optimization.

24. What is an attribute?


It is a particular property, which describes the entity.

25. What is RDBMS?

Relational Data Base Management Systems (RDBMS) are database management systems that
maintain data records and indices in tables.

26. What’ s difference between DBMS and RDBMS?

DBMS provides a systematic and organized way of storing, managing and retrieving from collection
of logically related information. RDBMS also provides what DBMS provides but above that it
provides relationship integrity.

27. What is SQL?

SQL stands for Structured Query Language. SQL is an ANSI (American National Standards
Institute) standard computer language for accessing and manipulating database systems. SQL
statements are used to retrieve and update data in a database.

28. What is Stored Procedure?

A stored procedure is a named group of SQL statements that have been previously created and
stored in the server database.

29. What is a view?

A view may be a subset of the database or it may contain virtual data that is derived from the
database files but is not explicitly stored.

30. What is Trigger?

A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE)
occurs.

31. What is Index?

An index is a physical structure containing pointers to the data.


32. What is extension and intension?

Extension -It is the number of tuples present in a table at any instance. This is time dependent.

Intension -It is a constant value that gives the name, structure of table and the constraints laid on
it.

33. What do you mean by atomicity and aggregation?

Atomicity-Atomicity states that database modifications must follow an “ all or nothing” rule. Each
transaction is said to be “ atomic.” If one part of the transaction fails, the entire transaction
fails.

Aggregation - A feature of the entity relationship model that allows a relationship set to participate
in another relationship set. This is indicated on an ER diagram by drawing a dashed box around
the aggregation.

34. What is RDBMS KERNEL?

Two important pieces of RDBMS architecture are the kernel, which is the software, and the data
dictionary, which consists of the system- level data structures used by the kernel to manage the
database.

35. Name the sub-systems of a RDBMS?

I/O, Security, Language Processing, Process Control, Storage Management, Logging and Recovery,
Distribution Control, Transaction Control, Memory Management, Lock Management.

36. How do you communicate with an RDBMS?

You communicate with an RDBMS using Structured Query Language (SQL)

37. Disadvantage in File Processing System?

· Data redundancy & inconsistency.

· Difficult in accessing data.

· Data isolation.

· Data integrity.

· Concurrent access is not possible.

· Security Problems.

38. What is VDL (View Definition Language)?

It specifies user views and their mappings to the conceptual schema.

39. What is SDL (Storage Definition Language)?

This language is to specify the internal schema. This language may Specify the mapping between
two schemas.

40. Describe concurrency control?


Concurrency control is the process managing simultaneous operations against a database so that
database integrity is no compromised. There are two approaches to concurrency control.

The pessimistic approach involves locking and the optimistic approach involves versioning.

41. Describe the difference between homogeneous and heterogeneous distributed


database?

A homogenous database is one that uses the same DBMS at each node. A heterogeneous database
is one that may have a different DBMS at each node.

42. What is a distributed database?

A distributed database is a single logical database that is spread across more than one node or
locations that are all connected via some communication link.

43. Explain the difference between two and three-tier architectures?

Three-tier architecture includes a client and two server layers.

The application code is stored on the application server and the database is stored on the
database server. A two-tier architecture includes a client and one server layer. The database is
stored on the database server.

44. Briefly describe the three types of SQL commands?

Data definition language commands are used to create, alter, and drop tables. Data manipulation
commands are used to insert, modify, update, and query data in the database. Data control
language commands help the DBA to control the database.

45. List some of the properties of a relation?

Relations in a database have a unique name and no multivalued attributes exist. Each row is
unique and each attribute within a relation has a unique name. The sequence of both columns and
rows is irrelevant.

46. Explain the differences between an intranet and an extranet?

An Internet database is accessible by everyone who has access to a Web site. An intranet
database limits access to only people within a given organization.

47. What is SQL Deadlock?

Deadlock is a unique situation in a multi user system that causes two or more users to wait
indefinitely for a locked resource.

48. What is a Catalog?

A catalog is a table that contains the information such as structure of each file, the type and
storage format of each data item and various constraints on the data .The information stored in
the catalog is called Metadata.

49. What is data ware housing & OLAP?


Data warehousing and OLAP (online analytical processing) systems are the techniques used in
many companies to extract and analyze useful information from very large databases for decision
making .

50. Describe the three levels of data abstraction?

Physical level: The lowest level of abstraction describes how data are stored.

Logical level: The next higher level of abstraction, describes what data are stored in database and
what relationship among those data.

View level: The highest level of abstraction describes only part of entire database.

51. What is Data Independence?

Data independence means that the application is independent of the storage structure and access
strategy of data.

52. How many types of relationship exist in database designing?

There are three major relationship models:-

One-to-one

One-to-many

Many-to-many

53. What is order by clause?

ORDER BY clause helps to sort the data in either ascending order to descending

54. What is the use of DBCC commands?

DBCC stands for database consistency checker. We use these commands to check the
consistency of the databases, i.e., maintenance, validation task and status checks.

55. What is Collation?

Collation refers to a set of rules that determine how data is sorted and compared.

56. What is difference between DELETE & TRUNCATE commands?

Delete command removes the rows from a table based on the condition that we provide with a
WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in
the table after we run the truncate command.

57. What is Hashing technique?

This is a primary file organization technique that provides very fast access to records on certain
search conditions.

58. What is a transaction?


A transaction is a logical unit of database processing that includes one or more database access
operations.

59. What are the different phases of Transaction?

Analysis phase

Redo phase

Undo phase

60. What is “ transparent dbms” ?

It is one, which keeps its physical structure hidden from user.

61. What are the primitive operations common to all record management System?

Addition, deletion and modification.

62. Explain the differences between structured data and unstructured data.

Structured data are facts concerning objects and events. The most important structured data are
numeric, character, and dates.

Structured data are stored in tabular form. Unstructured data are multimedia data such as
documents, photographs, maps, images, sound, and video clips. Unstructured data are most
commonly found on Web servers and Web-enabled databases.

63. What are the major functions of the database administrator?

Managing database structure, controlling concurrent processing, managing processing rights and
responsibilities, developing database security, providing for database recovery, managing the
DBMS and maintaining the data repository.

64. What is a dependency graph?

A dependency graph is a diagram that is used to portray the connections between database
elements.

65. Explain the difference between an exclusive lock and a shared lock?

An exclusive lock prohibits other users from reading the locked resource; a shared lock allows
other users to read the locked resource, but they cannot update it.

66. Explain the "paradigm mismatch" between SQL and application programming
languages.

SQL statements return a set of rows, while an application program works on one row at a time. To
resolve this mismatch the results of SQL statements are processed as pseudofiles, using a cursor
or pointer to specify which row is being processed.

67. Name four applications for triggers.

(1)Providing default values, (2) enforcing data constraints,


(3) Updating views and (4) enforcing referential integrity

68. What are the advantages of using stored procedures?

The advantages of stored procedures are (1) greater security, (2) decreased network traffic, (3)
the fact that SQL can be optimized and (4) code sharing which leads to less work, standardized
processing, and specialization among developers.

69. Explain the difference between attributes and identifiers.

Entities have attributes. Attributes are properties that describe the entity's characteristics. Entity
instances have identifiers. Identifiers are attributes that name, or identify, entity instances.

70. What is Enterprise Resource Planning (ERP), and what kind of a database is used in
an ERP application?

Enterprise Resource Planning (ERP) is an information system used in manufacturing companies


and includes sales, inventory, production planning, purchasing and other business functions. An
ERP system typically uses a multiuser database.

71. Describe the difference between embedded and dynamic SQL?

Embedded SQL is the process of including hard coded SQL statements. These statements do not
change unless the source code is modified. Dynamic SQL is the process of generating SQL on the
fly.The statements generated do not have to be the same each time.

72. Explain a join between tables

A join allows tables to be linked to other tables when a relationship between the tables exists. The
relationships are established by using a common column in the tables and often uses the
primary/foreign key relationship.

73. Describe a subquery.

A subquery is a query that is composed of two queries. The first query (inner query) is within the
WHERE clause of the other query (outer query).

74. Compare a hierarchical and network database model?

The hierarchical model is a top-down structure where each parent may have many children but
each child can have only one parent. This model supports one-to-one and one-to-many
relationships.

The network model can be much more flexible than the hierarchical model since each parent can
have multiple children but each child can also have multiple parents. This model supports one-to-
one, one-to-many, and many-to-many relationships.

75. Explain the difference between a dynamic and materialized view.

A dynamic view may be created every time that a specific view is requested by a user. A
materialized view is created and or updated infrequently and it must be synchronized with its
associated base table(s).

76. Explain what needs to happen to convert a relation to third normal form.
First you must verify that a relation is in both first normal form and second normal form. If the
relation is not, you must convert into second normal form. After a relation is in second normal
form, you must remove all transitive dependencies.

77. Describe the four types of indexes?

A unique primary index is unique and is used to find and store a row. A nonunique primary index is
not unique and is used to find a row but also where to store a row (based on its unique primary
index). A unique secondary index is unique for each row and used to find table rows. A nonunique
secondary index is not unique and used to find table rows.

78. Explain minimum and maximum cardinality?

Minimum cardinality is the minimum number of instances of an entity that can be associated with
each instance of another entity. Maximum cardinality is the maximum number of instances of an
entity that can be associated with each instance of another entity.

79. What is deadlock? How can it be avoided? How can it be resolved once it occurs?

Deadlock occurs when two transactions are each waiting on a resource that the other transaction
holds. Deadlock can be prevented by requiring transactions to acquire all locks at the same time;
once it occurs, the only way to cure it is to abort one of the transactions and back out of partially
completed work.

80. Explain what we mean by an ACID transaction.

An ACID transaction is one that is atomic, consistent, isolated, and durable. Durable means that
database changes are permanent. Consistency can mean either statement level or transaction
level consistency. With transaction level consistency, a transaction may not see its own
changes.Atomic means it is performed as a unit.

81. Under what conditions should indexes be used?

Indexes can be created to enforce uniqueness, to facilitate sorting, and to enable fast retrieval by
column values. A good candidate for an index is a column that is frequently used with equal
conditions in WHERE clauses.

82. What is difference between SQL and SQL SERVER?

SQL is a language that provides an interface to RDBMS, developed by IBM. SQL SERVER is a
RDBMS just like Oracle, DB2.

83. What is Specialization?

It is the process of defining a set of subclasses of an entity type where each subclass contain all
the attributes and relationships of the parent entity and may have additional attributes and
relationships which are specific to itself.

84. What is generalization?

It is the process of finding common attributes and relations of a number of entities and defining a
common super class for them.
85. What is meant by Proactive, Retroactive and Simultaneous Update?

Proactive Update: The updates that are applied to database before it becomes effective in real
world.

Retroactive Update: The updates that are applied to database after it becomes effective in real
world.

Simultaneous Update: The updates that are applied to database at the same time when it becomes
effective in real world.

86. What is RAID Technology?

Redundant array of inexpensive (or independent) disks. The main goal of raid technology is to
even out the widely different rates of performance improvement of disks against those in memory
and microprocessor. Raid technology employs the technique of data striping to achieve higher
transfer rates.

87. What are serial, non serial schedule?

A schedule S is serial if, for every transaction T participating in the schedule, all the operations of
T is executed consecutively in the schedule, otherwise, the schedule is called non-serial schedule.

88. What are conflict serializable schedules?

A schedule S of n transactions is serializable if it is equivalent to some serial schedule of the same


n transactions.

89. What is view serializable?

A schedule is said to be view serializable if it is view equivalent with some serial schedule.

90. What is a foreign key?

A key of a relation schema is called as a foreign key if it is the primary key of


some other relation to which it is related to.

91. What are the disadvantages of using a dbms?

1) High initial investments in h/w, s/w, and training.


2) Generality that a DBMS provides for defining and processing data.
3) Overhead for providing security, concurrency control, recovery, and integrity functions.

92. What is Lossless join property?


It guarantees that the spurious tuple generation does not occur with respect to relation schemas
after decomposition.

93. What is a Phantom Deadlock?


In distributed deadlock detection, the delay in propagating local information might cause the
deadlock detection algorithms to identify deadlocks that do not really exist. Such situations are
called phantom deadlocks and they lead to unnecessary aborts.
94. What is a checkpoint and When does it occur?
A Checkpoint is like a snapshot of the DBMS state. By taking checkpoints, the DBMS can reduce
the amount of work to be done during restart in the event of subsequent crashes.

95. What is schema?


The description of a data base is called the database schema , which is specified during database
design and is not expected to change frequently . A displayed schema is called schema diagram
.We call each object in the schema as schema construct.

S-ar putea să vă placă și