Você está na página 1de 30

Unit 1 - MATRIX THEORY

Notes
UNIT I
UNIT 1 - INTRODUCTION TO MATRIX
THEORY
CONTENTS
1.0 Aims and Objectives
1.1 Introduction
1.2 Database Basics
1.2.1 Data
1.2.2 Information
1.2.3 Data Processing
1.2.4 Metadata
1.2.5 Characteristics of Database Approach
1.2.6 Drawbacks of File Processing System
1.2.7 Advantages and Disadvantages of DBMS
1.3 Purpose of Database System
1.4 Data Models
1.4.1 Significance of Data Models
1.4.2 Hierarchical Data Model
1.5 Database Languages
1.5.1 Data Definition Language
1.5.2 Data Manipulation Language
1.5.3 Transaction Control Language
1.6 Transaction Management
1.6.1 Transaction Processing
1.6.2 Advantages and Disadvantages of Transaction Processing
System
1.6.3 Online Transaction Processing System
1.6.4 Serialisability and Recoverability
1.6.5 ACID Properties of Transactions
1.6.6 View Serialisability
1.6.7 Transaction Management in Multi-Database System
1.6.8 Long Duration Transactions
1.6.9 High Performance Transaction Systems

7
Database Management System

Notes 1.7 Let us Sum up


1.8 Lesson End Activity
1.9 Keywords
1.10 Questions for Discussion
1.11 Suggested Readings

1.0 AIMS AND OBJECTIVES


After studying this unit, you should be able to:
 Types of matrices
 Basic Matrix operations
 Rank of a matrix
 Gauss Jordon method of finding inverse
 Normal form of a matrix
 Computation of rank using normal forms
 Consistency of linear system of equations
 Linear and orthogonal transformations
 Eigen values and eigenvectors
 Properties of eigen values
 Cayley Hamilton theorem (without proof)
 Reduction to diagonal form

1.1 INTRODUCTION
A database is defined as a group of related information which can be used by
several users for different reasons. We can obtain the database content by
merging data from every different source of an organisation. In this way, data
can be obtained by every user and the user can remove or at least minimise the
redundant data. There are different ways of cross-referencing which can be
done by means of electronic filing system. Thus, the user can reorganise and
retrieve the data in different ways. The data related to business inventory,
accounting, and filing can be managed by a database and the information can
be used in its files in order to make sum-ups, calculations, and other reports. A
software package used for managing data in a database is referred to as
database management system (DBMS). DBMS is considered as the main
software element of a database system. Some database management systems
that are available commercially are INGRES, ORACLE and Sybase. Thus, we
can define DBMS as a combination of hardware and software which creates

8
Unit 1 - MATRIX THEORY

and monitors a database and handles the operations such as updating and Notes
retrieval of database stored in it.

1.2 TYPES OF MATRICES


Different types of Matrices and their forms are used for solving numerous
problems. Some of them are as follows:

1.2.1 Row Matrix


A row matrix has only one row but any number of columns. A matrix is said to
be a row matrix if it has only one row. For example,
A=[−1/2√523]
is a row matrix of order 1 × 4. In general, A = [aij]1 × n is a row matrix of order 1
× n.

1.2.2 Column Matrix


A column matrix has only one column but any number of rows. A matrix is
said to be a column matrix if it has only one column. For example,

is a column matrix of order 4 × 1. In general, B = [bij]m × 1 is a column matrix


of order m × 1.

1.2.3) Square Matrix


A square matrix has the number of columns equal to the number of rows. A
matrix in which the number of rows is equal to the number of columns is said
to be a square matrix. Thus an m × n matrix is said to be a square matrix if m =
n and is known as a square matrix of order ‘n’. For example,

9
Database Management System

Notes

is a square matrix of order 3. In general, A = [aij] m × m is a square matrix of


order m.

1.2.4 Rectangular Matrix


A matrix is said to be a rectangular matrix if the number of rows is not equal to
the number of columns. For example,

is a matrix of the
order 4 × 3

1.2.5 Diagonal matrix


A square matrix B = [bij] m × m is said to be a diagonal matrix if all its non-
diagonal elements are zero, that is a matrix B =[bij]m×m is said to be a diagonal
matrix if bij = 0, when i ≠ j. For example,

are diagonal
matrices of order 1, 2, 3, respectively.

1.2.6 Scalar Matrix


A diagonal matrix is said to be a scalar matrix if all the elements in its principal
diagonal are equal to some non-zero constant. A diagonal matrix is said to be a
scalar matrix if its diagonal elements are equal, that is, a square matrix B =
[bij]n × n is said to be a scalar matrix if
bij = 0, when i ≠ j
bij = k, when i = j, for some constant k.
For example,

10
Unit 1 - MATRIX THEORY

Notes

are scalar matrices of


order 1, 2 and 3, respectively.

1.2.7 Zero or Null Matrix


A matrix is said to be zero matrix or null matrix if all its elements are zero.
For Example,

are all zero matrices of


the order 1, 2 and 3 respectively. We denote zero matrix by O.

1.2.8 Unit or Identity Matrix


If a square matrix has all elements 0 and each diagonal elements are non-zero,
it is called identity matrix and denoted by I.
Equal Matrices: Two matrices are said to be equal if they are of the same order
and if their corresponding elements are equal to the square matrix A = [aij]n ×
n is an identity matrix if

aij = 1 if i = j
aij = 0 if i ≠ j
We denote the identity matrix of order n by In. When the order is clear from the
context, we simply write it as I. For example,

