Chapter A1
Chapter A1
@ It is the basic form of data, data that hasn’t been analyzed or processed in any
manner.
@ Once the data is analyzed, it is considered as information.
@ Data is a single unit. A group of data which carries news is called Information.
Data Definition. Defining new data structures for a database, removing data
structures from the database, modifying the structure of existing data.
Data Maintenance. Inserting new data into existing data structures, updating
data in existing data structures, deleting data from existing data structures.
Data Retrieval. Querying existing data by end-users and extracting data for use
by application programs.
Data Control. Creating and monitoring users of the database, restricting access
to data in the database and monitoring the performance of databases.
A 1.4 What is Transaction in DBMS?
A transaction is a set of changes that
must all be made together.
Process :
For example, to ensure data
consistency when moving money
between two accounts it is necessary
to complete two operations (debiting
one account and crediting the other).
Unless both operations are carried out
successfully, the transaction will be
rolled back.
A 1.5 Transaction state
Roll forward
Recovering a database by applying different transactions that recorded in the
database log files. It is nothing but re-doing the changes made by a transaction i.e.
after the committed transaction and to over write the changed value again to ensure
consistency.
A 1.7 Properties of Database Transactions
A transaction is a sequence of operations performed as a single logical
unit of work. A logical unit of work must exhibit four properties, called
the atomicity, consistency, isolation, and durability (ACID) properties,
to qualify as a transaction.
• The transaction must be fully compliant with the state of the database
as it was prior to the transaction. In other words, the transaction cannot
break the database’s constraints. For example, if a database table’s
Phone Number column can only contain numerals, then consistency
dictates that any transaction attempting to enter an alphabetical letter
may not commit.
Isolation
Data concurrency means that Data consistency means that each user
many users can access data at sees a consistent view of the data,
the same time. including visible changes made by the
user's own transactions and transactions
of other users.
To describe consistent transaction
behavior when transactions run at the
same time, database researchers have
defined a transaction isolation model
called serializability. The serializable
mode of transaction behavior tries to
ensure that transactions run in such a way
that they appear to be executed one at a
time, or serially, rather than concurrently.
When multiple users attempt to make modifications to a data at the same, some level
of control should be established to that having one user’s modification affect
adversely can be prevented. The process of controlling this is called concurrency
control.
There are three common ways that databases manage data concurrency and they are
as follows:
3. Last in wins
Pessimistic Optimistic concurrency
concurrency control
control With this method, a row
in this method, a cannot be available to
row is available to other users while the data
the users when the is currently being updated.
record is being During updating, the
fetched and stays database examined the row
with the user until
it is updated in the database to
within the determine whether or not
database . any change has been made.
An attempt to update a
record that has already
been changed can be
flagged as concurrency
violation.
Last in wins –
with this method, any row can never be available to users while the data is currently
being updated but there is no effort made to compare updates with the original
record.
The record would simply be written out. The potential effect would be overwriting
any changes that are being made by other concurrent users since the last refresh of
the record.
Some DBMS have multi-version concurrency control. This works by automatically providing read
consistency to a query which results in a situation where all data seen by query can only come from a
single point in time, or a term known as statement level read consistency. Another read consistency is
the transaction level read consistency.
The RDMS uses the information stored in the rollback segments which contain old values of data
that have been altered by recently committed or uncommitted transactions to get a consistent view.
Both consistency and concurrency are closely related to each other in database systems.
RDBMS
Relational database management System - languages use specific programming languages such
as SQL to store, retrieve and manipulate stored data. Scripting languages used in web
development such as PHP use "query" functions to send these commands to the target database.
g
g
Select Insert Update
Queries that encapsulate a "select" Queries that encapsulate an "insert" Queries that encapsulate an "update"
command are used to retrieve data command are used to add new rows command modify rows of data that
from databases. The command of data to a database. The command are already stored in a given
specifies conditions to retrieve rows specifies which table within the database table. The command can
of data and return them to the database will receive the data. update one or more fields in every
program. row in which another given field
holds a specified value.
CustomerI CustomerName ContactName Address City PostalCode Country
D
1
Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
5
Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden
UPDATE Customers
SET ContactName='Alfred Schmidt', City='Frankfurt'
WHERE CustomerID=1;
UPDATE Customers
SET ContactName='Juan'
WHERE Country='Mexico';
A 1.9 Data validation
The last one or two digits in a code are used to check the
Check digit Bar code readers in supermarkets use check digits
other digits are correct
A National Insurance number is in the form LL 99 99 99 L
Format check Checks the data is in the right format
where L is any letter and 9 is any number
Length check Checks the data isn't too short or too long A password which needs to be six letters long
Lookup table Looks up acceptable values in a table There are only seven possible days of the week
Presence check Checks that data has been entered into a field In most databases a key field cannot be left blank
Double entry - entering the data twice and Proofreading data / Visual Varification - this
comparing the two copies. This effectively method involves someone checking the data
doubles the workload, and as most people are entered against the original document. This is
paid by the hour, it costs more too. also time-consuming and costly.
Exercise Questions :
1. A tourist has booked a double room, non-smoking, at the Overlook Hotel. The tourist used an
online booking service called Best Fare that compares offers from different hotels.
Best Fare confirms the transaction by communicating only the booking code 3EP9RE to the tourist.
The tourist later receives an email from the hotel, with further details.
(a) Outline the difference between data and information, in relation to the booking code. [2]
OR
Data lacks meaning e.g. on their own data elements, Code, name, room;
Whereas information is interpreted data (the code interpreted by the system) and has meaning (eg
email provides meaningful information to the tourist about the use of the Code);
(b) Define the term database transaction. [2]
For example:
Minimal set of actions that complete/make the booking;
So that database is accurate/consistent/has integrity;
So that database is updated to prevent others booking room;
So that recovery can be run on failure;
(c) Describe the use of transactions to maintain data consistency. [3]
o Modifications on data are made persistent in the database only if the transaction terminates;
o A roll-back operation is performed if a failure occurs prior to termination of the transaction;
o And this keeps the database in the original consistent status;
For example:
Transactions conform to rules before update to database;
Transactions must complete fully to make the changes permanent/persistent;
Allows roll-back operation in case of failure;
To ensure database is consistent while performing transactions;
(d) Explain what is meant by isolation in the transaction described above. [2]
An example must be seen for the second mark to be awarded. (It means concurrent control;)
It says/defines/specifies how and when the changes of a process are visible to concurrent
operations;
For example:
using locks on data to prevent concurrent writing that would lead to inconsistency as in the case of
two people booking the same room;
(e) Explain the benefits offered by data sharing in databases, for two of the stakeholders in this
scenario. [6]
General explanation (“What it Tourist
is”): Can quickly/efficiently access;
A wide choice of hotels/offers/prices;
Data sharing/replication: all/part of Best Fare
one/several source databases are Can efficiently display offers on a wide selection of hotels;
shared/replicated according to the Can develop/extend existing software when new hotels are created;
needs of different user groups; Can develop/re-use the same application without major
modifications;
The information needed by the Hotel
group is made ‘closer’ to the user; The hotel needs to rely on new applications and increasing speed is
an issue (cost/maintenance);
Hence, less focus on Allowing the sharing of information in the source database gives
transmission/traffic (expensive or more visibility to the hotel, making it more competitive;
slow or not available or not The hotel can continue to locally operate only on part of the data in
convenient), but requires more the source database, using less advanced software;
storage space (but storage is cheap); Allows hotel to change prices and offers in real-time; [4]
[2]