0% found this document useful (0 votes)
20 views

dbms-3rd-dbms-3rd-unit

The document covers key concepts in Database Management Systems (DBMS), focusing on transactions, ACID properties, concurrency control, and RAID implementation techniques. It explains transaction operations, the importance of concurrency, and various locking protocols, including Two-Phase Locking. Additionally, it discusses indexing and hashing methods for efficient data access and the benefits of RAID for data redundancy and performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

dbms-3rd-dbms-3rd-unit

The document covers key concepts in Database Management Systems (DBMS), focusing on transactions, ACID properties, concurrency control, and RAID implementation techniques. It explains transaction operations, the importance of concurrency, and various locking protocols, including Two-Phase Locking. Additionally, it discusses indexing and hashing methods for efficient data access and the benefits of RAID for data redundancy and performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

lOMoARcPSD|53213213

DBMS 3RD - DBMS 3RD UNIT

dbms (Anna University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by student ([email protected])
lOMoARcPSD|53213213

UNIT III - TRANSACTIONS

Transaction Concepts – ACID Properties – Schedules – Serializability – Concurrency Control – Need for
Concurrency – Locking Protocols – Two Phase Locking – Deadlock – Transaction Recovery - Save
Points – Isolation Levels – SQL Facilities for Concurrency and Recovery

1.What is Transaction?

A set of logically related operations is known as transaction.

The main operations of a transaction are: Read(A): Read operations

Read(A) or R(A) reads the value of A from the database and stores it in a buffer in main memory.

Write (A): Write operation

Write(A) or W(A) writes the value back to the database from buffer.

Let us take a debit transaction from an account which consists of following operations: 1.R(A); 2.A=A-
1000; 3.W(A);

Assume A’s value before starting of transaction is 5000. • The first operation reads the value of A from
database and stores it in a buffer.

• Second operation will decrease its value by 1000. So buffer will contain 4000.

• Third operation will write the value from buffer to database. So A’s final value will be 4000.

But it may also be possible that transaction may fail after executing some of its operations. The failure
can be because of hardware, software or power etc.

To avoid this, Database has two important operations:

Commit: After all instructions of a transaction are successfully executed, the changes made by
transaction are made permanent in the database.

Rollback: If a transaction is not able to execute all operations successfully, all the changes made by
transaction are undone.

Why do you need concurrency in Transactions?

A database is a shared resource accessed. It is used by many users and processes concurrently. For
example, the banking system, railway, and air reservations systems, stock market monitoring,
supermarket inventory, and checkouts, etc. Not managing concurrent access may create issues like:

• Hardware failure and system crashes

• Concurrent execution of the same transaction, deadlock, or slow performance

Downloaded by student ([email protected])


lOMoARcPSD|53213213

2. EXPLAIN ACID PROPERTIES

A transaction is a single logical unit of work which accesses and possibly modifies the contents of a
database. Transactions access data using read and write operations. In order to maintain consistency in a
database, before and after transaction, certain properties are followed. These are called ACID properties.

Atomicity
By this, we mean that either the entire transaction takes place at once or doesn’t happen at all. There is no
midway i.e. transactions do not occur partially. Each transaction is considered as one unit and either runs
to completion or is not executed at all.

Consistency

This means that integrity constraints must be maintained so that the database is consistent before and
after the transaction. It refers to correctness of a database.

Isolation

This property ensures that multiple transactions can occur concurrently without leading to inconsistency
of database state. Transactions occur independently without interference. Changes occurring in a
particular transaction will not be visible to any other transaction until that particular change in that
transaction is written to memory or has been committed.

Durability: This property ensures that once the transaction has completed execution, the updates and
modifications to the database are stored in and written to disk and they persist even if system failure
occurs.

3. EXPLAIN serializable schedule?

A serializable schedule always leaves the database in consistent state. A serial schedule is always a
serializable schedule because in serial schedule, a transaction only starts when the other transaction
finished execution. However, a non-serial schedule needs to be checked for Serializability.

Types of Serializability

There are two types of Serializability. I. Conflict Serializability II. View Serializability

1. Conflict Serializability
Conflict Serializability is one of the type of Serializability, which can be used to check whether a
nonserial schedule is conflict serializable or not.
What is Conflict Serializability? A schedule is called conflict serializable if we can convert it into a
serial schedule after swapping its non-conflicting operations.
Conflicting operations Two operations are said to be in conflict, if they satisfy all the following three
conditions:
1. Both the operations should belong to different transactions.
2. Both the operations are working on same data item.
3. At least one of the operations is a write operation. Let’s see some examples to understand this:
Example 1: Operation W(X) of transaction T1 and operation R(X) of transaction T2 are conflicting

Downloaded by student ([email protected])


lOMoARcPSD|53213213

operations, because they satisfy all the three conditions mentioned above. They belong to different
transactions, they are working on same data item X, one of the operations in write operation.
2.Conflict Serializable
check Let’s check whether a schedule is conflict serializable or not. If a schedule is conflict
Equivalent to its serial schedule then it is called Conflict Serializable schedule. Let’s take few
examples of schedules. Example of Conflict Serializability
Let’s consider this schedule: T1 T2 ----- ------ R(A) R(B)
View Serializability
View Serializability is a process to find out that a given schedule is view serializable or not. To check
whether a given schedule is view serializable, we need to check whether the given schedule is View
Equivalent to its serial schedule.
Lets take an example to understand what I mean by that. Given Schedule: T1 T2 ----- ------ R(X)
W(X) R(X) W(X) R(Y) W(Y) R(Y) W(Y)
4. EXPLAIN LOCKING PROTOCOLS IN DETAIL.
Lock-Based Protocol In this type of protocol, any transaction cannot read or write data until it
acquires an appropriate lock on it.
There are two types of lock: 1. Shared lock: It is also known as a Read-only lock. In a shared lock,
the data item can only read by the transaction. It can be shared between the transactions because
when the transaction holds a lock, then it can't update the data on the data item.
2. Exclusive lock: o In the exclusive lock, the data item can be both reads as well as written by the
transaction. o This lock is exclusive, and in this lock, multiple transactions do not modify the same
data simultaneously.
TWO PHASE LOCKING (2PL) The two-phase locking protocol divides the execution phase of
the transaction into three parts.
In the first part, when the execution of the transaction starts, it seeks permission for the lock it
requires.
In the second part, the transaction acquires all the locks.
The third phase is started as soon as the transaction releases its first lock.
In the third phase, the transaction cannot demand any new locks. It only releases the acquired locks.
There are two phases of 2PL: • Growing phase: In the growing phase, a new lock on the data item
may be acquired by the transaction, but none can be released. • Shrinking phase: In the shrinking
phase, existing lock held by the transaction may be released, but no new locks can be acquired.
In the below example, if lock conversion is allowed then the following phase can happen:
1. Upgrading of lock (from S(a) to X (a)) is allowed in growing phase.
2. Downgrading of lock (from X(a) to S(a)) must be done in shrinking phase.
Types of Two Phase Locking (2PL)
1. Strict Two-phase locking (Strict-2PL)
The first phase of Strict-2PL is similar to 2PL. In the first phase, after acquiring all the locks, the
transaction continues to execute normally. The only difference between 2PL and strict 2PL is
that Strict-2PL does not release a lock after using it.
2. Rigorous Two-Phase Locking • Rigorous Two – Phase Locking Protocol avoids cascading
rollbacks.

• This protocol requires that all the share and exclusive locks to be held until the transaction commits.

Downloaded by student ([email protected])


lOMoARcPSD|53213213

UNIT IV

IMPLEMENTATION TECHNIQUES

RAID – File Organization – Organization of Records in Files – Indexing and Hashing –Ordered Indices
– B+ tree Index Files – B tree Index Files – Static Hashing – Dynamic Hashing – Query Processing
Overview – Algorithms for SELECT and JOIN operations – Query optimization using Heuristics and
Cost Estimation

1.EXPLAIN RAID IN DETAIL

RAID (redundant array of independent disks) originally redundant array of inexpensive disks) is a
way of storing the same data in different places on multiple hard disks to protect data in the case of
a drive failure.

