Most Frequently asked DBMS interview questions:
In this article, we will discuss the most important DBMS Interview Questions in order to make you familiar with the type of questions that can be asked during a Job Interview related to the Database Management System (DBMS).
Basically, out of my personal experience, there is not any specific way or formula to get through an Interview Process and it totally depends on you and the type of Interviewer. But still, it’s good to be prepared on your profile for your own confidence and knowledge so that you don’t feel hesitant to answer the questions asked during an Interview.
This article includes almost all the important DBMS interview questions, covering all the basic concepts in simple terms along with examples for your easy understanding.
DBMS Interview Questions and Answers
Following is the list of the basic yet most important DBMS interview questions that can be asked in the Interview.
Q #1) What is DBMS used for?
Ans: DBMS, commonly known as Database Management System, is an application system whose main purpose revolves around the data. This is a system that allows its users to store the data, define it, retrieve it and update the information about the data inside the database.
Q #2) What is meant by a Database?
Ans: In simple terms, Database is a collection of data in some organized way to facilitate its user’s to easily access, manage and upload the data.
Q #3) Why is the use of DBMS recommended? Explain by listing some of its major advantages.
Ans: Some of the major advantages of DBMS are as follows:
- Controlled Redundancy: DBMS supports a mechanism to control redundancy of data inside the database by integrating all the data into a single database and as data is stored at only one place, the duplicity of data does not happen.
- Data Sharing: Sharing of data among multiple users simultaneously can also be done in DBMS as the same database will be shared among all the users and by different application programs.
- Backup and Recovery Facility: DBMS minimizes the pain of creating the backup of data again and again by providing a feature of ‘backup and recovery’ which automatically creates the data backup and restores the data whenever required.
- Enforcement of Integrity Constraints: Integrity Constraints are very important to be enforced on the data so that the refined data after putting some constraints are stored in the database and this is followed by DBMS.
- Independence of Data: It simply means that you can change the structure of the data without affecting the structure of any of the application programs.
Q #4) What is the purpose of normalization in DBMS?
Ans: Normalization is the process of analyzing the relational schemas which are based on their respective functional dependencies and the primary keys in order to fulfill certain properties.
The properties include:
- To minimize the redundancy of the Data.
- To minimize the Insert, Delete and Update Anomalies.
Q #5) What are the different types of languages that are available in the DBMS?
Ans: Basically, there are 3 types of languages in the DBMS as mentioned below:
- DDL: DDL is Data Definition Language which is used to define the database and schema structure by using some set of SQL Queries like CREATE, ALTER, TRUNCATE, DROP and RENAME.
- DCL: DCL is Data Control Language which is used to control the access of the users inside the database by using some set of SQL Queries like GRANT and REVOKE.
- DML: DML is Data Manipulation Language which is used to do some manipulations in the database like Insertion, Deletion, etc. by using some set of SQL Queries like SELECT, INSERT, DELETE and UPDATE.
Q #6) What is the purpose of SQL?
Ans: SQL stands for Structured Query Language whose main purpose is to interact with the relational databases in the form of inserting and updating/modifying the data in the database.
Q #7) Explain the concepts of a Primary key and Foreign Key.
Ans: Primary Key is used to uniquely identify the records in a database table while Foreign Key is mainly used to link two or more tables together as this is a particular field(s) in one of the database tables which are the primary key of some other table.
Example: There are 2 tables – Employee and Department and both have one common field/column as ‘ID’ where ID is the primary key of the Employee table while this is the foreign key for the Department table.
Q #8) What are the main differences between Primary key and Unique Key?
Ans: Given below are few differences:
- The main difference between the Primary key and Unique key is that the Primary key can never have a null value while the Unique key may consist of null value.
- In each table, there can be only one primary key while there can be more than one unique key in a table.
Q #9) What is the concept of sub-query in terms of SQL?
Ans: Sub-query is basically the query which is included inside some other query and can also be called as an inner query which is found inside the outer query.
Q #10) What is the use of DROP command and what are the differences between DROP, TRUNCATE and DELETE commands?
Ans: DROP command is a DDL command which is used to drop/delete the existing table, database, index or view from the database.
The major difference between DROP, TRUNCATE and DELETE commands are:
DROP and TRUNCATE commands are the DDL Commands which are used to delete tables from the database and 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 and so should be used with great care.
DELETE Command, on the other hand, is a DML Command which is also used to delete rows from the table and this can be rolled back.
Note: It is recommended to use ‘Where’ clause along with the DELETE command else the complete table will get deleted from the database.
Q #11) What is the main difference between UNION and UNION ALL?
Ans: UNION and UNION ALL are used to join the data from 2 or more tables but UNION removes duplicate rows and picks the rows which are distinct after combining the data from the tables whereas UNION ALL does not remove the duplicate rows, it just picks all the data from the tables.
Q #12) Explain the concept of ACID properties in DBMS?
Ans: ACID properties is the combination of Atomicity, Consistency, Isolation, and Durability properties. These properties are very helpful in allowing a safe and secure way of sharing the data among multiple users.
Atomicity: This is based on the concept of “either all or nothing” which basically means that if any update occurs inside the database then that update should either be available to all the others beyond user and application program or it should not be available to anyone beyond the user and application program.
Consistency: This ensures that the consistency is maintained in the database before or after any transaction that takes place inside the database.
Isolation: As the name itself suggests, this property states that each transaction that is occurring is in isolation with others i.e. a transaction which has started but not yet completed should be in isolation with others so that the other transaction does not get impacted with this transaction.
Durability: This property states that the data should always be in a durable state i.e. any data which is in the committed state should be available in the same state even if any failure or restart occurs in the system.
Q #13) What is Correlated Subquery in DBMS?
Ans: A Subquery is also known as a nested query i.e. a query written inside some query. When a Subquery is executed for each of the rows of the outer query then it is termed as a Correlated Subquery.
Example of Non-Correlated Subquery is:
Select * from EMP where ‘RIYA’ IN (Select Name from DEPT where EMP.EMPID=DEPT.EMPID)
Here, inner query is not executed for each of the rows of the outer query.
Q #14) Explain Entity, Entity Type, and Entity Set in DBMS?
Ans: Entity is an object, place or thing which has its independent existence in the real world and about which data can be stored in a database. Eg: any person, book, etc.
Entity Type is a collection of the entities which have the same attributes. Eg: STUDENT table contains rows in which each row is an entity holding attributes like name, age , and id of the students, hence STUDENT is an Entity Type which holds the entities having same attributes.
Entity Set is a collection of the entities of the same type. Eg: A collection of the employees of a firm.
Q #15) What are the different levels of abstraction in the DBMS?
Ans: There are 3 levels of data abstraction in the DBMS.
- Physical Level: This is the lowest level of the data abstraction which states how the data is stored in the database.
- Logical Level: This is the next level of the data abstraction which states the type of the data and the relationship among the data that is stored in the database.
- View Level: This is the highest level in the data abstraction which shows/states only a part of the database.
Q #16) What integrity rules exist in the DBMS?
Ans: There are 2 major integrity rules that exist in the DBMS.
- Entity Integrity: This states a very important rule that value of a Primary key can never have a NULL value.
- Referential Integrity: This rule is related to the Foreign key which states that either the value of a Foreign key is a NULL value or it should be the primary key of any other relation.
Q #17) What is E-R model in the DBMS?
Ans: E-R model is known as an Entity-Relationship model in the DBMS which is based on the concept of the Entities and the relationship that exists among these entities.
Q #18) What is a functional dependency in the DBMS?
Ans: This is basically a constraint which is useful in describing the relationship among the different attributes in a relation.
Example: If there is some relation ‘R1’ which has 2 attributes as Y and Z then the functional dependency among these 2 attributes can be shown as Y->Z which states that Z is functionally dependent on Y.
Q #19) What is 1NF in the DBMS?
Ans: 1NF is known as the First Normal Form.
This is the easiest form of the normalization process which states that the domain of an attribute should have only atomic values. The objective of this is to remove the duplicate columns that are present in the table.
Q #20) What is 2NF in the DBMS?
Ans: 2NF is the Second Normal Form.
Any table is said to have in the 2NF if it satisfies the following 2 conditions:
- A table is in the 1NF.
- Each non-prime attribute of a table is said to be functionally dependent in totality on the primary key.
Q #21) What is 3NF in the DBMS?
Ans: 3NF is the Third Normal Form.
Any table is said to have in the 3NF if it satisfies the following 2 conditions:
- A table is in the 2NFm.
- Each non-prime attribute of a table is said to be non-transitively dependent on every key of the table.
Q #22) What is BCNF in the DBMS?
Ans: BCNF is the Boyce Codd Normal Form which is stricter than the 3NF.
Any table is said to have in the BCNF if it satisfies the following 2 conditions:
- A table is in the 3NF.
- For each of the functional dependency X->Y that exists, X is the super key of a table.
Q #23) What is a CLAUSE in terms of SQL?
Ans: This is used with the SQL queries to fetch a specific data as per the requirements on the basis of the conditions that are put in the SQL. This is very helpful in picking the selective records from the complete set of the records.
Example: There is a query which has WHERE condition or the query with the HAVING clause.
Q #24) How can you get the alternate records from the table in the SQL?
Ans: If you want to fetch the odd numbers then the following query can be used:
Select EmpId from (Select rowno,EmpId from Emp) where mod(rowno,2)=1
If you want to fetch the even numbers then the following query can be used:
Select EmpId from (Select rowno,EmpId from Emp) where mod(rowno,2)=0
Q #25) How is the pattern matching done in the SQL?
Ans: With the help of the LIKE operator, pattern matching is possible in the SQL.’%’ is used with the Like operator when it matches with the 0 or more characters and ‘_’ is used to match the one particular character.
Select * from Emp where name like ‘b%’
Select * from Emp where name like ‘hans_’
Q #26) What is a join in the SQL?
Ans: A Join is one of the SQL statements which is used to join the data or the rows from 2 or more tables on the basis of a common field/column among them.
Q #27) What are different types of joins in the SQL?
Ans: There are 4 types of SQL Joins:
- Inner Join: This type of join is used to fetch the data among the tables which are common in both the tables.
- Left Join: This returns all the rows from the table which is on the left side of the join but only the matching rows from the table which is on the right side of the join.
- Right Join: This returns all the rows from the table which is on the right side of the join but only the matching rows from the table which is on the left side of the join.
- Full Join: This returns the rows from all the tables on which the join condition has put and the rows which do not match hold null values.
Q #28) What is meant by trigger?
Ans: Trigger is one of the very important codes or programs which get executed automatically in response to the events that occur in a table or a view. Eg: If a new record is inserted in an employee database then the data gets created automatically in the related tables like salary, department and roles tables.
Q #29) Explain Stored Procedure.
Ans: Stored Procedure is a group of SQL statements in the form of a function which has some unique name and is stored in a relational database management systems(RDBMS) and can be accessed whenever required.
Q #30) What is RDBMS?
Ans: RDBMS is the Relational Database Management System which contains data in the form of the tables and data is accessed on the basis of the common fields among the tables.
Q #31) What are the different type of relationships in the DBMS?
Ans: Relationships in DBMS depicts an association between the tables.
Different types of relationships are:
- One-to-One: This basically states that there should be a one-to-one relationship between the tables i.e. there should be one record in both the tables. Eg: Among a married couple, both wife and husband can have only one spouse.
- One-to-Many: This states that there can be many relationships for one i.e. a primary key table hold only one record which can have many, one or none records in the related table. Eg: A Mother can have many children.
- Many-to-Many: This states that both the tables can be related to many other tables. Eg: One can have many siblings and so do they have.
This is all about DBMS Interview Questions.
I hope that this article would have provided you a great insight regarding the questions that can be asked during an Interview and by now you should have gained the confidence to handle your interview process.
Do practice all the important practical topics of DBMS for better understanding.
Happy Reading!!Happy Testing!!