0% found this document useful (0 votes)
12 views

DBMS Interview Questions

SOmething

Uploaded by

Imran Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

DBMS Interview Questions

SOmething

Uploaded by

Imran Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Pdf 7 - dbms based questions

Q1. What is DBMS and what is its utility?

Answer:
DBMS stands for Database Management System, is a set of applications or programs
that enable users to create and maintain a database. DBMS provides a tool or an
interface for performing various operations such as inserting, deleting, updating, etc. into
a database. It is software that enables the storage of data more compactly and securely
as compared to a le-based system. A DBMS system helps a user to overcome problems
like data inconsistency, data redundancy, etc. in a database and makes it more
convenient and organized to use it.

Q2. Explain RDBMS with examples.

Answer:
RDBMS stands for Relational Database Management System and was introduced in
the 1970s to access and store data more e ciently than DBMS. RDBMS stores data in
the form of tables as compared to DBMS which stores data as les. Storing data as rows
and columns makes it easier to locate speci c values in the database and makes it more
e cient as compared to DBMS.
Examples of popular RDBMS systems are MySQL, Oracle DB, etc.

Q3. What is a Database?

Answer:
A Database is an organized, consistent, and logical collection of data that can easily be
updated, accessed, and managed. Database mostly contains sets of tables or objects
(anything created using create command is a database object) which consist of records
and elds. A tuple or a row represents a single entry in a table. An attribute or a column
represents the basic units of data storage, which contain information about a particular
aspect of the table.

Q4. Mention the issues with traditional le-based systems that make DBMS a better
choice?

Answer:
The absence of indexing in a traditional le-based system leaves us with the only option
of scanning the full page and hence making the access of content tedious and super
slow. The other issue is redundancy and inconsistency as les have many duplicate and
redundant data and changing one of them makes all of them inconsistent. Accessing data
is harder in traditional le-based systems because data is unorganized in them.

Another issue is the lack of concurrency control, which leads to one operation locking the
entire page, as compared to DBMS where multiple operations can work on a single le
simultaneously.

Integrity check, data isolation, atomicity, security, etc. are some other issues with
traditional le-based systems for which DBMSs have provided some good solutions.
ffi
fi
fi
fi
fi
fi
fi
ffi
fi
fi
fi
fi
Q5. Are NULL values in a database the same as that of blank space or zero?

Answer:
No, a NULL value is very di erent from that of zero and blank space as it represents a
value that is assigned, unknown, unavailable, or not applicable as compared to blank
space which represents a character and zero represents a number.
Example: NULL value in “number_of_courses” taken by a student represents that its value
is unknown whereas 0 in it means that the student hasn’t taken any courses
.

Q6. Explain di erent levels of data abstraction in a DBMS.

Answer:
The process of hiding irrelevant details from users is known as data abstraction. Data
abstraction can be divided into 3 levels:

• Physical Level: it is the lowest level and is managed by DBMS. This level consists
of data storage descriptions and the details of this level are typically hidden from
system admins, developers, and users.
• Conceptual or Logical level: it is the level on which developers and system
admins work and it determines what data is stored in the database and what is the
relationship between the data points.
• External or View level: it is the level that describes only part of the database and
hides the details of the table schema and its physical storage from the users. The
result of a query is an example of View level data abstraction. A view is a virtual
table created by selecting elds from one or more tables present in the database.

Q7. Explain the di erence between intension and extension in a database.

answer:
• Intension: Intension or popularly known as database schema is used to de ne the
description of the database and is speci ed during the design of the database and
mostly remains unchanged.
• Extension: Extension on the other hand is the measure of the number of tuples
present in the database at any given point in time. The extension of a database is
also referred to as the snapshot of the database and its value keeps changing as
and when the tuples are created, updated, or destroyed in a database.

Q8. Explain the di erence between the DELETE and TRUNCATE command in a
DBMS.

Answer:
DELETE command: this command is needed to delete rows from a table based on the
condition provided by the WHERE clause.

TRUNCATE command: this command is needed to remove complete data from a table
in a database. It is like a DELETE command which has no WHERE clause.
ff
ff
ff
fi
ff
fi
fi
Q9. What is a lock? Explain the major di erence between a shared lock and an
exclusive lock during a transaction in a database.

Answer:
A database lock is a mechanism to protect a shared piece of data from getting updated
by two or more database users at the same time. When a single database user or session
has acquired a lock then no other database user or session can modify that data until the
lock is released.
• Shared Lock: A shared lock is required for reading a data item and many
transactions may hold a lock on the same data item in a shared lock. Multiple
transactions are allowed to read the data items in a shared lock.
• Exclusive lock: An exclusive lock is a lock on any transaction that is about to
perform a write operation. This type of lock doesn’t allow more than one
transaction and hence prevents any inconsistency in the database.

Q10. What is meant by normalization and denormalization?