are identity matrices of order 1, 2 and 3, respectively. Observe that a scalar


matrix is an identity matrix when k = 1. But every identity matrix is clearly a
scalar matrix.

11
Database Management System

Notes 1.2.9 Upper Triangular Matrix


A square matrix in which all the elements below the diagonal are zero is
known as the upper triangular matrix. For example,

1.2.10 Lower Triangular Matrix


A square matrix in which all the elements above the diagonal are zero is known
as the upper triangular matrix. For example,

Solved Examples
Question: Assertion :

is a diagonal matrix.
Reason: If A=[aij] is a square matrix such that aij=0,∀i≠j, then A is called a
diagonal matrix.
Both Assertion and Reason are correct and Reason is the correct explanation
for Assertion
Both Assertion and Reason are correct but Reason is not the correct
explanation for Assertion
Assertion is correct but Reason is incorrect
Both Assertion and Reason are incorrect

12
Unit 1 - MATRIX THEORY

Solution: If A=[aij]n×n is a square matrix such that aij = 0 for i≠j, then A is Notes
called a diagonal matrix. Since, a12 = a13 = a21 = a23 = a31 = a32 = 0 Thus, the
given statement is true and

is a diagonal matrix is a diagonal matrix

1.3 BASIC MATRIX OPERATIONS


Organizations use large amounts of data. A database management system
(DBMS) is a software tool that makes it possible to organize data in a database.

The standard acronym for database management system is DBMS, so you will
often see this instead of the full name. The ultimate purpose of a database
management system is to store and transform data into information to support
making decisions.

A DBMS consists of the following three elements:

 The physical database: the collection of files that contain the data

 The database engine: the software that makes it possible to access and
modify the contents of the database

 The database scheme: the specification of the logical structure of the


data stored in the database

While it sounds logical to have a DBMS in place, it is worth thinking for a


moment about the alternative. What would the data in an organization look like
without a DBMS? Consider yourself as the organization for a moment, and the
data are all the files on your computer. How is your data organized? If you are
like most typical computer users, you have a large number of files, organized
in folders.

You may have word processor documents, presentation files, spreadsheets,


photographs, etc. You find the information you need based on the folder

13
Database Management System

Notes structure you have created and the names you have given to your files. This is
called a file system and is typical for individual computer users.

Now consider the challenges you are faced with. Have you ever lost a file?
Have you had difficulty finding a file? Probably. Perhaps you are using
multiple computers and your files are located in different physical locations.
And, when was the list time you created a backup of all your files? You do
back up, right?

To see why database management systems are necessary, let's look at a typical
``file-processing system'' supported by a conventional operating system.
The application is a savings bank:
 Savings account and customer records are kept in permanent system files.
 Application programs are written to manipulate files to perform the
following tasks:
 Debit or credit an account.
 Add a new account.
 Find an account balance.
 Generate monthly statements.
Development of the system proceeds as follows:
 New application programs must be written as the need arises.
 New permanent files are created as required.
 but over a long period of time files may be in different formats, and
 Application programs may be in different languages.
So we can see there are problems with the straight file-processing approach:
 Data redundancy and inconsistency
 Same information may be duplicated in several places.
 All copies may not be updated properly.
 Difficulty in accessing data
 May have to write a new application program to satisfy an unusual
request.
 E.g. find all customers with the same postal code.
 Could generate this data manually, but a long job...
 Data isolation
 Data in different files.
 Data in different formats.

14
Unit 1 - MATRIX THEORY

 Difficult to write new application programs. Notes


 Multiple users
 Want concurrency for faster response time.
 Need protection for concurrent updates.
 E.g. two customers withdrawing funds from the same account at the
same time - account has $500 in it, and they withdraw $100 and $50.
The result could be $350, $400 or $450 if no protection.
 Security problems
 Every user of the system should be able to access only the data they are
permitted to see.
 E.g. payroll people only handle employee records, and cannot see
customer accounts; tellers only access account data and cannot see
payroll data.
 Difficult to enforce this with application programs.
Integrity problems
 Data may be required to satisfy constraints.
 E.g. no account balance below $25.00.
 Again, difficult to enforce or to change constraints with the file-
processing approach.
These problems and others led to the development of database management
systems.

1.4 DATA MODELS


Data models include basic operations which are used for database updates and
retrievals. You can define it as a method of storing and retrieving the data. A
set of valid user defined operations is specified on the database objects by
database designer. You must remember that in data models, the relationships
are viewed and manipulated by the users in a different manner. Data can be
stored in several ways. The classification of data models depend on data
models’ closeness with the users. The different types of data models are
hierarchical data model, network data model, relational data models, etc.

1.4.1 Significance of Data Models


The communication between the applications programmer, designer, and end
user can be facilitated by data models. An organisation for which the database
design is formulated can be understood in an improved way. This is done by
means of a well-built data model. So, we can say that data models are
considered as a communication tool. A system’s most basic information units
are included in the data. In order to handle data and transforming data into

15
Database Management System

Notes information, applications are created. However, different people view data in
different ways.
For instance, let us consider the view of a company manager and view of a
company clerk. Even though they work for the same company, there is a good
chance for the manager to have an enterprise-wide view of company data.
Therefore, in comparison to the manager, the clerk has a less chance of having
an enterprise-wide view of company data.
Nevertheless, applications programmers consists of another data view which is
more interested in data location, formatting, and detailed requirements of
reporting. The policies and procedures of a company are translated from
various sources into suitable reports, interfaces, and query screens. This
process is done by application programmers. On the availability of a good
blueprint of database, the difference between the data view of an application
programmer and the data view of manager and/or the end user does not matter.
On the other hand, non-availability of a good blueprint of the database leads to
various problems.
Example: An order entry system and an inventory management program may
make use of contradictory product-numbering strategies, which thus cost the
company thousands of dollars or much more.
The data model is considered as an abstraction. The required data cannot be
taken out from the data model.

