DBMS May-2024 Ans
DBMS May-2024 Ans
5. What is deadlock?
-> In the context of databases and operating systems, a deadlock is a situation
where two or more processes are unable to proceed because each is waiting for
the other to release a resource.
This creates a cycle of dependencies that leads to a standstill, where none of
the processes can make progress.
Non-Procedural DML:
Specifies what data operations are needed, not how to perform them.
Describes the desired result.
Example: SQL SELECT statements.
Q.4 Answer the following in detail.
1. What are the advantages of DBMS?
a) Data Redundancy and Inconsistency Reduction:
DBMS ensures that all data is stored centrally, reducing redundancy and
minimizing inconsistencies. This eliminates the need for multiple copies of the
same data, which can often lead to discrepancies.
b) Data Integrity and Accuracy:
Integrity constraints in DBMS enforce rules on the data being entered,
ensuring its accuracy and consistency. This helps in maintaining high-quality
data which is critical for decision-making processes.
c) Data Security:
DBMS provides robust security measures to protect sensitive data. Access
controls and authorization mechanisms ensure that only authorized users can
access or manipulate data, safeguarding it from unauthorized access and
breaches.
d) Data Sharing and Concurrent Access:
Multiple users can access and work with data simultaneously in a DBMS
without conflicts, thanks to mechanisms like locking, transaction management,
and concurrency control. This enhances collaboration and productivity.
e) Backup and Recovery:
DBMS offers automatic backup and recovery features that protect data from
loss due to system failures, crashes, or other disasters. This ensures data
availability and reliability, helping organizations to quickly restore data and
continue operations with minimal disruption.
Advantages of Normalization:
a) Reduces Data Redundancy:
By organizing data into related tables and eliminating duplicate data,
normalization ensures that each piece of information is stored only once.
This reduces storage space and minimizes data redundancy, leading to more
efficient data storage.
b) Improves Data Integrity:
Normalization enforces data integrity by ensuring that relationships
between tables are maintained through foreign keys.
This helps in maintaining consistent and accurate data across the
database, preventing anomalies like update, insert, and delete anomalies.
c) Facilitates Data Maintenance:
With normalized tables, any changes to data need to be made in only one
place, which simplifies data maintenance and updates.
This reduces the risk of data inconsistencies and makes it easier to
manage the database.
d)Enhances Query Performance:
Normalized databases often have well-defined relationships between tables,
making it easier to write efficient queries.
This can improve the performance of data retrieval operations, especially
when dealing with large datasets.
e) Promotes Data Flexibility and Scalability:
A well-normalized database is more flexible and can easily accommodate
changes in data requirements.
It allows for easier addition of new data attributes and relationships
without major restructuring, making the database more scalable.
a) Atomicity:
Definition: Atomicity ensures that a transaction is treated as a single,
indivisible unit. It means that either all the operations within the transaction
are completed successfully, or none of them are.
If any part of the transaction fails, the entire transaction is
rolled back, leaving the database in its previous state.
Example: In a banking system, transferring money from one account to
another involves debiting one account and crediting another. Atomicity ensures
that both operations are completed successfully;
otherwise, neither operation is performed.
b) Consistency:
Definition: Consistency ensures that a transaction takes the database from
one valid state to another, maintaining the integrity constraints of the
database.
A transaction must ensure that all data integrity constraints are
satisfied, and the database remains in a consistent state before and after the
transaction.
Example: If a transaction involves updating the total balance of accounts
in a banking system, the sum of the balances before and after the transaction
should remain the same,
ensuring consistency.
c) Isolation:
Definition: Isolation ensures that the operations of one transaction are
isolated from the operations of other transactions. It means that the
intermediate state of a transaction is not visible to other transactions until
the transaction is committed.
This prevents concurrent transactions from interfering with each
other.
Example: In an online booking system, two users attempting to book the
same seat should not see each other's transactions until they are completed.
Isolation ensures that only one user can book the seat, avoiding
conflicts.
d) Durability:
Definition: Durability ensures that once a transaction is committed, its
changes are permanent and will survive any subsequent system failures.
This means that the results of a committed transaction are reliably
stored in the database, even in the event of a power failure or crash.
Example: After a successful purchase transaction in an e-commerce system,
the order details and inventory updates are permanently recorded in the
database,
ensuring that they are not lost in case of a system crash.
Types of Failures:
a) Transaction Failure:
Description: Occurs when a transaction cannot be completed due to errors
such as logical errors (e.g., division by zero) or system errors (e.g., deadlock
detection).
Example: A transaction trying to transfer funds between accounts might
fail if it detects an insufficient balance.
b) System Crash:
Description: A system crash happens due to hardware failures, software
bugs, or power outages. These crashes can lead to the abrupt termination of all
active transactions.
Example: A server crash during a database operation causes the system to
shut down unexpectedly.
c)Media Failure:
Description: Media failure refers to the failure of storage devices such
as hard disks. This can result in the loss of the database or parts of it.
Example: A hard disk failure leads to the corruption or loss of stored
data.
d) Application Software Failure:
Description: Failures in application software interacting with the
database can lead to incorrect data processing or transactions not being
completed.
Example: A bug in a banking application causes incorrect transaction
processing, leading to data inconsistencies.
e) Natural Disasters:
Description: Natural disasters such as floods, earthquakes, or fires can
cause extensive damage to the database infrastructure, leading to data loss or
unavailability.
Example: A flood damages the data center, resulting in the loss of
hardware and data.
Wait-Die Scheme:
The Wait-Die scheme uses timestamps to determine the priority of
transactions. Each transaction is assigned a timestamp when it enters the
system.
The scheme dictates that an older transaction (with a smaller timestamp)
can wait for a younger transaction (with a larger timestamp), but a younger
transaction must be aborted if it requests a resource held by an older
transaction.
Wound-Wait Scheme:
The Wound-Wait scheme also uses timestamps to assign priorities but takes
a different approach. In this scheme, an older transaction can "wound" a younger
transaction by forcing it to roll back and release resources. Conversely, a
younger transaction can wait for an older transaction to release resources.
Components of an ERD:
a) Entities:
Definition: Entities represent real-world objects or concepts that have a
distinct existence and are distinguishable from other objects. Each entity is
typically a table in the database.
Example: In a school database, entities could be Student, Teacher, Course,
and Classroom.
b) Attributes:
Definition: Attributes are the properties or characteristics of an entity.
They provide details about the entity and are typically the columns in a table.
Example: For the Student entity, attributes could include StudentID, Name,
DateOfBirth, and Email.
c) Relationships:
Definition: Relationships depict the associations between entities. They
describe how entities interact with each other and are represented by lines
connecting entities in the ERD.
Types: One-to-One (1:1): Each instance of one entity is associated with a
single instance of another entity.
One-to-Many (1:M): An instance of one entity can be associated
with multiple instances of another entity.
Many-to-Many (M:N): Instances of one entity can be associated
with multiple instances of another entity, and vice versa.
Example: A Student can enroll in multiple Courses (1:M), and a Course can
have multiple Students (M:N).
d) Primary Keys:
Definition: A primary key is a unique identifier for each instance of an
entity. It ensures that each record in the table can be uniquely identified.
Example: StudentID in the Student entity.
e) Foreign Keys:
Definition: A foreign key is an attribute in one entity that links to the
primary key of another entity, establishing a relationship between the entities.
Example: CourseID in the Enrollment entity, linking to the primary key
CourseID in the Course entity.
Importance of ERD:
Visual Clarity: Provides a clear and intuitive visual representation of
the database structure, making it easier to understand and communicate.
Efficient Design: Helps in identifying redundant data, ensuring data
normalization, and creating an efficient database design.
Documentation: Acts as a blueprint for the database, providing detailed
documentation that can be referred to during development and maintenance.
Consistency and Integrity: Ensures that all necessary data relationships
and constraints are captured, maintaining consistency and integrity in the
database.
Example:
Consider a simple ERD for a university database with the following entities and
relationships:
Entities:
Student, Course, Instructor, Enrollment
Attributes:
Student: StudentID, Name, DateOfBirth
Course: CourseID, CourseName, Credits
Instructor: InstructorID, Name, Department
Enrollment: EnrollmentID, Grade
Relationships:
Student enrolls in Course (M:N)
Course is taught by Instructor (1:M)
Enrollment links Student and Course