Answer:
Normalization is a process of reducing redundancy by organizing the data into multiple
tables. Normalization leads to better usage of disk spaces and makes it easier to maintain
the integrity of the database.
Denormalization is the reverse process of normalization as it combines the tables which
have been normalized into a single table so that data retrieval becomes faster. JOIN
operation allows us to create a denormalized form of the data by reversing the
normalization.

Q11. Explain the di erence between a 2-tier and 3-tier architecture in a DBMS.

Answer:
The 2-tier architecture refers to the client-server architecture in which applications at the
client end directly communicate with the database at the server end without any
middleware involved.

The 3-tier architecture contains another layer between the client and the server to
provide GUI to the users and make the system much more secure and accessible. In this
type of architecture, the application present on the client end interacts with an application
on the server end which further communicates with the database system.

Q12. What are the advantages of DBMS?

Answer:
• Redundancy control
• Restriction for unauthorized access
• Provides multiple user interfaces
• Provides backup and recovery
• Enforces integrity constraints
• Ensure data consistency
• Easy accessibility
• Easy data extraction and data processing due to the use of queries
ff
ff
Q13. What is a checkpoint in DBMS?

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

Q14. What do you mean by transparent DBMS?

Answer:
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.

Q15. What is DDL (Data De nition Language)?

Answer:
Data De nition Language (DDL) is a standard for commands which de nes the di erent
structures in a database. Most commonly DDL statements are CREATE, ALTER, and
DROP. These commands are used for updating data into the database.

Q16. What is DML (Data Manipulation Language)?

Answer:
Data 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.

Q17. What do you understand by query optimization?

Answer:
The term query optimization speci es an e cient 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 e cient and the process of determining the
e cient way is known as query optimization.

Q18. What is SQL and where is it used?

Answer:
ffi
fi
fi
fi
ffi
ffi
fi
ff
Structured Query Language is the core of the relational database which is used for
accessing and managing the databases. This language is used to manipulate and retrieve
data from a structured data format in the form of tables and holds relationships between
those tables. So, in layman terms, you can use SQL to communicate with the database.

Q19. What do you understand by sub-queries in SQL?

Answer:
A subquery is a query inside another query where a query is de ned to retrieve data or
information back from the database. In a subquery, the outer query is called as the main
query whereas the inner query is called subquery. Subqueries are always executed rst
and the result of the subquery is passed on to the main query. It can be nested inside a
SELECT, UPDATE or any other query. A subquery can also use any comparison operators
such as >,< or =.

Q20. Mention the di erences between UNION and UNION ALL

Answer:
UNION UNION ALL
Combines the Combines the
result of two or result set of two
more SELECT or more
statements SELECT
consisting of statements
distinct values consisting of
duplicate values
Syntax: UNION Syntax: UNION
ALL
Has low Has better
performance performance
than UNION than UNION, as
ALL, as duplicate rows
duplicate rows need not have
need to be to be removed.
removed.

Q21. What do you understand by CLAUSE in SQL?

Answer:
CLAUSE in SQL is used to limit the result set by mentioning a condition to the query. So,
you can use a CLAUSE to lter rows from the entire set of records.
Example: WHERE HAVING clause.

Q22. Mention the di erences between HAVING and WHERE clause?


ff
ff
fi
fi
fi
Answer:
HAVING WHERE
Used only with Used in a
SELECT GROUP BY
statement clause
Used with the Applied to each
GROUP BY row before they
function in a are a part of the
query GROUP BY
function in a
query
Note: Whenever GROUP BY is not used, HAVING behaves like a WHERE clause.

Q23. How can you perform pattern matching in SQL?

Answer:
You can perform pattern matching in SQL by using the LIKE operator. With the LIKE
operator, you can use the following symbols:
1. %(Percentage sign) – To match zero or more characters.

2. _ (Underscore) –To match exactly one character._’


Example:
SELECT * FROM Customers WHERE CustomerName LIKE ‘s%’
SELECT * FROM Customers WHERE CustomerName like ‘xyz

Q24. What does initial in SQL do?

Answer:
This function returns the string with the rst letter in uppercase and the rest of the letters
in lowercase.
Syntax: INITCAP(‘string’)

Q25. What are joins in SQL and what are the di erent types of joins?

Answer:
A JOIN clause is used to combine rows from two or more tables, based on a related
column between them. It is used to merge two tables or retrieve data from there. There
are 4 joins in SQL namely:
• Inner Join
• Right Join
• Left Join
• Full Join

Q26. Write a query to create a duplicate table with and without data present?

Answer:
CREATE TABLE DuplicateCustomer AS SELECT * FROM Customers;
fi
ff
Q27. Mention a query to calculate the even and odd records from a table

Answer:
Even records
SELECT CustomerID FROM (SELECT rowno, CustomerID from Customers) where
mod(rowno,2)=0;

Odd records
SELECT CustomerID FROM (SELECT rowno, CustomerID from Customers) where
mod(rowno,2)=1;

Q28. Write a query to remove duplicate rows from a table?