1.4.2 Hierarchical Data Model


Prior to the development of the first Database Management System (DBMS),
access to data was provided by application programs that accessed flat files.
The data integrity problem and the inability of such file processing systems to
represent logical data relationships lead to the first data model: the hierarchical
data model. This model, which was implemented primarily by IBM’s
Information Management System (IMS), only allows one-to-one or one-to-
many relationships between entities. Any entity at the different (many) ends of
the relationship can be related only to one entity at the one end.
In Hierarchical Data Model, we organise data into a structure which appears as
a tree. In this structure, every node comprises one parent node. Root node is an
exception, that is, it does not contain any parent. This is to note that although a
node can comprise numerous child nodes, it can comprise just one parent node.
Figure 1.3 shows hierarchical data model representation.

16
Unit 1 - MATRIX THEORY

Root Notes

Level 1 Level 1 Level 1


Child Child Child

Level 2 Level 2 Level 2 Level 2 Level 2


Level 2
Child Child Child Child Child

Figure 1.3: Hierarchical Data Model Representation


A record is represented by a node available in structure which appears as a tree.
Every attribute of a particular record is available below entity type. All entity
types are connected to one another by means of 1 : N mapping. A known
example of this model is IMS (Information Management System) implemented
by IBM.
An example of a hierarchical data model would be if an organisation had
records of employees in a table (entity type) called “Employees”. In the table
there would be attributes/columns such as First Name, Last Name, Job Name
and Wage. The company also has data about the employee’s children in a
separate table called “Children” with attributes such as First Name, Last Name,
and Date of Birth. The Employee table represents a parent segment and the
Children table represents a Child segment. These two segments form a
hierarchy where an employee may have many children, but each child may
only have one parent.
Consider the following structure:
Table 1.1: Hierarchical Data Model Structure

In this, the “child” is the same type as the “parent”. The hierarchy stating Emp
No. 10 is boss of 20, and 30 and 40 each report to 20 is represented by the
“Reports To” column. In Relational database terms, the Reports To column is a
foreign key referencing the Emp No. column. If the “child” data type were
different, it would be in a different table, but there would still be a foreign key
referencing the Emp No. column of the employees table.
This simple model is commonly known as the adjacency list model, and was
introduced by Dr Edgar F Codd after initial criticisms surfaced that the
relational model could not model hierarchical data.

Advantages of Hierarchical Data Model


Hierarchical databases include the following advantages:

17
Database Management System

Notes  Simplicity: It has a simple design process since data (in many practical
circumstances) usually consists of hierarchical relationship. It is thus easier
to see the data organised in this manner.
 Security: These databases can execute the changing level of security
characteristics.
 Database integrity: It is extremely advertised in these systems due to its
inbuilt structure of parent and child.
 Relationship handling: These databases are considered as extremely
proficient for the relationships of the type 1 : M.

Disadvantages of Hierarchical Data Model


Hierarchical databases include the following disadvantages:
 Complication in implementation: Implementing Hierarchical database is
quite difficult since it is based on the data’s physical warehousing.
 Trouble in management: It is not easy to manage hierarchical database.
For instance, moving a part of data from one position to the other position
needs you to modify every accessing application related to that data which
is complicated to perform.
 Structural reliance: In this database, relationships are defined in a rigid
manner. Thus if a change is performed in any portion of database structure,
then the programs using it would also require change. So the process of
maintaining the database is a very complicated and monotonous job.
 Difficulty in programming: Programming this type of database is
considered a quite difficult task. To do this, the programmers should
essentially recognise the physical route followed by data items.
 Bad portability: These databases offers bad portability since there is no
standard available.

1.5 DATABASE LANGUAGES


Read, Update, Manipulate, and Store data in a database using Database
Languages. The following are the database languages:
 Data Definition Language
 Data Manipulation Language
 Data Control Language
 Transaction Control Language
Let us begin with Data Definition Language:

18
Unit 1 - MATRIX THEORY

1.5.1 Data Definition Language Notes


The language is used to create database, tables, alter them, etc. With this, you
can also rename the database, or drop them. It specifies the database schema.
The DDL statements include:
CREATE: Create new database, table, etc.
ALTER: Alter existing database, table, etc.
DROP: Drop the database
RENAME: Set a new name for the table.

1.5.2 Data Manipulation Language


The language used to manipulate the database like inserting data, updating
table, retrieving record from a table, etc. is known as Data Manipulation
Language:
 SELECT: Retrieve data from the database
 INSERT: Insert data
 UPDATE: Update data
 DELETE: Delete all records
 Data Control Language
Grant privilege to a user using the GRANT statement. In the same way, revoke
the privilege using the REVOKE statement. Both of these statements come
under the Data Control Language (DCL).:
GRANT: Give privilege to access the database.
REVOKE: Take back the privilege to access the database.

1.5.3 Transaction Control Language


Manage transactions in the Database using the Transaction Control Language:
 COMMIT: Save the work.
 SAVEPOINT: Set a point in transaction to rollback later
 ROLLBACK: Restores since last commit

1.6 TRANSACTION MANAGEMENT


