DB2 Unit 2
DB2 Unit 2
DB2 Unit 2
Page 1 of 33
DB2
IBM DATABASE2 (DB2) is IBM's Relational Data Base Product.
Page 2 of 33
DB2 (Contd..)
Page 3 of 33
DB2 (Contd..)
Page 4 of 33
DB2 (Contd..)
Benefits of DB2
Ease of use. Non-procedural. (Specify what data you want, not how to get it) DB2 uses Optimizer for selecting the access path to the required data. Provides interactive facilities for : Testing Debugging Program preparation and execution
Page 5 of 33
DB2 (Contd..)
Benefits of DB2 (Contd..)
Provides full data protection including data security, data integrity and data recovery. Reduces application design and development efforts. Provides a language interface.
Page 6 of 33
DB2 (Contd..)
Page 7 of 33
DB2 (Contd..)
Page 8 of 33
DB2 (Contd..)
Page 9 of 33
DB2 (Contd..)
Components of DB2
Locking Services : IRLM (IMS Resource Lock Manager) DB2 treats data as a shared recourse Any number of users can access the same data simultaneously A concurrency control mechanism is required to isolate the users from one another IRLM provides this mechanism which is called Locking
Page 10 of 33
10
DB2 (Contd..)
Components of DB2 (Contd..)
System Services Controls the overall DB2 execution environment Manages log datasets Gathers statistics for performance monitoring Handles system startup & shutdown. Controls attachment to other MVS subsystems such as CICS, TSO etc.
Page 11 of 33
11
DB2 (Contd..)
Components of DB2 (Contd..)
System Services (Contd..) Performs commit, rollback, checkpoint and recovery. Supports operator communication and logging functions
Page 12 of 33
12
DB2 (Contd..)
Components of DB2 (Contd..)
Database Services Supports the functions of SQL i.e. definition, access control, manipulation of user & system data.
Page 13 of 33
13
DB2 (Contd..)
Other DB2 Features
DB2 Subsystem A copy of DB2 that runs on a CPU One CPU can have more than one DB2 subsystems running on it Information about DB2 subsystem is maintained in DB2s Directory and Catalog.
Page 14 of 33
14
DB2 (Contd..)
Other DB2 Features
Directory Solely for DB2s internal use. Catalog
DB2 (Contd..)
DB2 Features (Contd..)
DB2 Catalog tables for security __________________________________
Table Name DESCRIPTION _________________________________________ Records privileges held by auth-ids over: SYSIBM.SYSCOLAUTH Specific columns in tables and views SYSIBM.SYSTABAUTH Tables and views. SYSIBM.SYSDBAUTH Databases. SYSIBM.SYSPLANAUTH Application plans. SYSIBM.SYSUSERAUTH The DB2 subsystem. SYSIBM.SYSTESAUTH Tablespaces, storage groups and bufferpools.
Page 16 of 33
16
DB2 (Contd..)
Page 17 of 33
17
DB2 (Contd..)
DB2 as Perceived by an Individual User
There will be many users, all operating on the same data at the same time. Users are protected from one another.
Tables are of two types Base Tables Views A base table is a real table that exists physically. A View is a virtual table that does not actually exist in the physical storage but looks to the user as if it did.
Page 18 of 33
18
DB2 (Contd..)
Database Services
Supports the definition, retrieval and update of user & system data. Subcomponents are: Precompiler (PRECOM) Bind (BIND) Runtime Supervisor (RS) Data Manager (DM) Buffer Manager (BM)
These together allow: Preparation of application programs for execution. Subsequent execution of these programs
Page 19 of 33
19
DB2 (Contd..)
Database Services (Contd..)
Precompiler Preprocessor for the host language Function
Analyze a host language source module.
DB2 (Contd..)
Database Services (Contd..)
Precompiler (Contd..)
Page 21 of 33
21
DB2 (Contd..)
Database Services (Contd..)
Bind
Checks for errors, using the DB2 Catalog. Checks for authorization.
Selects optimized access path.
Page 22 of 33
22
DB2 (Contd..)
Package
Single bound DBRM with optimized access path. If one DBRM used in the plan is changed only that Package needs to be rebound.
New packages can be bound to the package collection without binding the plan.
Each package is assigned to exactly one collection when it is bound. Collections are essentially just a means of giving a name to a logically related set of packages.
DB2_Tr Ver. 1.0.0 04/12/1998 Page 23 of 33 23
DB2 (Contd..)
Plan
Executable module containing access path logic produced by DB2 optimizer. Consists of names of packages and/or directly bound DBRM(s). Bind produces such a plan by binding together the specified packages and DBRMs.
Page 24 of 33
24
DB2 (Contd..)
Packages and Plans:
Previously all of the DBRMs for a given application were simultaneously compiled into optimized code and bound together into the required application plan.
Page 25 of 33
25
DB2 (Contd..)
The disadvantages were :
If an individual DBRM needed to be recompiled, the entire plan had to be recompiled and rebound. If multiple plans involved the same DBRM, the same DBRM had to be recompiled multiple times. If that DBRM ever needed to be recompiled, then all the relevant plans had to be recompiled. Adding a new DBRM to the existing plan required again a recompilation and rebind of the entire plan.
Page 26 of 33
26
DB2 (Contd..)
The package concept was introduced as a remedy.
If a given DBRM needs to be recompiled, all that has do be done is an appropriate package bind.
If multiple plans involve the same DBRM, that DBRM can now be compiled once, and the corresponding package referenced multiple times in multiple plan binds.
Page 27 of 33
27
Page 28 of 33
28
Page 29 of 33
29
Source Module
Compiler
(Logically Part of Collection) Object Module List of Packages and/or DBRMs Package
Linkage Editor
Bind
Runtime Supervisor
Data Manager
Buffer Manager
DB
(Other)
Main Memory
Page 30 of 33
30
DBRM
Catalog
Package Bind
List of Packages
Package
Stored in Directory
Plan Bind
Application Plan
Stored in Directory
Page 31 of 33
31
DB2 (Contd..)
Database Services (Contd..)
Runtime Supervisor (RS) RS is resident in main storage when the application program is executing.
DB2 (Contd..)
Database Services (Contd..)
Data Manager It performs all of the normal access method functions i.e. search, retri eval, update, and so on. In short, this component manages the physical database(s) Buffer Manager Physically transfer data between the external medium and virtual storage; in effect, it performs the actual I/O operations.
Page 33 of 33
33