0% found this document useful (0 votes)
54 views32 pages

Chapter A1

Uploaded by

vibhormurti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views32 pages

Chapter A1

Uploaded by

vibhormurti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

IBDP CS Database Chapter – A1

Database : Basic Concepts


A 1.1Data and information
Data is meaningless. To be useful, data must be interpreted to produce
information.

Data Processing Information


A 1.2Key difference:
@ Data usually refers to raw data, or unprocessed data.

@ 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.

@ Information is "knowledge communicated or received concerning a particular


fact or circumstance."
@ Information is a sequence of symbols that can be interpreted as a message. It
provides knowledge or insight about a certain matter.
Some differences between data and information:
@ Data is used as input for the computer system. Information is the output of
data.

@ Data is unprocessed facts figures. Information is processed data.

@ Data doesn’t depend on Information. Information depends on data.

@ Data is not specific. Information is specific.

@ Data is a single unit. A group of data which carries news is called Information.

@ Data doesn’t carry a meaning. Information must carry a logical meaning.

@ Data is the raw material. Information is the product.


A1.3 Information System
An Information System (IS) is any combination
of information technology and people's activities
using that technology to support operations,
management, and decision-making.

In a very broad sense, the term information


system is frequently used to refer to the
interaction between people, algorithmic
processes, data and technology.
Database
A database system is a term that is typically used to encapsulate the
constructs of a data model, database Management system (DBMS)
and database.
Databases are a component within an
information system.
A database is an organised pool of
logically-related data. Data is stored
within the data structures of the database.
A DBMS is a suite of computer software
providing the interface between users and
a database(s).
Components of DBMS

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

Consistent state, by ensuring that interdependent operations on the


system are either all completed successfully or all canceled successfully.
Rollback
The Rollback transaction is a transaction which rolls back the transaction to the
beginning of the transaction. The transaction can be rolled back completely by
specifying the transaction name in the Rollback statement or to cancel any changes
to a database during current transaction. It is permissible to use before Commit
transaction.

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.

Atomicit Consistenc Isolatio Durabilit


y y n y
Atomicity

• A transaction must be an atomic unit of work; either all of its data


modifications are performed, or none of them is performed.

• A transaction must be fully complete, saved (committed) or


completely undone (rolled back). A sale in a retail store database
illustrates a scenario which explains atomicity, e.g., the sale consists of
an inventory reduction and a record of incoming cash. Both either
happen together or do not happen - it's all or nothing.
Consistency

• 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

• Transaction data must not be available to other transactions until the


original transaction is committed or rolled back.

• Modifications made by concurrent transactions must be isolated from


the modifications made by any other concurrent transactions. A
transaction either recognizes data in the state it was in before another
concurrent transaction modified it, or it recognizes the data after the
second transaction has completed, but it does not recognize an
intermediate state.
Durability

• After a transaction has completed, its effects are permanently in place


in the system. The modifications persist even in the event of a system
failure.
• Transaction data changes must be available, even in the event of
database failure.
Concurrency Control
In a single-user database, the user can modify data in the database without concern for other
users modifying the same data at the same time. However, in a multiuser database, the
statements within multiple simultaneous transactions can update the same data. Transactions
executing at the same time need to produce meaningful and consistent results.
Therefore, control of data concurrency and data consistency is vital in a multiuser database.

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:

1. Pessimistic concurrency control

2. Optimistic concurrency control

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

2 Ana Trujillo Avda. de la


Ana Trujillo México D.F. 05021 Mexico
Emparedados Constitución 2222
3 Antonio Moreno
Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
Taquería
4
Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK

5
Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden

SELECT column_name, column_name FROM table_name WHERE column_name operator value;

SELECT * FROM Customers WHERE Country='Mexico';

SELECT * FROM Customers WHERE CustomerID=1;


UPDATE table_name
SET column1=value1, column2=value2,...
WHERE some_column=some_value;

UPDATE Customers
SET ContactName='Alfred Schmidt', City='Frankfurt'
WHERE CustomerID=1;

UPDATE Customers
SET ContactName='Juan'
WHERE Country='Mexico';
A 1.9 Data validation

Data validation guarantees to your


application that every data value is
correct and accurate. You can design
data validation into your application
with several differing approaches: user
interface code, application code, or
database constraints.
Types of validation
There are a number of validation types that can be used to check the data that is being entered.

Validation type How it works Example usage

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

Number of hours worked must be less than 50 and more


Range check Checks that a value falls within the specified range
than 0

Spell check Looks up words in a dictionary When word processing


Data Verification
Data verification refers to the process wherein the data is checked for accuracy and
inconsistencies after data migration are done. This helps to determine whether data
was accurately translated when data is transported from one source to another, is
complete, and supports processes in the new system.
There are two main methods of verification:

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]

Data (the booking code) are unorganized/unstructured/unprocessed terms;


Whereas information (hotel’s email) is organized/structured/processed data;

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]

o The minimal step of operation/update to be performed on a database;


o That guarantees consistency/integrity of the database;
o And recovery upon failure;

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]

You might also like