A transaction is a logical unit of work that contains one or more SQL
statements. A transaction is an atomic unit. The effects of all the SQL
statements in a transaction can be either all committed (applied to the database)
or all rolled back (undone from the database).

19
Database Management System

Notes

1.6.1 Transaction Processing


As you know, usually, one or more database operations are grouped into three
transactions, which is a unit of work that must be performed atomically and in
separation from other transactions. Additionally, a DBMS provides the
assurance of stability that the work of a finished transaction will never be
vanished. Thus the transaction manager obtains transaction commands from an
application, which inform the transaction manager when transactions start and
end, in addition to information regarding the expectations of the application.
Figure 1 demonstrates several features of transaction processing in an example.
Begin

Catalog
Capture

Transaction Manager
Order
Orders

Unit of Work Process


Order Inventory

Shipping

End
Figure 1.4: An Example of Transaction Processing Architecture
For example, some may not need atomicity. The following tasks are carried out
by the transaction manager.
1. Logging: To guarantee stability, each change in the database is logged
individually on disk. The log manager considers numerous policies
designed to guarantee that regardless of when a system failure or ”crash"
takes place, a recovery manager can check the log of changes and database
is restored to some reliable state.
2. Concurrency control: Transactions must emerge to perform in isolation.
However, in most of the systems, the binary transactions are actually
executing at once. Therefore, the scheduler must guarantee that the
individual actions of numerous transactions are executed in such a way that
the total outcome is the same as if the transactions had actually executed in
their entirety, one by one.

20
Unit 1 - MATRIX THEORY

