1. What is a DBMS?
A DBMS (Database Management System) is a software system designed to manage
databases. It provides a systematic way to store, retrieve, and manipulate data
efficiently. A DBMS ensures data integrity, security, and consistency. It allows multiple
users to interact with the database simultaneously and offers a centralized data
management system.
2. What are the types of DBMS?
There are four primary types of DBMS:
● Hierarchical DBMS: Data is structured in a tree-like format. Each record has a
single parent, making it suitable for applications like banking systems.
● Network DBMS: Data is represented using graphs where multiple relationships
between records exist.
● Relational DBMS (RDBMS): Data is stored in tables with rows and columns.
The RDBMS utilizes Structured Query Language (SQL) for managing and
manipulating data..
● Object-Oriented DBMS: Data is represented as objects, similar to
object-oriented programming concepts, and it integrates database capabilities
with object-oriented
● programming features.
3. What is SQL?
SQL defines Structured Query Language as a standard programming language. It is
used for managing and querying data in a relational database. It allows users to interact
with the database by operating such as SELECT, INSERT, DELETE, and UPDATE.
SQL is used for various purposes, including defining a database's structure (DDL),
managing data (DML), and controlling user access (DCL).
4. What are the relationship types in DBMS?
In DBMS, relationships between tables are defined by how they are connected. There
are three primary types of primary relationships:
● One-to-One: Each record in one table is connected to one record in another
table.
Example: A person has one passport.
● One-to-Many: A single record in one table connects to many records in another
table.
Example: One customer can have multiple orders.
● Many-to-Many: Multiple entries in one table can be connected to multiple entries
in another table.
Example: In a system involving students and courses, each student can enroll in various
courses, and each course can have several students.
5. What is a database?
Databases are structured collections of data stored and accessed electronically. It
provides a systematic way to manage, store, and retrieve data for different applications.
6. What is normalization?
A normalization process involves dividing large tables into smaller ones to reduce
redundancy and dependency in a database. It ensures that each piece of information is
stored in the right place, eliminating anomalies like update, insertion, and deletion
anomalies. The goal is to ensure that each table contains only related data, thus
improving data integrity and efficiency.
7. Explain the different normal forms in DBMS.
Normalization involves multiple stages, or "normal forms," to eliminate data redundancy
and dependency:
● 1NF (First Normal Form): Ensures that each column contains atomic
(indivisible) values and that there are no repeating groups or arrays.
● 2NF (Second Normal Form): Builds on 1NF and removes partial dependencies,
ensuring that every non-key attribute is fully dependent on the primary key.
● 3NF (Third Normal Form): Removes transitive dependencies, ensuring that
non-key attributes are only dependent on the primary key.
● BCNF (Boyce-Codd Normal Form): A stricter version of 3NF that ensures every
determinant is a candidate key.
● 4NF (Fourth Normal Form): Deals with multi-valued dependencies, ensuring
that no table contains more than one independent multi-valued dependency.
8. What is a primary key?
A primary key serves as a unique identifier for each entry in a database table. It ensures
that no two rows in the table can have the same value in the primary key column(s). A
primary key is crucial for maintaining data integrity and is used to establish relationships
with other tables through foreign keys. A primary key cannot have NULL values.
9. What is a foreign key?
A foreign key is a column in a table that uniquely identifies a row in another table, or in
the same table when referencing itself. It is used to create and maintain a relationship
between the data in two tables, ensuring that the connection between them remains
consistent and valid. The foreign key column in one table points to the primary key in
another table, ensuring valid data relationships.
10. What is an index?
An index is a database object that improves the speed of data retrieval operations on a
table. It works similarly to an index in a book, allowing the database to quickly locate the
rows without having to search the entire table. Indexes can be created on one or more
columns, and although they speed up query performance, they can slow down data
modification operations like insertions, deletions, and updates.
11. What is join in SQL?
JOIN is used to combine rows from two or more tables based on a related column
between them. Joins allow you to retrieve data that is spread across multiple tables in a
relational database. The most commonly used joins are INNER JOIN, LEFT JOIN,
RIGHT JOIN, and FULL OUTER JOIN. These types of join determine how unmatched
rows are handled in SQL JOINS.
12. Differentiate between INNER JOIN and Outer JOIN.
Here are the differences between INNER JOIN and OUTER JOIN:
INNER JOIN OUTER JOIN
Returns only the matching values in Returns all rows from one table and
both tables. matched rows from the other;
non-matching rows will have NULLs.
Used when you need data that Used when you need all data from one or
exists in both tables, e.g., matching both tables, even if no matching data
customer orders. exists.
It does not have any JOINS. It consists of three types: LEFT OUTER
JOIN, RIGHT OUTER JOIN, and FULL
OUTER JOIN.
13. Explain the ACID properties.
The ACID properties maintain the consistency and reliability of transactions in a
database are:
● Atomicity: Ensures that a transaction is treated as a single unit, meaning either
all of its operations are successfully executed or none of them are.
● Consistency: Ensures that each transaction maintains the database's integrity
while shifting it from one valid state to another.
● Isolation: Ensures that transactions are isolated from each other, meaning the
operations of one transaction are not visible to others until the transaction is
completed.
● Durability: Assures that once a transaction is committed, its changes are
permanent, even if there is a system disruption.
14. What is a transaction in DBMS?
A transaction in DBMS is a sequence of one or more operations that are executed as a
single unit of work. These operations typically include INSERT, UPDATE, or DELETE
commands. A transaction ensures that the database is always in a consistent state by
adhering to the ACID properties. Transactions help in managing changes to the
database effectively and are used in scenarios where multiple operations need to be
executed in sequence.
15. What is a deadlock in DBMS?
A deadlock is a situation that occurs when two or more transactions are blocked forever,
each waiting for the other to release resources. In a deadlock, no transaction can
proceed because each one holds a resource that the other needs. The DBMS must
detect and resolve deadlocks by aborting one of the transactions, allowing others to
proceed. This is typically handled by deadlock prevention and detection algorithms.
16. What is a view in DBMS?
A view in DBMS is a virtual table created by a query that combines data from one or
more tables. Unlike a physical table, a view does not store data itself; it only provides a
way to view data based on the underlying tables. Views can simplify complex queries,
provide a level of abstraction, and enhance security by restricting access to sensitive
data. They can also be used to hide complexity or ensure consistency.
17. What is a trigger in DBMS?
A trigger is a set of SQL statements that are automatically executed in response to
certain events on a particular table or view. These events include INSERT, UPDATE, or
DELETE operations. Triggers are commonly used to enforce business rules, ensure
data integrity, or automatically generate values such as timestamps. They can be set to
execute either before or after the triggering event.
18. What are the advantages of DBMS?
DBMS offers numerous advantages, including:
● It ensures accuracy and consistency
● Provides mechanisms for data access control
● Minimizes duplication of data
● Data Independence
● Improved Data Sharing
19. What is data redundancy?
Data redundancy refers to the excessive duplication or repetition of data within a
database. It leads to inefficient use of storage, inconsistencies, and difficulties in
updating data. Redundant data can cause errors such as update, insert, or delete
anomalies. Normalization is employed in DBMS to eliminate redundancy by dividing the
data into multiple tables that can be linked using keys.
20. What is data independence?
Data independence refers to the ability of a database system to change its schema
without affecting the application programs. It is classified into two types:
● Logical Data Independence: The ability to change the logical schema (e.g.,
adding new fields) without affecting the application programs.
● Physical Data Independence: The ability to change the physical schema (e.g.,
how data is stored) without affecting the logical schema or application programs.
Data independence is a key advantage of using a DBMS over traditional file
systems.
21. What is the purpose of the GROUP BY clause in SQL?
The GROUP BY clause in SQL is used to organize rows with identical values in
specified columns into summary rows. It is commonly used with aggregate functions like
COUNT, SUM, AVG, MIN, and MAX to perform calculations on each group of rows. For
example, you can use the GROUP BY clause to calculate the total sales by each region
or count the number of employees in each department. It helps organize data and
generate reports.
22. What is schema in DBMS?
In DBMS, a schema defines the structure of a database, including tables, relationships,
views, and constraints. It serves as a blueprint, outlining how data is organized and
accessed.
23. What is a relational database in DBMS?
A relational database is a type of database that organizes data into tables consisting of
rows and columns, using a relational model to structure the data. The tables in a
relational database are linked to each other using keys.
24. What is a Composite Key?
A composite key consists of two or more columns in a table that, when combined,
uniquely identify a record. Each column in the composite key may not uniquely identify a
row, but when combined, they provide uniqueness. Composite keys are useful when no
single column can serve as a primary key.
25. What are the various types of joins in SQL?
In SQL, the following join types are used to retrieve data from multiple tables:
● INNER JOIN: Fetches rows that have corresponding matches in both tables.
● LEFT JOIN (LEFT OUTER JOIN): Fetches all rows from the left table and the
matched rows from the right table. When no match is found, the columns from
the right table are filled with NULL values.
● RIGHT JOIN (RIGHT OUTER JOIN): Fetches all rows from the right table and
the matched rows from the left table. NULL values are returned for the left table
columns if there’s no match.
● FULL JOIN (FULL OUTER JOIN): Retrieves all rows when there is a match in
either of the tables, with NULL values where there is no match.
● CROSS JOIN: Merges each row from the first table with every row from the
second table, creating a Cartesian product.
● SELF JOIN: Joins a table to itself, which is useful for comparing rows within the
same table.