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.
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.
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.
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.
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.
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.
A relation is specified as a set of tuples. A relation is the set of related attributes with
identifying key attributes
One-To-One: Here one record of any object can be related to one record of another
object.
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.
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.
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.
For example, a student has student_id, department, and course as its characteristics.
For example: If a student is an entity in the table then age will be the attribute of that
student.
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.
o Research Storage
o System Relational Data System
It makes you able to modify the schema definition in one level should not affect the
schema definition in the next higher 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.
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:
Where:
X->Y
Y does not -> X
Y->Z so, X->Z
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.
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.
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.
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.
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.