3. Deadlock resolution: As transactions struggle for getting resources via the Notes
locks that the scheduler provides, they can be in a condition where none
can continue since each requires something another transaction comprises.
The transaction manager has the liability to interfere and terminate
(“rollback" or "abort") one or more transactions to allow the others to
continue.

1.6.2 Advantages and Disadvantages of Transaction Processing System


Transaction processing system consists of several advantages and
disadvantages which you are going to study now.

Advantages of Transaction Processing System


The advantages of transaction processing system are as follow:
1. Each business company needs a system for the collection, accumulating
and recovering of data and statistics, so that it can function competently. A
transaction processing system will fulfil this requirement. Every single
transaction is managed and monitored by means of a transaction processing
system, in order that the system will identify if entered data is valid. Once
the gathered information clears the test, it will then be accumulated and
generated in the processing system.
2. The process of monitoring all transactions can be made simpler by means
of an organised transaction processing system. It will enormously save a
firm’s time, energy, money and attempt. Additionally, all the entered data
will be kept protected and all transactions performed will be monitored and
recorded in a correct manner. All records will be maintained in an
organised and protected manner. Only approved people have access to its
functions.
3. By means of a consistent transaction processing system, any firm will
successfully please its consumers and get more satisfied consumers.
Consumers rely on the consistency of a company. In future, they will stand
by a firm with whom that they can trust their earnings, money and personal
information.

Disadvantages of Transaction Processing System


The main disadvantages of transaction processing systems that you must know
are:
1. There is a need to manage hundreds and thousands of simultaneous
consumers.
2. There is the need to permit several consumers to work on the same set of
data, with instant updating.
3. There is the need to manage faults in a protected and consistent way.
Transaction systems usually manage faults in a secure and reliable manner,

21
Database Management System

Notes but there are some faults that you cannot evade, for example, network
faults or deadlocks of databases. Thus, there should be a method which can
be used to manage them when they take place. We cannot just terminate an
existing process.

1.6.3 Online Transaction Processing System


Online transaction processing is considered as interactive in which every
transaction is processed as it takes place. In Online Transaction Processing
(OLTP) system, you can endlessly interact with the system by a computer or a
terminal. The Air-line reservation, Railway reservation system, the Banking
ATM machine, the Library application, etc. are some of the examples of online
transaction processing system. In these types of systems, you are required to
enter pre-defined inputs such as flight number, train number, date of journey,
amount to withdraw, etc. According to these pre-defined inputs, the system
generates pre-defined outputs such as the confirmed tickets, or non-availability
of ticket, etc. The problem with Online Transaction Processing (OLTP) system
is the high costs related with the required security and fault acceptance traits. A
data is entered by a person for a system transaction, where it is processed and
the output is obtained before entering the next input. When you use online
entry with postponed processing, then data is input as the transaction takes
place and is stored online, but files are not updated. Files are updated
afterwards in batch. For example, orders received over the phone may be
accepted by the system, but the orders are not processed until a slow time, like
at night.

Figure 1.5: Online Transaction Processing Framework


In Figure 1.5 you can see an example of online transaction processing. In it a
customer uses an ATM, which demonstrates an easy interface for different
functions such as cash withdrawal, account balance query, bill payment,

22
Unit 1 - MATRIX THEORY

transfer, or cash advance. In the same network, an employee in the branch Notes
office executes operations such as fund applications and consulting. In the
bank head office, a business analyst tunes up business deal for better
functioning. Other employees execute day-to-day functions such as customer
relationship management, budget planning, and stock control. In the figure,
you can see that all requests are addressed to the mainframe for processing.

1.6.4 Serialisability and Recoverability


In transaction processing, serialisability is considered as the property of a
serialisable schedule. Serialisability is the main criterion for the accuracy of
simultaneous transactions executions and a main objective for concurrency
control. In the context of data storage and communication, we can define
serialisability as the process of converting a data structure into a format that
can be stored. If every transaction is accurate by itself, then any sequential
execution of these transactions is accurate.
Notable examples are banking transactions that debit and credit accounts with
money. If the associated schedules are not serialisable, then the total sum of
money may not be maintained. Money could vanish, or be produced from
nowhere. This does not take place if serialisability is sustained.
In systems where transactions can terminate, serialisability by itself is not
adequate for accuracy. Schedules are also required to acquire the property of
Recoverability. Recoverability signifies that data is not read by the committed
transactions where the data is written by terminated transactions. While
serialisability can be negotiated in various applications, negotiating
recoverability always infringes the database’s integrity.
If a system crash takes place, the actions of the committed transactions can be
rebuilt on the disk copy of the database.

No activity is carried out by the logging system to assist serialisability. A


database state is simply rebuilt even if it is the consequence of non-serialisable
schedule of actions.
Commercial database systems do not always endure on serialisability and
serialisability is enforced in some systems, when the user makes a demand.

Cascading Rollback
On the failing of the transaction, the system is required to return to the situation
that it was in before the transaction was initiated. We call this as rollback. That
is, on the failing of the transaction, the changes that had been made are known
as "rolled back."
When a data is written by a non-committed transaction it is stated to be ‘dirty’.
The dirty data can be viewed either in the buffers, or on disk, or both. They
both can lead to problems.

23
Database Management System

Notes A cascading rollback can be carried out if dirty data can be procured to
transactions. On termination of transaction T, any transaction that has read the
data written by it should be found out and terminated.

Each transaction ‘U’ that read dirty data written by T should be discovered and
V should be aborted. Find out any transaction V that read dirty data from U,
and terminate V.
A log can be used to end the effect of a terminated transaction if it is one of the
kinds that offer previous values for e.g. undo or undo/redo. The data can also
be fixed from the copy in the disk if the effect of the dirty data has not shifted
to disk.

Transaction Recovery
If you want any of the logging methods to permit recovery, the set of
transactions that are considered as committed after recovery must be reliable.
Specifically, if a transaction TI is, after recovery considered as committed, and
Tl utilised a value written by T2, then T2 must also remain committed, after
recovery. Therefore, we define a recoverable schedule as follows:
“If a transaction commits only after every transaction from which it has read
commits, a schedule is said to be recoverable.”

Managing Rollbacks Using Locking


In this section you will study about the management of cascading rollbacks in a
lock-based scheduler. Strict locking is a simple method used to provide
assurance against cascading rollbacks. Till the time the transaction is either
committed or aborted, any write locks or other locks such as increment
locks which permit values to be changed should not be discharged by the
transaction.
A transaction cannot read dirty data in a recoverable schedule as it remains
locked until the transaction commits. The problem of fixing the data in buffers
when a transaction terminates however still persists since the changes need to
have the effect terminated.

SAVEPOINT Statement
The SAVEPOINT statement names and marks the current point in the
processing of a transaction. With the ROLLBACK TO statement, savepoints
undo parts of a transaction instead of the whole transaction.

Example: Using SAVEPOINT with ROLLBACK


CREATE TABLE emp_name AS SELECT employee_id, last_name, salary
FROM employees;
CREATE UNIQUE INDEX empname_ix ON emp_name (employee_id);

24
Unit 1 - MATRIX THEORY

DECLARE
Notes
emp_idemployees.employee_id%TYPE;
emp_lastnameemployees.last_name%TYPE;
emp_salaryemployees.salary%TYPE;
BEGIN
SELECT employee_id, last_name, salary INTO emp_id,
emp_lastname,
emp_salary FROM employees WHERE employee_id = 120;
UPDATE emp_name SET salary = salary * 1.1 WHERE employee_id =
emp_id;
DELETE FROM emp_name WHERE employee_id = 130;
SAVEPOINT do_insert;
INSERT INTO emp_name VALUES (emp_id, emp_lastname,
emp_salary);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
ROLLBACK TO do_insert;
DBMS_OUTPUT.PUT_LINE('Insert has been rolled back');
END;
/
When you roll back to a savepoint, any savepoints marked after that savepoint
are erased. The savepoint to which you roll back is not erased. A simple
rollback or commit erases all savepoints.

Implementing Commit
To process a commit operation, the recovery manager adds a commit record to
the end of the log and flushes the log. The log manager is designed so that it
doesn’t acknowledge the flush operation until all the log pages in memory, up
to and including the one being flushed, have been written to disk and the disk
has acknowledged that the disk writes completed successfully. At this point,
the transaction has been committed and the recovery manager can
acknowledge this fact to its caller.

1.6.5 ACID Properties of Transactions


Let us now study about a few desirable properties of a transaction, which are
known as ACID properties.
A – Atomicity – all or nothing execution
C – Consistency – database consistency is preserved
I – Isolation – concurrently executing transactions have no effect on one
another

25
Database Management System

Notes D – Durability – result survive failures


Atomicity: Either all operations of the transaction are reflected properly in the
database or none are.
Consistency: Execution of a transaction in isolation (i.e., with no other
transaction executing concurrently) preserves the consistency of the database.
Isolation: Even though multiple transactions may execute concurrently, the
system guarantees that for every pair of transactions Ti and Tj, it appears to Ti
that either Tj finished execution before Ti started, or, Tj started execution after
Ti finished. Thus, if isolation is guaranteed, each transaction is unaware of
other transactions executing concurrently in the system.
Durability: After a transaction completes successfully, the changes it has made
to the database persist, even if there are system failures.

Significance
We will discuss some cases showing the significance of these properties.
Consider a banking database. Assume that the database permanently resides on
disk and some portion of it temporarily resides in main memory. Consider two
basic operations
 Read(X)
 Write(X)
Read(X): Transfers data item X from the database to a local buffer belonging
to the transaction that executed this read operation. Figure 1.6 shows the
different steps of execution of Read(X).
Read(X) means Read a data item X.
Steps:
Find the address on the disk that contains X.
Copy X from disk to a buffer.
Copy X from buffer to program variable X

Figure 1.6: Steps of How Read Works


Write(X): Transfers the data item X from the local buffer of the transaction that
executed the write back to the database. In Figure 1.7 you can see the different
steps of execution of Write(X).
Write(X) means write value to a data item X
Steps:
Writes a data item X
Copy program variable X to a buffer
Copy X from buffer to a disk

Figure 1.7: Steps of How Write Works

26
Unit 1 - MATRIX THEORY

Assume that the write operation immediately updates the database. Let Ti be a Notes
transaction that transfers ` 5000 from Account A to Account B. Figure 1.8
shows different steps involved in such a money transfer.
Ti: read(A);
A = A – 5000;
write(A);
read(B);
B = B + 5000;
write(B);

Figure 1.8: Shows a Transaction Ti


Property of consistency: The property of consistency means that the sum
should remain same. That is, the total of amount in A/c A and amount in A/c B
should be the same before and after the transaction. In Figure 1.9 you can see
how property consistency is applicable for the transaction Ti represented in
Figure 1.8.
Ti: Transfer Rs:5000 from A/c A to A/c B.
Before Transaction Ti
A/c A = 10,000 A/c B = 10,000 Total of A and B = 20,000
After Transaction Ti
A = 5000 B = 15000 Total of A and B = 20,000

Figure 1.9: Total of A and B Remains the Same Before and after the Transaction T i
Property of Atomicity: Assume that the accounts are initially like A/c A =
10,000 and A/c B = 10,000. Assume that a failure occurred which prevented Ti
from completing successfully. What happens if the problem came after
executing statement write(A), but before executing statement write(B)?
Ti: Transfer Rs:5000 from A/c A to A/c B.
Before Transaction Ti
A/c A = 10,000 A/c B = 10,000
After partial execution of Ti
A = 5000 B = 10000

Figure 1.10: ` 5000 is Withdrawn from A’s Account but B’s Account is not Updated

If the transaction stopped before completing, the accounts would not be in a


correct state. As the figure (Figure 1.10) indicates, though money is withdrawn
from A/c: A, A/c: B may not get updated. Actually A/c: B should have amount
` 15000, but it shows only ` 5000 i.e., the state of system no longer reflects a

27
Database Management System

Notes real state of the world that the database is supposed to capture. This is referred
to as an inconsistent state.

Property of Durability: This property guarantees that, once a transaction


completes successfully, all updates it carried out on the database persist, even
if there is a system failure after the transaction completes execution.
In the example of bank transaction, once Ti completes successfully, the
changes it made in accounts should persist (till another transaction changes the
same).
Assumptions ensuring durability: The updates carried out by the transaction
have been written to disk before the transaction completes. Information about
the updates carried out by the transaction and written to disk is sufficient to
enable the database to reconstruct the updates when the database system is
restarted after the failure.
Property of Isolation: If several transactions are executed concurrently, and
their operations are interleaved in some undesirable way, it may result in an
inconsistent state. The isolation property of a transaction ensures that
concurrent execution of transactions results in a system state that is equivalent
to a state that could have been obtained had these transactions executed one at
a time in some order. Suppose <T1, T2, T3> is a schedule S of serial
transactions in the order T1, T2, T3. Assume that another concurrent schedule C
is there which consists of statements from all three transactions in some
interleaved fashion, still resulting a database state equal to that resulted by S. In
this case, we can say that the property of isolation is ensured. Concurrency
problem can be solved by using the approach - Either execute transactions
serially or use efficient concurrency control techniques.

Different States of a Transaction


There are different states of a transaction as listed below which can be
represented using a state diagram (Figure 1.11).

Figure 1.11: State Diagram of Transaction


 Active
 Partially committed
 Failed

28
Unit 1 - MATRIX THEORY

 Aborted Notes
 Committed
Active: The transaction stays in this state while it is executing.
Partially committed: A database transaction enters this phase when its final
statement has been executed. At this phase, the database transaction has
finished its execution, but it is still possible for the transaction to be aborted
because the output from the execution may remain residing temporarily in
main memory – an event like hardware failure may erase the output.
Failed: A database transaction enters the failed state when its normal execution
can no longer proceed due to hardware or program errors.
Aborted: A database transaction, if determined by the DBMS to have failed,
enters the aborted state. An aborted transaction must have no effect on the
database, and thus any changes it made to the database have to be undone, or in
technical terms, rolled back. The database will return to its consistent state
when the aborted transaction has been rolled back. The DBMS's recovery
scheme is responsible to manage transaction aborts.
Committed: A database transaction enters the committed state when enough
information has been written to disk after completing its execution with
success. In this state, so much information has been written to disk that the
effects produced by the transaction cannot be undone via aborting; even when
a system failure occurs, the changes made by the committed transaction can be
re-created when the system restarts. In short, after successful completion, a
transaction is said to be in committed state.

System Recovery
 Any transaction that was running at the time of failure needs to be undone
and restarted.
 Any transactions that committed since the last checkpoint need to be
redone.
 Transactions of type T1 need no recovery.
 Transactions of type T3 or T5 need to be undone and restarted.
 Transactions of type T2 or T4 need to be redone.

Media Recovery
A media failure is the loss of a portion of stable storage. This is usually
detected when an attempt is made to read a portion of the stable database, and
the disk responds with an error condition. Failure rates of stable storage
devices are sensitive to many factors, and they change over time with changing
technologies. That said a typical failure rate for magnetic disks is 2% to 8% per
year, meaning that a system with 100 disks experiences two to eight irreparable
disk failures per year. This is a sufficiently frequent occurrence that engineered

29
Database Management System

Notes solutions are needed to shield the system from the effect of a media failure and
to enable recovery when a media failure does occur. The latter is similar to
recovering from a system failure: Load a usable state of the stable database
from some backup device, such as tape or another disk, and then use the log to
bring that state up to date.

1.6.6 View Serialisability


"View-serialisability" is one of the weaker conditions that assure serialisability.
View-serialisability regards all the associations between transactions T and U
in a way that a database element is written by T, the value of which is read by
U. The main dissimilarity among serialisability and view c become apparent
when a value A is written by transaction T and it is not read by any transaction.
A value for A is written thereafter by some other transaction. In that situation,
you can put the WT (A) action in some different locations of the schedule that
would not be allowed in case of conflict-serialisability. In this section, we will
discuss the concept of view-serialisability.
View Equivalence: Let us presume two schedules named as S1 and S2 which
are related to the similar group of transactions. Visualise an imaginary
transaction TO. Preliminary values for every database element read by any
transaction in the schedules are written by TO. Again visualise some other
imaginary transaction Tf. Every element written by one or more transactions
after the end of each schedule is read by Tf.
Thereafter we can discover the write action Wj (A) that most closely headed
the read in question for every read action rt (A) in one of the schedules. T 3 is
regarded to be the source of the read action Tt (A). T3 could be the imaginary
initial transaction T0, and also Tt could be Tf. If for all read actions in one of
the schedules, the source is similar in the other schedule, then S1and S2 are said
to be view-equivalent.
Certainly, view equivalent schedules are factually equivalent. When
executed on any one database state, they both perform the same. We can say
that S is view-serialisable if a schedule S is view-equivalent to a sequential
schedule.

1.6.7 Transaction Management in Multi-Database System


A multi-database system is the one that permits the transactions of the
customer to invoke retrieval and update commands in opposition to data
situated in various hardware and software environments. There are two types
of transaction defined as below:
 Local transactions: Local transactions control local database system.
 Global transactions: Global transactions control multiple database system.
Transaction management is considered as complex in multi-database systems
due to the supposition of autonomy. In Global 2 Phase Locking, each local site
utilises a strict 2 Phase Locking (locks are discharged at the end). Locks set in

30
Unit 1 - MATRIX THEORY

consequence of a global transaction are released only when that transaction Notes
arrives at the end. Global 2 Phase Locking assures global serialisability.
Because of autonomy necessities, sites cannot collaborate and perform
common concurrency control method. For example, there is no way to make
sure that all databases pursue strict 2 Phase Locking.
The solutions to these include:
 provide very low level of simultaneous execution, or
 utilise weaker levels of consistency
Each local DBMS executes local transactions. These are executed outside of
the multiple-database system control. We perform global transactions under
multi-database control.
Local database managements systems cannot correspond directly to coordinate
global transaction execution. The multi-database cannot manage local
transaction execution.
To make sure that DBMS’s schedule is serialisable, there is a need of local
concurrency control technique. In locking, DBMS must be able to protect
against local deadlocks.
Additional methods are required to guarantee global serialisability. DBMS
guarantees local serialisability between its local transactions, together with
those that are part of a global transaction. The multi-database guarantees
serialisability between global transactions. This is done by overlooking the
orderings induced by local transactions. Two-level serialisability (2LSR) does
not guarantee global serialisability; however, it can fulfil the needs for strong
accuracy.
Now let us discuss the Global-read protocol and Local-read protocol.
Global-read protocol: Global transactions are capable to read, however, they
cannot perform updation of local data items. Global data cannot be accessed by
local transactions. No reliability constraints are there among local and global
data items.
Local-read protocol: Local transactions comprise read access to global data. It
prohibits all access to local data by global transactions.
A transaction comprises value dependency if the value that it writes to a data
item at one site relies on a value that it read for a data on another site.

1.6.8 Long Duration Transactions


At times you will find a set of applications in which a database system is
suitable for satisfying data. Yet the model of diverse small transactions for
which database concurrency-control techniques are proclaimed, is not suitable.
Now you will study the problems that arise during long transactions.

31
Database Management System

Notes Problems of Long Transactions


A long transaction is the one that is permitted too much time to hold locks, and
that particular lock is needed by another transaction. According to the
environment, long time could signify hours, minutes or seconds.
We can presume that at least a number of minutes, and most likely hours, are
included in "long" transactions. There are three extensive categories of
applications that include long transactions. These are:
1. Conventional DBMS applications: Although general database applications
perform usually short transactions, several applications require sporadic
long transactions. For instance, a transaction may inspect all the bank's
accounts to verify that total balance is correct. A different application
might need one index to be reconstructed infrequently to maintain working
at its height.
2. Design systems: An object designed may be mechanical such as a car,
electronics like a microwave, or software system; the universal aspect of
the design systems is that the design is separated into a set of different parts
or components (for example, codes of some software scheme), and many
designers work on these different components simultaneously. We would
not like 2 designers working on a copy of one file, doing some edition in
designs, and then composing the new file versions. This is for the reason
that one group of changes would over-write the other.
Therefore, the system of check-out and check-in permits one designer to
"check-out" a file and ‘check-in’ after the final changes, possibly hours or
days afterwards. In this case, even if, the first designer is doing some
changes a second designer may want to check out the file to discover
something regarding its subjects.
Workflow systems: These systems include accumulations of processes,
some performed by software itself, some including human contact, and
probably some by human action alone. For instance, we will now consider
an office paperwork including a bill payment. Such applications may take
some time to perform, and throughout this period, some database
components may be subject to some changes.

1.6.9 High Performance Transaction Systems


High-performance transaction systems assist in enhancing the rate of
transaction processing, but are inadequate to acquire high performance:
 Disk I/O is a restricted access. I/O time does not decrease at a rate
analogous to the increase in processor speeds.
 Parallel transactions may try to read or write the similar data item, resulting
in data conflicts that decrease effectual parallelism.

32
Unit 1 - MATRIX THEORY

We can diminish the extent to which a database system is disk bound by Notes
augmenting the size of the database buffer.
Main memory database: Commercial 64-bit systems can sustain main
memories of tens of gigabytes. Memory resident data permits quicker
processing of transactions.
We will now study some disk-related limitations. These are given below:
 Use group-commit to decrease various output operations.
 If the system crashes, all of main memory is vanished.
 Logging is a restricted access when transaction rate is high.
 If the update rate for customised buffer blocks is high, the disk data-
transfer rate could turn out to be a restricted access.

Check Your Progress 2


1. What are the tasks carried out by the transaction manager?
.......................................................................................................................
...................................................................................................................
2. Explain serialisability and recoverability.
.......................................................................................................................
.......................................................................................................................

1.7 LET US SUM UP


A database is a collection of related data stored in a standard format, designed
to be shared by several users. Data models consist of basic operations which
are used for database updates and retrievals. A series of operations comprising
database operations that is atomic with regard to concurrency and recovery is
called transaction. If any step of the transaction does not succeed, then the
entire transaction is bound to fail. Online transaction processing is considered
as interactive in which every transaction is processed as it takes place. In
transaction processing, serialisability is considered as the property of a
serialisable schedule. Serialisability is the main criterion for the accuracy of
simultaneous transactions executions and a main objective for concurrency
control.

1.8 LESSON END ACTIVITY


Research for controversies related with data model.

1.9 KEYWORDS

33
Database Management System

Notes Aborted: A database transaction, if determined by the DBMS to have failed,


enters the aborted state.
Active: The transaction stays in this state while it is executing.
Data Processing: The process of converting the facts into meaningful
information.
Database: A group of related information which can be used by various users
for different reasons.
Failed: A database transaction enters the failed state when its normal execution
can no longer proceed due to hardware or program errors.
Metadata: Data that describe the properties or characteristics of other data.
Partially committed: A database transaction enters this phase when its final
statement has been executed.
View: It is conceptually a table, but the records of this table are not stored in
the database.
Committed: A database transaction enters the committed state when enough
information has been written to disk after completing its execution with
success.

1.10 QUESTIONS FOR DISCUSSION


1. What is Hierarchical data model? Explain with an example.
2. Explain the concept of data models.
3. What are the differences between File processing systems and DBMS?
4. Write short notes on Disadvantages of Database Management System.
5. What is data abstraction? Why is it necessary?
6. What is Data independence? Explain the types of Data Independence.
7. What are the functional components of a database system? Discuss.
8. Discuss the responsibilities of transaction manager and buffer manager.
9. Explain the different methods used for resolving deadlocks.
10. Explain the concept of high performance transaction systems.

Check Your Progress: Model Answers


CYP 1
1. A generalization is a relationship between more generic classes, for
example Animal, and a more specific class, for example Dog. The generic

34
Unit 1 - MATRIX THEORY

class is the class that generalizes the specific one and the specific one that Notes
specializes the generic one. A generalization can be interpreted as an “is-
a” relationship. So, the generic class is the superclass whereas the specific
class is the subclass.
2. A link denotes a connection through which an object collaborates with
other objects. Rumbaugh has defined it as “a physical or conceptual
connection between objects”. Through a link, one object may invoke the
methods or navigate through another object. A link depicts the
relationship between two or more objects.

CYP 2
1. Following are the advanced Object and class concepts:
o Association Ends
o N-ary Associations
o Aggregation
o Abstract Classes
o Multiple Inheritance
o Meta Data
o Reification
o Constraints
o Derived Data
o Packages
o Dependency and its modeling
o Classifiers
o Visibility.
2. The visibility of the attributes and operations can be represented in the
following ways:
Public: A public member is visible from anywhere in the system. In class
diagram, it is prefixed by the symbol ‘+’.
Private: A private member is visible only from within the class. It cannot be
accessed from outside the class. A private member is prefixed by the symbol
‘−’.
Protected: A protected member is visible from within the class and from the
subclasses inherited from this class, but not from outside. It is prefixed by the
symbol ‘#’.

1.11 SUGGESTED READINGS


 Abraham Silberschatz, Henry F. Korth, S. Sudarshan, "Database
System Concepts", Tata McGraw-Hill, 2011.

35
Database Management System

Notes  G. K. Gupta, “Database Management Systems”, Tata McGraw-Hill,


2011.
 Ramez Elmasari, Shamkant B. Navathe, "Fundamentals of Database
Systems", Pearson Education Asia, 2008.
 Sumathi S., Esakkirajan S., “Fundamentals of Relational Database
Management Systems”, Springer, 2007.
 Patricia Ward, George Dafoulas, “Database Management Systems”,
Cengage Learning, 2006.

36

Você também pode gostar