Basic DBMS Interview Questions
Basic DBMS Interview Questions
1. What is DBMS?
Some of the most important advantage of DBMS over traditional file-based systems
are:
Single tier architecture - The data is readily available on the client machine.
Two tier architecture - The DBMS software is present on the client machine and the database
is present on the server machine.
Three tier architecture - A layer is present between the client and server machine and there
is no direct communication between them. A client DBMS application on the client machine
interacts with a server DBMS application on the server machine.
6. What is a checkpoint in DBMS?
A checkpoint or savepoint is used to declare a state where all the previous logs are
removed from the system. In the event of a system crash, checkpoints can be used for
recovery. Instead of performing the transactions from the very beginning, you can use
checkpoints to get the last recorded snapshot of the database.
A database language refers to the queries that are used for updating and modifying the
data in a database. There are four main types of database languages:
1. Data Definition Language (DDL) - These commands are used to update the data.
2. Data Manipulation Language (DML) - These commands are used to manipulate the updated
data.
3. Data Control Language (DCL) - These commands are used for providing and revoking user
access to a database.
4. Transaction Control Language (TCL) - These commands are used to manage all the
transactions in a database.
A Data model is a collection of tools that are used to describe data, semantics and
constraints. They also help describe the relationship between the data entities and
their attributes. Some of the most common data models are hierarchical data model,
network model, entity relationship model and relational model. You can also check
out other data modeling interview questions to learn more about data models.
ACID properties are the basic rules of a DBMS which needs to be followed in order
to preserve data integrity. They are:
Atomicity - It is also known as the “all or nothing” rule, which implies that everything
considered as one unit is either run to completion or not executed at all.
Consistency - This property implies that the data in the database remains consistent
before and after every transaction.
Isolation - This property states that different numbers of transactions can be executed
concurrently.
Durability - This property ensures that every transaction is stored in the non-volatile
memory after the transaction is completed.
DELETE command is used to remove the rows in a table based on the condition set
by the WHERE clause. The rows deleted can be rolled back.
TRUNCATE command is used to remove all the rows in a table without any
conditions. The rows cannot be rolled back.
First Normal Form(1NF) - A table is said to be in 1NF if it holds only atomic values.
Second Normal Form(2NF) - A table is said to be in 2NF if it is in 1NF and non-prime
attributes are not dependent on any candidate key.
Third Normal Form(3NF) - A table is said to be in 3NF if it is in 2NF and non-prime attributes
are not dependent on any super key.
Boyce & Codd Normal Form(BCNF) - A table is said to be in BCNF if it is in 3NF and for every
functional dependency A->B, B is the super key of the table.
Merge join - A merge join is used to join two input streams of the joined tables into a
single output stream.
15. Define a relationship in DBMS and its various
types.
A relationship is an association or link between two or more data entities. There are
three main types of relationships in DBMS:
One to one - A single record in one table is related to a single record in another table and
vice versa.
One to many / Many to one - A single record of one table is related to many records of other
tables and vice versa.
Many to many - Multiple records of one table are related to multiple records of another
table.
It describes only how the user interacts with the database.
Foreign key - It is a field or a collection of fields used to link one table to a primary
key from another table.
Intention - It is a constant value where the description of the database doesn’t change
or is highly unlikely to change frequently. It is usually specified during the database
design phase. Extension - It is the description of the actual database at a particular
time, and is likely to change frequently.
Data abstraction is the process of hiding irrelevant details from the users. Since a
database consists of complex data structures, data abstraction helps users to interact
easily with the database. For example, a user can interact with the system using the
GUI, but they may not necessarily know how the data is being stored in the backend.
Physical level - The physical level represents the lowest level of data abstraction. It shows
complex data structures and describes exactly how the data is stored.
Logical level - The logical level represents the middle level of data abstraction. It describes
the data stored in the database and the relationship between them.
View level - The view level represents the highest level of data abstraction
Proactive update - This update occurs inside the database before it even becomes
active in the real world.
Retroactive update - This update occurs in the database only after it occurs in the real
world.
Simultaneous update - This update occurs at the same time as it does in the real world.
All attributes that are unavailable, unknown, or have no assigned values fall under the
NULL category. Whereas both ZERO represents an integer and BLANK represents
an empty String value.
This depends entirely on the purpose of the database, as each model has its own
strengths. For example, if you want to use atomic data, a relational model works best.
If you want to use text or semi-structured data, the document model works best.
The VIEW level of data abstraction is typically given to users who only need the
details of the table schema. This makes sure that the complex structure of the table
and its physical storage are hidden from them.
The lazy way - Do nothing. Simply restart the operation to get out of the deadlock.
The proactive way - Preventing deadlocks to ever happen. Allocate the resources in such a
way that a deadlock will never occur.
When there is no primary key for a table, you should create a “surrogate key” which
acts as a pseudo key. It is simply a made up value which can be created by an auto
incrementing ID.
An index can be used when you want to enforce uniqueness in a database. You can
also use it to facilitate sorting and perform fast retrieval. A column that is frequently
used can be a good candidate for an index.