RAID: Redundant Arrays of Independent Disks Disk organization techniques that manage a large
numbers of disks, providing a view of a single disk of high capacity and high speed by using multiple
disks in parallel, and high reliability by storing data redundantly, so that data can be recovered even
if a disk fails

Motivation for RAID

 Just as additional memory in form of cache, can improve the system performance, in the same
way additional disks can also improve system performance.

 In RAID we can use an array of disks which operates independently since there are many disks,
multiple I/O requests can be handled in parallel if the data required is on separate disks

 A single I/O operation can be handled in parallel if the data required is distributed across multiple
disks.

Benefits of RAID

 Data loss can be very dangerous for an organization

 RAID technology prevents data loss due to disk failure

 RAID technology can be implemented in hardware or software

 Servers make use of RAID Technology RAID Level 0- Stripping and non-redundant

 RAID level 0 divides data into block units and writes them across a number of disks. As data is
placed across multiple disks it is also called “data Striping”.

 The advantage of distributing data over disks is that if different I/O requests are pending for two
different blocks of data, then there is a possibility that the requested blocks are on different
disksThere is no parity checking of data.

Downloaded by student ([email protected])


lOMoARcPSD|53213213

So if data in one drive gets corrupted then all the data would be lost.

Thus RAID 0 does not support data recovery Spanning is another term that is used with RAID level 0
because the logical disk will span all the physical drives.

