This article contains 100 most frequently asked questions on Database Management System. These questions are extracted from various interview experiences, held at various locations and companies.
Download the e-books of Interview Questions : here
SET 1 – Q1 – Q5
Q. What is Data ?
A. Data refers to raw facts and figures that can be recorded.
Q. What is Database ?
A. Database refers to the collection of interrelated and coherent data.
Q. Explain DBMS ?
A. DBMS stands for Database Management System. It is a software package designed to define, manipulate, retrieve and manage data in database.
Q. Why DBMS ?
A. To make information easy to access and protected, we use database management systems. DBMS is important because it manages the data efficiently and allow users to perform multiple tasks on it with the ease.
Q. Name some of the popular Database Management System ?
A. MySQL, Oracle, SQL Server, Amazon simple DB (Cloud-based), etc.
SET 2 – Q6 – Q10
Q. What is a database system?
A. The collection of database and DBMS software together is known as a database system.
Q. What do you mean by Data Modelling ?
A. Data Modelling is the set of conceptual tools for describing data relationship, data semantics, and consistency constraints. Different data models are : Network model, Relational model, Object Oriented model, ER model, and more.
Q. Explain RDBMS ?
A. RDBMS stands for Relational Database Management System. It arranges information into allied rows and columns. RDMS is an information management system which is oriented on a data model. RDBMS Example systems are SQL Server, Oracle, MySQL, MariaDB and SQLite.
Q. Explain Abstraction of Data, with reference to DBMS ?
A. Data Abstraction refers to the process of hiding background details from user.
Q. Explain the 3 L’s of Data Abstraction ?
A. It refers to three levels of abstraction. They are :
1. Physical Level : It is lowest level of abstraction. It describes how data is actually stored. It also describes complex data structure in detail.
2. Logical Level : It describes what data get stored in the database and what are the relationships among them.
3. View Level : It is the highest level of data abstraction that only describes a part of database indirectly.
SET 3 – Q11 – Q15
Q. What are the disadvantages of using Flat File System ?
A. 1. Data Redundancy and Inconsistency.
2. Difficulty in accessing data.
3. Data Isolation.
4. Integrity Problem.
5. Security Issues.
Q. What is Database Schema ?
A. Schema refers to the overall structure of database without data values.
Q. What do you mean by transparent DBMS?
A. The transparent DBMS is a type of DBMS which keeps its physical structure hidden from users.
Q. Explain ER Model ?
A. This model is based on the perception of real world that consists of collection of basic entities and relationship among these objects. It is the graphical representation of the database.
Q. What do you understand by Data Independency ?
A. It refers to the capacity to change data at one level without affecting next higher level is called Data Independence. It is of two types : Physical DI, Logical DI.
Physical DI : It indicates that physical storage of device could be changed without affecting conceptual view.
Logical DI : It indicates that conceptual schema can be changed without affecting existing external schema.
SET 4 – Q16 – Q20
Q. What is a Database Language ?
A. Database Language is a medium by which we can interact with the database system through some set of commands. These commands are structured.
Q. What are different types of database languages ?
A. 1. DDL : Data Definition Language defines different structures in database.
Example – create, alter, drop, truncate are some DDL commands.
2. DML : Data Manipulation Language allows database user to manipulate data.
Example – insert, insert into, update, delete, select are DML commands.
3. TCL : Transaction Control Language commands are used to manage transactions in the database.
Example – commit, rollback, savepoint are TCL commands.
4. DCL : Data Control Language is used to control access to data stored in a database.
Example – Grant, Revoke are DCL commands.
Q. Suppose we want to insert multiple values in a table at same time. How we can do this?
A. We can add multiple values at same time using insert into statement.
INTO table_name (col1, col2, ….., coln) VALUES (expr1, expr2, expr_n)
INTO table_name(col1, col2, ….., coln) VALUES (expr1, expr2, expr_n)
SELECT * FROM dual;
Q. List the difference between following commands : drop, truncate, delete.
A. drop and truncate commands are the DDL commands, used to delete tables from the database. Once the table gets deleted, all the privileges and indexes that are related to the table also get deleted. These 2 operations cannot be rolled back.
On the other hand, delete is a DML Command which is also used to delete rows from the table and this can be rolled back.
Q. What is a Tuple ?
A. A single row of a table, which contains a single record for that relation is called a tuple.
SET 5 – Q21 – Q25
Q. Explain degree and Cardinality ?
A. Degree is the total number of attributes in a relation or table and cardinality is total number of tuples/rows in a relation/table.
Q, What is a relation in DBMS ?
A. A database relation refers to an individual table in a relational database. A table is a relation because it stores the relation between data in its column-row format.
Q. What are the different types of relationship in DBMS ?
A. There are basically three types of relationship, that can be defined among various different objects.
One-To-One: In this, one record of an object relates to one record of another object.
One-To-Many/ Many-To-One : In this, one record of an object relates to many records of other object and vice versa.
Many-To-Many: In this, more than one records of an object relates to ‘n’ number of records of another object.
Q. What is the role of DML Compiler ?
A. It translates DML statements in a query language into low-level instructions that the query evaluation engine can easily understand.
Q. Explain me the role of using clause for queries ?
A. Clause enables you to specify conditions that filters the results as per the requirement. Some of the most commonly used clauses are : having, where etc.
SET 6 – Q26 – Q30
Q. What is a Query ?
A. Query is a statement that is used for the extraction of data from database.
For example – select * from table1 is a query.
Q. What is Subquery ?
A. Subquery is a query within query.
For example – select * from students where marks = ( select max(marks) from students);
Q. What are the ACID properties in DBMS ?
Q. Give brief information about entity, entity type, entity set ?
A. Entity is any real world object about which data can be stored in a database.
Example – Book, Person.
Entity Type is a collection of the entities which have the same attributes.
Example – Employee table is an entity type containing ‘n’ rows, in which each row defines different data for different entities
Entity Set is a collection of the entities of the same type.
Example – A collection of the employees of a company.
Q. What is Normalization ?
A. Normalization refers to the decomposition of relation. It is required to remove data anomalies, data redundancy and data inconsistency. Normalization of a database increases more restrictions on it.
Most commonly used normal forms are :
First Normal Form
Second Normal Form
Third Normal Form
Boyce & Codd Normal Form
SET 7 – Q31 – Q35
Q. What are the rules for 1 NF ?
A. 1. Each table cell should contain a single value.
2. Each record needs to be unique.
Q. What is 2 NF ?
A. A relation is said to be in 2 NF, if it satisfies following rules :
1. It is in 1 NF.
2. Every non-prime attribute is fully functionally dependent on the primary key.
Q. What is 3 NF ?
A. A relation is said to be in 3 NF, if it satisfies following rules :
1. It is in 2 NF.
2. There is no transitive functional dependency.
Q. Explain BCNF ?
A. BCNF is Boyce-Codd Normal Form. It is considered to be the advanced version of 3 NF. Hence it is also refered to as 3.5 NF. A relation is said to be in BCNF, if it satisfies following rules :
1. It is in 3NF.
2. For every functional dependency P->Q, P should be the super key of the table.
Q. What are Stored Procedures ?
A. Stored Procedure refers to the set of Structured Query Language(SQL) statements stored in a relational database management system as a group. It can further be reused and shared by multiple programs. It provides a layer of security between a user interface and database.
SET 8 – Q36 – Q40
Q. Can you create a table without using create command ?
A. Yes, we can create table with the help of SELECT INTO statement. It copies content of one table to another table. However, there should be atleast one table from where we can copy content.
Copying all columns : select * into new_table from old_table where condition
Copying specific column : select col1,col2 into new_table from old_table where condition
Creating new empty table : select * into new_table from old_table where 1 = 0
Q. What is Denormalization ?
A. It is the reverse process of Normalization. It is the process of trying to improve the readability of the database by grouping data. Denormalization is also used for speeding up the performance.
Q. What are Joins ?
A. Join clause are used to combine rows from two or more tables, depending upon the columns between them.
Q. What are the different types of Joins ?
A. Different types of Joins are :
1. INNER JOIN : It returns all records that are common in both tables.
2. LEFT OUTER JOIN : It returns all records from the left table, and matched records from right table.
3. RIGHT OUTER JOIN : It returns all records from the right table, and matched records from left table.
4. FULL OUTER JOIN : It returns all records when there is a match in either left or right table.
Q. Explain Transaction ?
A. Transaction refers to the collection of multiple statements, that are responsible for transferring a database from one consistent state to another consistent state.
SET 9 – Q41 – Q45
Q. Explain the role of views in database ?
A.View refers to the virtual table. We can create view using create view statement.
CREATE VIEW as Select col1
Q. Explain Trigger ?
A. Triggers are defined as special kind of stored programs, which are automatically executed whenever a specific operation occurs in the database server.
Q. What are Locks ?
A. Locking is the mechanism to protect data integrity and ensure data consistency during transactions. Locks are the most common cause of blocked processes. Stronger the Isolation level, more the chances of blocking.
Q. Explain different types of Locks ?
A. Locks are broadly characterized into following types :
Shared Locks : These locks are acquired by readers during read operations. In other words, these locks exist when two transactions are granted read access. Data updation is not allowed until shared lock is released.
Exclusive Locks : In exclusive lock, data items can be both read as well as written by the transaction. In Exclusive lock, multiple transactions do not modify the same data simultaneously.
Q. What is Super Key ?
A. An attribute or set of attributes that uniqueness in database is refered to as Super key. It is the superset of Candidate key.
SET 10 – Q46 – Q52
Q. What is Candidate Key ?
A. A minimal set of attribute/attributes that can be used to uniquely identify a single row in a given relation is refered to as Candidate key.
Q. Explain Primary Key ?
A. DB Designer selects one of the candidate key as primary key for a relation for the purpose of identification of a tuple uniquely. It is identified during table creation.
Q. What is Composite Key ?
A. If a primary key has more than one attribute, then it is refered to as Composite key.
Q. Explain Foreign Key ?
A. A set of attribute/attributes that is used to establish and enforce a link between data in two or more relations.
Q. Can a table have more than one primary key ?
Q. Can We Have NULL Value in Primary Key?
Q. What are cursors ?
A. A cursor is a temporary work area created in system memory when a SQL statement is executed. A cursor can hold more than one row, but can process only one row at a time.
So, these are most frequently asked interview questions on DBMS.
We, at CODE OF GEEKS, wish you all the best for your upcoming future.