Escolar Documentos
Profissional Documentos
Cultura Documentos
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
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.
9
Database Management System
Notes
is a matrix of the
order 4 × 3
are diagonal
matrices of order 1, 2, 3, respectively.
10
Unit 1 - MATRIX THEORY
Notes
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,
11
Database Management System
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
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.
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
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
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.
16
Unit 1 - MATRIX THEORY
Root Notes
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.
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.
18
Unit 1 - MATRIX THEORY
19
Database Management System
Notes
Catalog
Capture
Transaction Manager
Order
Orders
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.
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.
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.
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.”
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.
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.
25
Database Management System
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
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.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
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.
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.
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.
31
Database Management System
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.
1.9 KEYWORDS
33
Database Management System
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 ‘#’.
35
Database Management System
36