Note: To remove duplicate rows from a table, you have to initially select the duplicate
rows from the table without using the DISTINCT keyword.

SELECT CustomerNumber FROM Customers WHERE ROWID (SELECT MAX (rowid)


FROM Customers C WHERE CustomerNumber = C.CustomerNumber);

DELETE FROM Customers WHERE ROWID(SELECT MAX (rowid) FROM Customers C


WHERE CustomerNumber = C.CustomerNumber);

Q29. Mention a query to add email validation to your database

Answer:
SELECT Email FROM Customers WHERE NOT REGEXP_LIKE(Email, &amp;lsquo;[A-
Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}&amp;rsquo;, &amp;lsquo;i&amp;rsquo;);

Q30. What is an Extension of entity type?

Answer:
An extension of an entity type is speci ed as a collection of entities of a particular entity
type that are grouped into an entity set.

Q31. What is Join?

Answer:
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.

Q32. What is stored procedure?

Answer:
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
fi
a code which you need to use again and again then save that code and call that code
whenever it is required.

Q33. How do you communicate with an RDBMS?

Answer:
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.

Q34. What is the 3-Tier architecture?

Answer:
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.

Q35. What is BCNF?

Answer:
• BCNF: BCNF stands for Boyce-Codd Normal Form and is an advanced form of
3NF. It is also referred to as 3.5NF for the same reason. A table to be in its BCNF
normal form should satisfy the following conditions:
• The table should be in its 3NF i.e. satisfy all the conditions of 3NF.
• For every functional dependency of any attribute A on B
(A->B), A should be the super key of the table. It simply implies that A can’t be a
non-prime attribute if B is a prime attribute.

Q36. What is a candidate key?

Answer;
The candidate key represents a set of properties that can uniquely identify a table. Each
table may have multiple candidate keys. One key amongst all candidate keys can be
chosen as a primary key. In the below example since studentId and rstName can be
considered as a Candidate Key since they can uniquely identify every tuple.

Q37. What is a super key?

Answer:
The super key de nes a set of attributes that can uniquely identify a tuple. Candidate key
and primary key are subsets of the super key, in other words, the super key is their
superset.

Q38. What is a primary key?

Answer:
fi
fi
The primary key de nes a set of attributes that are used to uniquely identify every tuple.
In the below example studentId and rstName are candidate keys and any one of them
can be chosen as a Primary Key. In the given example studentId is chosen as the primary
key for the student table.

Q39. What is a unique key?

Answer:
The unique key is very similar to the primary key except that primary keys don’t allow
NULL values in the column but unique keys allow them. So essentially unique keys are
primary keys with NULL values.

Q40. What is an alternate key?

Answer:
All the candidate keys which are not chosen as primary keys are considered as alternate
Keys. In the below example, rstname and lastname are alternate keys in the database.

Q41. What is a foreign key?

Answer:
The foreign key de nes an attribute that can only take the values present in one table
common to the attribute present in another table. In the below example courseId from the
Student table is a foreign key to the Course table, as both, the tables contain courseId as
one of their attributes.

Q42. What is a composite key?

Answer:
A composite key refers to a combination of two or more columns that can uniquely
identify each tuple in a table. In the below example the studentId and rstname can be
grouped to uniquely identify every tuple in the table.

——————————————————————

TEST YOURSELF

Q1. An entity set is represented by what in an E-R diagram?


1. Circle
2. Rectangle
3. Diamond
4. Ellipse

Q2. A record in a relational DBMS is also known as:


1. Tuple
2. Attribute
fi
fi
fi
fi
fi
3. Relation
4. Criteria

Q3. What does ODBC in a database stand for:


1. Oral database connection
2. Oracle database connection
3. Open database connectivity
4. Oracle database connectivity

Q4. Which of the following represents a one-to-many relationship?


1. One teacher many students
2. One teacher one class
3. Many teachers one class
4. Many teacher one student

Q5. Which of the following contains information about the data stored in a DBMS?
1. Meta data
2. Directory
3. Sub data
4. Warehouse

Q6. Which of the following does DBA stand for?


1. Database administrator
2. Data administrator
3. Database attribute
4. Data analysis

Q7. In a DBMS, TCL means


1. Transaction control language
2. Transmission central language
3. Transaction central language
4. None of the above

Q8. Data Manipulation Language (DML) is not to


1. Create information table in the Database
2. Insertion of new information into the Database
3. Deletion of information in the Database
4. Modi cation of information in the Database

Q9. The minimal set of super key is called


1. Primary key
2. Secondary key
3. Candidate key
4. Foreign key

Q10. A data dictionary doesn't provide information about:


1. Where data is located
2. The size of the disk storage device
3. It allows a many-to-many relationship
fi
4. It is conceptually simple

————————————————————

Answers:
1. Rectangle
2. Tuple
3. Open database connectivity
4. one teacher many students
5. meta data
6. Database administrator
7. Transaction control language
8. Create information table in the Database
9. Candidate key
10. The size of the disk storage device

You might also like