If you are preparing for a Database Management System interview, then you have reached the right place.
Computer Science Engineering is a broad field of study that deals with the Database Management System.It is a fast-growing field that has many opportunities for career growth. A Database Management System interview is a type of interview that is designed to assess a candidate's knowledge of Computer Science Engineering . The purpose of the interview is to evaluate the candidate's knowledge and deep understanding of subject.
The interview may also assess the candidate's communication skills, such as the ability to present complex information in a clear and concise manner.
The Interview is typically conducted by a hiring manager or recruiter who has experience in the field. The interviewer will typically ask a series of questions about the candidate's background and experience. The interviewer will also ask about the candidate's strengths and weaknesses.
This list of interview questions in Database Management System includes basic-level, advanced-level, and program-based interview questions.
Here are the commonly asked question list of Database Management System (Computer Science Engineering) interview questions and answers that you must prepare for fresher as well as experienced candidates to get your dream job.
DBMS stands for Database Management System, is a set of applications or programs that enable 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. A DBMS system helps a user to overcome problems like data inconsistency, data redundancy, etc. in a database.
Some popular Database Management System- MySQL, Oracle, SQL Server, Amazon simple DB (Cloud-based), etc.
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.
>
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.
A software application that interacts with databases, applications, and users to capture and analyze the required data. The data stored in the database can be retrieved, deleted and modified based on the client’s requirement.
The different types of DBMS are as follows:
The advantages of DBMS are as follows:
Database language implies the queries that are used for the update, modify and manipulate the data. The different languages present in DBMS are as follows:
Super Key : A super key is a set of attributes of a relation schema upon which all attributes of the schema are functionally dependent. No two rows can have the same value of super key attributes.
Candidate Key : A Candidate key is a minimal superkey, i.e., no proper subset of Candidate key attributes can be a superkey.
Primary Key : A Primary Key is one of the candidate keys. One of the candidate keys is selected as most important and becomes the primary key. There cannot be more than one primary key in a table..
Foreign key : A Foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table.
The primary key cannot have NULL value, the unique constraints can have NULL values. There is only one primary key in a table, but there can be multiple unique constrains.
ACID stands for Atomicity, Consistency, Isolation, and Durability in a DBMS these are those properties that ensure a safe and secure way of sharing data among multiple users.
The process of hiding irrelevant details from users is known as data abstraction. Data abstraction can be divided into 3 levels:
Following are different types of relationship amongst tables in a DBMS system:
It is a process of analyzing the given relation schemas based on their functional dependencies and primary keys to achieve the following desirable properties:
The process of organizing data to avoid any duplication of data and redundancy is known as Normalization. There are many successive levels of normalization which are known as normal forms. Each consecutive normal form depends on the previous one. The following are the first three normal forms. Apart from these, you have higher normal forms such as BCNF.
Some of the major advantages of DBMS are as follows:
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.
The term query optimization specifies an efficient 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 efficient and the process of determining the efficient way is known as query optimization.
There are many benefits of query optimization:
Denormalization is the process of boosting up database performance and adding of redundant data which helps to get rid of complex data. Denormalization is a part of database optimization technique. This process is used to avoid the use of complex and costly joins. Denormalization doesn't refer to the thought of not to normalize instead of that denormalization takes place after normalization. In this process, firstly the redundancy of the data will be removed using normalization process than through denormalization process we will add redundant data as per the requirement so that we can easily avoid the costly joins.
E-R model is a short name for the Entity-Relationship model. This model is based on the real world. It contains necessary objects (known as entities) and the relationship among these objects. Here the primary objects are the entity, attribute of that entity, relationship set, an attribute of that relationship set can be mapped in the form of E-R diagram.
In E-R diagram, entities are represented by rectangles, relationships are represented by diamonds, attributes are the characteristics of entities and represented by ellipses, and data flow is represented through a straight line.
There are mainly 7 types of Keys, that can be considered in a database. I am going to consider the below tables to explain to you the various keys.
Candidate Key
This is a set of attributes which can uniquely identify a table. Each table can have more than a candidate key. Apart from this, out of all the candidate keys, one key can be chosen as the Primary key. In the above example, since CustomerID and PanNumber can uniquely identify every tuple, they would be considered as a Candidate Key.
Super Key
This is a set of attributes which can uniquely identify a tuple. So, a candidate key, primary key, and a unique key is a superkey, but vice-versa isn’t true.
Primary Key
This is a set of attributes which are used to uniquely identify every tuple. In the above example, since CustomerID and PanNumber are candidate keys, any one of them can be chosen as a Primary Key. Here CustomerID is chosen as the primary key.
Unique Key
The unique key is similar to the primary key, but allows NULL values in the column. Here the PanNumber can be considered as a unique key.
Alternate Key
Alternate Keys are the candidate keys, which are not chosen as a Primary key. From the above example, the alternate key is PanNumber
Foreign Key
An attribute that can only take the values present as the values of some other attribute, is the foreign key to the attribute to which it refers. in the above example, the CustomerID from the Customers Table is referred to the CustomerID from the Customer_Payment Table.
Composite Key
A composite key is a combination of two or more columns that identify each tuple uniquely. Here, the CustomerID and Date_of_Payment can be grouped together to uniquely identify every tuple in the table.
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 a code which you need to use again and again then save that code and call that code whenever it is required.
When you say an application has data independence, it implies that the application is independent of the storage structure and data access strategies of data.
1NF is the First Normal Form. It is the simplest type of normalization that you can implement in a database. The primary objectives of 1NF are to:
2NF is the Second Normal Form. A table is said to be 2NF if it follows the following conditions:
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
BCMF stands for Boyce-Codd Normal Form. It is an advanced version of 3NF, so it is also referred to as 3.5NF. BCNF is stricter than 3NF.
A table complies with BCNF if it satisfies the following conditions:
Indexes are data structures responsible for improving the speed of data retrieval operations on a table. This data structure uses more storage space to maintain extra copies of data by using additional writes. So, indexes are mainly used for searching algorithms, where you wish to retrieve data in a quick manner.
The differences between clustered and non-clustered index are :
Triggers
Stored Procedures
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.
There are 4 types of SQL Joins:
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.
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 only when necessary.
DELETE command, on the other hand, is a DML Command which is used to delete rows from the table and this can be rolled back.
In Network model - Each parent node can have multiple children nodes and vice versa. In Hierarchical Database Model A top-down structure where each parent node can have many child nodes. But, a child node can have only a single parent node.
In Network model - Supports one-to-one, one-to-many, and many-to-many relationships. In Hierarchical Database Model Supports one-tone and one-to-many relationships.
CLAUSE in SQL is used to limit the result set by mentioning a condition to the query. So, you can use a CLAUSE to filter rows from the entire set of records.
Example: WHERE HAVING clause.
Note: Whenever GROUP BY is not used, HAVING behaves like a WHERE clause.
HAVING | WHERE |
Used only with SELECT statement | Used in a GROUP BY clause |
Used with the GROUP BY function in a query | Applied to each row before they are a part of the GROUP BY function in a query |