RDBMS 17 mostly asked interview questions and answers: RDBMS, foreign key, view, transaction , index, triggers, deadlock . Normalization: 1NF, 2NF,3NF.

0

 RDBMS Interview Questions and Answers

Q. What is RDBMS?

Answer: RDBMS stands for Relational Database Management System. It is a software system used to manage and store data in a structured way.


Q. What is a table in RDBMS?

Answer: A table is a collection of data organized in rows and columns. It is the basic unit of storage in an RDBMS.


Q. What is a primary key?

Answer: A primary key is a unique identifier for a record in a table. It ensures that each record is unique and can be accessed quickly and efficiently.


Q. What is a foreign key?

Answer: A foreign key is a field in a table that refers to the primary key in another table. It is used to establish relationships between tables.


Q. What is normalization?

Answer: Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity.


Q. What are the different levels of normalization?

Answer: There are six levels of normalization, ranging from first normal form (1NF) to sixth normal form (6NF).


Q. What is a view in RDBMS?

Answer: A view is a virtual table that is based on the result of a SELECT query. It does not actually store data, but provides a way to access data from one or more tables.


Q. What is an index in RDBMS?

Answer: An index is a data structure used to improve the speed of data retrieval. It contains a subset of the data in a table and provides a way to quickly search for specific data.


Q. What is a transaction in RDBMS?

Answer: A transaction is a set of database operations that are executed as a single unit of work. It ensures that all operations are completed successfully or none of them are completed at all.


Q. What is a trigger in RDBMS?

Answer: A trigger is a stored procedure that is executed automatically in response to a specific event, such as an insert, update, or delete operation.


Q. What is a stored procedure in RDBMS?

Answer: A stored procedure is a set of SQL statements that are stored in the database and can be executed repeatedly. It is used to encapsulate complex logic and improve performance.


Q. What is a cursor in RDBMS?

Answer: A cursor is a mechanism used to traverse the rows of a result set one at a time. It is used when processing large amounts of data and allows for more precise control over the data retrieval process.


Q. What is a deadlock in RDBMS?

Answer: A deadlock is a situation where two or more transactions are waiting for each other to release resources, preventing any of them from completing.


Q. What is ACID in RDBMS?

Answer: ACID stands for Atomicity, Consistency, Isolation, and Durability. It is a set of properties that ensure that database transactions are processed reliably.


Q. What is a constraint in RDBMS?

Answer: A constraint is a rule that is enforced by the database to ensure the integrity of the data. It can be used to enforce rules such as uniqueness, referential integrity, and data type.


Q. What is the difference between a left join and a right join?

Answer: A left join returns all the rows from the left table and matching rows from the right table, while a right join returns all the rows from the right table and matching rows from the left table.


Q. What is the difference between a primary key and a unique key?

Answer: A primary key is a unique identifier for a record in a table, while a unique key ensures that a column or combination of columns contains only unique values.

Normalization

Normalization is the process of organizing data in a relational database to minimize redundancy and improve data integrity. This process involves breaking down a table into smaller, more manageable tables and establishing relationships between them. The goal of normalization is to eliminate data redundancy and ensure that data is stored in a way that reduces data inconsistencies and errors. There are several normalization forms, each building on the previous form to achieve a higher degree of normalization. In this answer, 

we will discuss the three most common normalization forms: First Normal Form (1NF), Second Normal Form (2NF), and Third Normal Form (3NF).


First Normal Form (1NF):

The first step in the normalization process is to ensure that a table is in 1NF. A table is said to be in 1NF if it meets the following conditions:

  • There are no repeating groups or arrays in any of the columns.

  • Each column has a unique name.

  • The order of the columns does not matter.

  • Each row is unique, and there are no duplicate rows.


Let’s consider the following table:

Customer (Customer_ID, Customer_Name, Order1, Order2, Order3)

This table violates the 1NF condition of having no repeating groups. The Order columns represent multiple values, which should be stored in separate rows. To normalize this table to 1NF, we can split it into two tables:

Customer (Customer_ID, Customer_Name)

Orders (Customer_ID, Order)


Second Normal Form (2NF):

A table is in 2NF if it is in 1NF and every non-key attribute is fully dependent on the primary key. This means that each non-key attribute is dependent on the entire primary key, not just part of it.


Let’s consider the following table:

Customer (Customer_ID, Customer_Name, Order_ID, Order_Date, Product, Price)

This table violates the 2NF condition because the non-key attributes (Order_Date, Product, Price) are dependent on only part of the primary key (Order_ID). To normalize this table to 2NF, we can split it into two tables:

Customer (Customer_ID, Customer_Name)

Orders (Order_ID, Customer_ID, Order_Date)

Order_Items (Order_ID, Product, Price)


Third Normal Form (3NF):

A table is in 3NF if it is in 2NF and every non-key attribute is non-transitively dependent on the primary key. This means that if a non-key attribute is dependent on another non-key attribute, then the two attributes should be in a separate table.


Let’s consider the following table:

Customer (Customer_ID, Customer_Name, City, State, Zip)

This table violates the 3NF condition because City, State, and Zip are dependent on each other, rather than on the primary key. To normalize this table to 3NF, we can split it into two tables:

Customer (Customer_ID, Customer_Name)

Address (Customer_ID, City, State, Zip)


Normalization is an important process in RDBMS that helps to minimize data redundancy and improve data integrity. It involves breaking down tables into smaller, more manageable tables and establishing relationships between them. The three most common normalization forms are 1NF, 2NF, and 3NF, each building on the previous form to achieve a higher degree of normalization. By properly normalizing a database, data inconsistencies and errors can be minimized, and the overall efficiency and reliability of the database can be improved.



Post a Comment

0Comments
Post a Comment (0)