Database Concepts 1. 1
CSE2132 Database Systems
Week 1 Lecture Database Concepts
Database Concepts 1. 2
Data - An Informal DefinitionData are raw facts. Facts concerning people, places, events, or other
objects/concepts. They can be of any type:
qualitative or quantitativehistorical or predictionabstract or subjective
Sources(1)External to an organization: telephone calls, turnaround
documents, remote workstation (point of sale) transactions.(2)Internal to an organization: financial and management accounting
production and operation management, payroll and personnel.(3)From “strange” places: metal sensor on the street, digitizing of an
image, hardware failure messages.
Database Concepts 1. 3
Data and the Organization• Data by itself is useless unless it is some how aggregated,
organized and prepared in a form convenient for decision making or other organizational activities.
DATA INFORMATION ACTION
A lack of data leads to inadequate information and thus ill-informeddecisions and business collapse.
Database Concepts 1. 4
Data as Resource
Why use database?
Data is a valuable corporate resource which needs adequate, accuracy, consistency and security controls.
The centralized control of data means that for many applications the data will already exist, and facilitate quicker development.
Data will no longer be related by application programs, but by the structure defined in the database.
Easier to maintain systems
Database Concepts 1. 5
Basic Definitions
Database: A collection of related data
Schema: Some part of the real world about which data is stored in the database.
Database Management System(DBMS):A software package to facilitate the creation, maintenance and protection of a computerized database.
Database Concepts 1. 6
A DBMS and Interfaced Utilities
Query Language(e.g.SQL)
Data Dictionary
ApplicationGenerator
ReportGenerator
Graphics
DataentryScreens
ApplicationPrograms
DBMS
Data
(Frontend)
Database Concepts 1. 7
Traditional File Systems Databases are often contrasted to traditional file systems
though they are now rarely used. But as the problems that existed were the impetus for the development of the “Database Concept” it is worth noting some of these.
- Applications were often considered in relative isolation.
- Data that should have been together was not.
- The potential for flexible enquiry and reporting was limited.
- All validations were in the programs.
- Procedures were required for backup and recovery.
- All programmers had access to all records.
- There was limited concurrent access.
Database Concepts 1. 8
Objectives of Database Technology
· Program-Data Independence· Minimal Data Redundancy· Increased Data Sharing· Improved Data Quality · Improved Security of Data· Improved Access to Data· Reduced Program Maintenance· Inter-relate Data Through Model
Database Concepts 1. 9
Program-Data Independence
· Data is stored independently of the programs· The degree to which descriptions of data are embedded in
application programs.· Can the database structure be changed with no impact on
programs ?· Role of the database catalog or dictionary.· Maintenance costs are high !
Database Concepts 1. 10
Degrees of Data Independence
· Device Characteristics· Blocking Factors· Data Access Organization· Physical Record Location· Logical Views (Local)· Virtual Data Items· Virtual Records· Data Value Characteristics· Data Element Name Only
GreaterIndependence
Database Concepts 1. 11
Inter-Related Data
CLAIMS
RENEWALS
AGENCY
DBMS
RENEWALS
CLAIMS AGENCY
QUERY
Data related by structure
Flexible Inquiry easier LOCALVIEWS
Database Concepts 1. 12
Application Development
· Some companies use database technology as just a multi-key access method:
CLAIMS
PREMIUMS
DBMS CLAIMS DB
PREMIUMS DBDBMS
Database Concepts 1. 13
· Applications & their data needs are not considered in isolation.
· Centralized control of one or several databases takes place. i.e database administration.
· Data administration is seen as an important part of system development.
CLAIMS
PREMIUMS
CLAIMS
PREMIUMS
DBMS
Application Development
Database Concepts 1. 14
Semantic Data Integrity
· Validation or integrity rules may be defined and automatically invoked at run time by the DBMS regardless of the source of update i.e. application program, 4GL screen or query language.
· Significant variation exists among DBMS in the level of support for semantic data integrity.
· ISO suggest that 100% of all enterprise rules should be held in the conceptual schema, and specifically none in application programs.
· An area of significant development during the 1990's.
Database Concepts 1. 15
CATALOGUEData Definitions &
Integrity Rules
STORED DATA
DBMS
ApplicationPrograms
4GL Screens &Stored Procs.
InteractiveQuery
Language
Semantic Data Integrity
Database Concepts 1. 16
Database Transactions
EMP# SALARY DEPT
E1 50,000 D1E2 18,000 D1
DEPT# T0TAL SALARY
D1 68,000D2 90,000
A database transaction may be defined as a group (one or more) of database operations which need to be treated as one atomic unit which may either succeed or fail. That is all the database operations must succeed or all the database operations must fail.
If this is not the case tasks can be half complete and the database loses it’s integrity.
Database Concepts 1. 17
Concurrency Control
Part 2 QOH 10
Part 2 QOH 10
Part 2 QOH 5
Part 2 QOH 20Part 2 QOH 10QOH=QOH+10
QOH=QOH-5
Transaction 1 Transaction 2
Problems such as the “lost update” can arise if no measures are taken to support concurrent transactions. The DBMS should support multiple concurrent transactions potentially using the same data and ensure that the data remains consistent at all times.
readread
write
write
Database Concepts 1. 18
Record LockingTo avoid concurrency problems, transactions must be made
logically serial. One common technique used is record locking. That is, a transaction can lock a record, preventing update by another transaction, until completed. Although TX2 waits a little while both complete without error.
TX1 TX2
Part 10 lock
Part 20 lock
Part 30 lock
Part 301 lock
Part 20 wait
Part 101 lock
timeend trans.
end trans.
Part 20 lock
Database Concepts 1. 19
DeadlockThe technique of locking introduces it’s own problems.DBMS
packages with record locking must also be able to handle "deadlock" situations.
TRANSACTION A TRANSACTION B lock 10 lock 20
request 20 wait request 10 wait
Note that both transactions above could wait forever!Deadlock detection algorithms can be used to detect this situation amongst locked records. Usually the least expensive transaction is aborted.
Database Concepts 1. 20
Restart and Recovery· Many DBMS maintain redundant copies of data in a log file to
support recovery from failures. This may be on disk or tape.
· Copies of record images after update , together with periodic dumping of the database allow for rollforward recovery where the database contents are not intact. A dump of the database is an exact copy of the content of the database at some point in time.
· Copies of record images before update allow rollback recovery of changes made by incomplete or failed transactions.
· Many DBMS take periodic checkpoints to reduce recovery time in the event of failure. A rollback recovery then goes back to the checkpoint rather than the start of the transaction.
Database Concepts 1. 21
Rollforward Recovery
A log file of After Images of recordschanged since the last dump was takenare applied in a forward order thru time.
A dump of the databasefrom the previous period.
The restored database shows no effect of the major disaster such as a “disk crash”.
Database Concepts 1. 22
Rollback Recovery
A Log file of Before Imagesof records which are changed are kept. If a transaction fails, the before images are written back to the database in reverse order thru time. When the start of the failed transaction is reached the rollback stops.
The restored databasein a state as if the transaction never occurredso no effects of the transaction failure are apparent.
Database Concepts 1. 23
Security
· Each user may require identification with a user-id and password.
· Users may be limited in the data they can see and what actions they can perform on that data.
· The DBMS may encrypt and decrypt data as it is stored and retrieved.
· Many systems now provide data value sensitive security.
Database Concepts 1. 24
Easy Access to Data· High level query languages provided by DBMS provide
easy access to data
20 READ #1, CUSTNO, NAME, BAL30 IF END #1 GO TO 8040 IF BAL > 20050 PRINT CUSTNO, NAME, BAL60 ENDIF70 etc
VERSUS
SELECT CUSTNO, NAME, BAL FROM CUSTDB WHERE BAL > 200;
Database Concepts 1. 25
Data Models
A way of viewing or abstracting the data.
There are a number of data models on which current generation DBMS are based:
Hierarchical, Network, Relational,
Extended Relational and Object-Oriented
Database Concepts 1. 26
The Costs of DBMSThe initial purchase cost
Planning and design
Database education
Application conversion
System overheads (response)
Complexity of support