RAID 0 implementation requires minimum 2 disks.

Advantages  I/O performance is greatly improved by spreading the I/O load across many channels
& drives.

 Best performance is achieved when data is striped across multiple controllers with only one driver
per controller

Disadvantages

 It is not fault-tolerant, failure of one drive will result in all data in an array being lost RAID Level 1:
Mirroring (or shadowing)

 Also known as disk mirroring, this configuration consists of at least two drives that duplicate the
storage of data. There is no striping.

RAID Level 2: This configuration uses striping across disks, with some disks storing error checking
and correcting (ECC) information. It has no advantage over RAID 3 and is no longer used.

RAID Level 3: Bit-Interleaved Parity  A single parity bit is enough for error correction, not just
detection, since we know which disk has failed – When writing data, corresponding parity bits must
also be computed and written to a parity bit disk – To recover data in a damaged disk, compute XOR
of bits from other disks (including parity bit disk).

RAID Level 4: Block-Interleaved Parity  When writing data block, corresponding block of parity bits
must also be computed and written to parity disk  To find value of a damaged block, compute XOR
of bits from corresponding blocks (including parity block) from other disks.

RAID Level 5:  RAID 5 uses striping as well as parity for redundancy. It is well suited for heavy read
and low write operations.  Block-Interleaved Distributed Parity; partitions data and parity among
all N + 1 disks, rather than storing data in N disks and parity in 1 disk.

2.WRITE SHORT NOTES ON INDEXING AND HASHING

 Indexing mechanisms used to speed up access to desired data. – E.g., author catalog in library

 Search Key - attribute to set of attributes used to look up records in a file.

An index file consists of records (called index entries) of the form Search-key pointer

 Index files are typically much smaller than the original file

Downloaded by student ([email protected])


lOMoARcPSD|53213213

 Two basic kinds of indices: – Ordered indices: search keys are stored in sorted order – Hash
indices: search keys are distributed uniformly across “buckets” and by using a “hash function” the
values are determined.

Ordered Indices  In an ordered index, index entries are stored sorted on the search key value.

 Primary index: in a sequentially ordered file, the index whose search key specifies the sequential
order of the file.

 Secondary index: an index whose search key specifies an order different from the sequential
order of the file.

Types of Ordered Indices  Dense index  Sparse index Dense Index Files

Dense index — Index record appears for every search-key value in the file.

Sparse Index Files  Sparse Index contains index records for only some search-key values.  To locate
a record with search-key value K.

Downloaded by student ([email protected])

You might also like