Vous êtes sur la page 1sur 30

Databases

Topic 10:
Supporting Transactions

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.2

Scope and Coverage


This topic will cover:
Business rules
Identifying and documenting transactions
Views and de-normalisation

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.3

Learning Outcomes
By the end of this topic, students will be able to:
Identify transactions
Understand business rules and their implications
Recognise potential performance issues
Identify the potential need for de-normaliation

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.4

Boat Rental System - 1

BOAT 1 0...N RENTAL 0...N 1 CUSTOMER

1
0...N
DAMAGE

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.5

Boat Rental System - 2


Domain Base Relation
DamageType varchar length 30 Rentals(
BoatID number NOT NULL,
Base Relation CustomerID number NOT NULL,
Boats( RentalStartDate date NOT NULL,
BoatID number NOT NULL, RentalEndDate date NOT NULL,
BoatName varchar 30 NOT NULL Primary Key (BoatID, CustomerID,
Primary Key (BoatID); RentalStartDate),
Foreign Key (BoatID) REFERENCES Boat (BoatID),
Base Relation Foreign Key (CustomerID) REFERENCES
Customers( Customer(CustomerID));
CustomerID number NOT NULL,
CustomerName varchar 30 NOT Base Relation
NULL, Damage(
CustomerAddress varchar 60 NOT BoatID number NOT NULL,
NULL, CustomerID number NOT NULL,
Primary Key (Customer ID); RentalStartDate date NOT NULL,
DamageType DamageType);

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.6

What is a Business Rule?


A procedure/ process/ way of doing something/
custom/ method that is particular to a business and
needs to be taken account of in the structure of
data and/or the design of an application.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.7

Transactions
Transactions are the units of work in a database
system.
Transactions can be made up of one or more
operations. Operations are usually defined as:
CREATE or INPUT
RETRIEVE CRUD or IRUD
UPDATE
DELETE

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.8

Identify Transactions

What are they? What tables do they affect?

How often do they run?


What do they do?

What attributes do they affect?

How many rows do they affect?

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.9

What to Look at
Transactions that are frequent and could affect the
efficiency and performance of the database
Critical transactions vital to the running of the
business
Transactions that take place in peak periods

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.10

How to Investigate
Look at each transaction and work out what tables
it will affect.
Work out if there are tables that are used by many
transactions.
Look at how the data is affected by the transaction.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.11

Transactions in the Boat Hire System


a. Enter the details of all the boats. Update any details for
customers. Delete boats.
b. Enter the details for customers. Update any details for
customers.
c. Enter the details for hiring of boats.
d. Enter the details for any damage to boats.
e. List the details of all the boats.
f. List the details of all the customers; their hire and for which
boats.
g. List the details for damage, to which boats, during which
hire periods and for which customers.
h. Provide a summary of the hires for a particular period.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.12

Blank CRUD Matrix


Transaction/ A B C D E F G H
Relations

Boat
Customer

Rental
Damage

Draw this diagram and then look at the transactions


again.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.13

Competed CRUC Matrix


Transaction/ A B C D E F G H
Relations

Boat CUD R R
Customer CU R R

Rental C R R R
Damage C R R

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.14

Attribute Level
A transaction may affect some attributes in a table
but not others.
Or it may affect different attributes in the same
table in different ways, e.g. updating one and
deleting another.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.15

Analysing Tranactions
CRUD
Does the transaction involve any predicates
(specific conditions in the where clause)?
Attributes
Frequency

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.16

Transaction Analysis Form


Transaction Analysis Form
1st Jan 2010
Transaction (e) List the details of all boats
Transaction volume
Average 1 per day
Peak 100 times per day during production of promotional literature (June)

Select boatID, boatName


From Boats

Boats (50) Boats


(50)
Access Entity Type of Access Average Number
Peak Number
1 Boats R 1 * 50
100 * 50

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.17

Indexes
Improve performance
They work by creating entries in a special structure,
so that makes it easier to find a record.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.18

Performance
Increasingly, databases contain large amounts of
data...
The rate at which a query can return an answer
can be slowed when it has to sort though large
numbers of records.
Performance becomes an issue...

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.19

Applications
The software that is used to access the data in
a database...

Websites Forms

Queries Types of
Application

Reports Batch processes

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.20

Roles in a System
Not every user is the same.

Users will need to access different parts of the


system and access it in different ways.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.21

Boat Hire System - Roles


Manager should be able to access all parts of the
system, because their role means that they might have
to add and delete any data and be able to see anything.
Admin Assistant just carries out routine tasks, such
as adding any new customers and recording damage to
boats.
Table/User Boat Customer Rental Damage

Manager CRUD CRUD CRUD CRUD

Admin R CRU CRU CRU


Assistant

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.22

SQL Facilities to Manage Roles


Grant gives a particular role or user in the
database system access to an object (such as a
table).

Revoke removes access to an object (such as a


table) from a particular role or user in the database
system.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.23

Grant
Grant create on Boat to Admin

Grant all on Boat to Manager

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.24

Revoke
Revoke all on Boat from Admin

Revoke delete on Boat to Manager

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.25

De-Normalisation
We have created a database following all the rules
of normalisation...

Now we can break them to make the database


work quicker and perform better...

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.26

Improving Performance with the


Use of Views
Query

Table 1
View of
selected rows
Table 2
or columns of
these tables

Table 3

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.27

View in the Boat Hire System


What view would support the Transaction G?
List the details for damage: which boats, during
which hire periods and for which customers?
Without a view, this query has to access all 4
tables.
Do this as part of self study.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.28

Learning Outcomes Have We


Met Them?
By the end of this topic, students will be able to:
Identify transactions
Understand business rules and their implications
Recognise potential performance issues
Identify the potential need for de-normalisation

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.29

References
Connolly, T. & Begg, C. (2004). Database Systems: A
Practical Approach to Design, Implementation, and
Management, 4th edition. Addison Wesley. Chapter
20.

V1.0 NCC Education Limited


Supporting Transactions Topic 10 - 10.30

Topic 10 Supporting Transactions

Any Questions?

V1.0 NCC Education Limited

Vous aimerez peut-être aussi