DBMS Interview Questions
DBMS Interview Questions
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.
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.
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.
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.
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.
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.
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.
For example: If a student is an entity in the table then age will be the attribute of that student.
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.
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.
Inner joins:
Inner join is of 3 categories. They are:
• Theta join
• Natural join
• Equi join
Outer joins:
Outer join have three types. They are:
• Left outer join
• Right outer join
• Full outer join
• The table is in 1NF, i.e., firstly it is necessary that the table should follow the rules of
1NF.
• 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.
• It is in 3NF.
• 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.
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.
37) 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.
• DELETE command delete only those rows which are specified with the WHERE
clause.
• DELETE command can be rolled back.
• DELETE command maintain a log, that's why it is slow.
• 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.
• The TRUNCATE command removes all the rows from the table.
• The TRUNCATE command cannot be rolled back.
• The TRUNCATE command doesn't maintain a log. That's why it is fast.
• TRUNCATE use table log while performing the TRUNCATE function.
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.