Documente Academic
Documente Profesional
Documente Cultură
7 Academic Workshop
What is Data?
Collection of facts or numbers Can be quantitative or qualitative Describes a variable or set of variables Essentially data can be thought of as the result of observations based on things like: . measurements . Statistics
Why Databases?
Data can be stored using multiple methods such as: .Text files .Comma delimited data files .Spreadsheets .Databases Why database? .The way data is accessed .The way data is handled
Managing Data
Using a database provides: .a standard interface for accessing data .multiple users with simultaneous ability to insert, update and delete data .changes to the data without risk of losing data and its consistency .the capability to handle huge volumes of data and users .tools for data backup, restore and recovery .security .reduce redundancy .data independence
Information Model
Abstract management of objects at a conceptual level Defines relationships between managed objects. Multiple implementations of an information model exists .Data models
Data Model
A model is a representation of an object or concept of the real world It can be used to map how data from the real world is to be represented in a software system
Relational databases store data using tables . A table consists of columns and rows . Each column has a specific data type . Each row features a certain value for each column
Tables
A table stores data in rows and columns like relation in relational database . Rows are the same as Tuples . Columns are the same as Attributes There can be multiple tables for different types of data to reduce redundant information . Normalization
For example: .You want to store data about a company . Data about branch offices will be stored in a table . Employee data for specific branches will be stored in its own table . Product data will be stored in another table
Columns
Columns are also known as fields Each field contains a specific type of information such as name, extension, position and so on Columns must be designated a specific data type such as DATE, VARCHAR, INTEGER
EXAMPLE
Primary Keys
Uniquely identifies each tuple (row) of the relation (table) . Relations must always have a primary key Examples . Driver's license of a person . ISBN of a book . Serial number of a product
Foreign Keys
Attribute in one relation whose values match a primary key of another relation . Defines the relationship between two tables
Why Normalization?
Consider the following table: .Lists of task an employee is involved in:
Example operation: if John moves to a new city, all entries related to John must be updated . redundancy . anomalies
Normalization
No anomalies, no redundancy No loss of information
AGENDA
Product Overview
.Editions & Features .Licensing
Fundamentals
.Architecture .Users .Instances .DB2 Client
Express C
Free to develop, distribute, deploy Optimized to use up to 2 processor cores and 2 GB memory Available for Linux, Windows, Solaris (x64) Unsupported and without warranty Does not include replication services and high availability Includes pure XML
Express
Optimized to use up to 4 GB memory and 4 processor cores Available for Linux, Windows Includes pureXML Available add-ons include Performance Expert and High Availability Feature .High Availability Feature provides 24 x 7 continuous availability for your DB2 data server Fixed Term License (FTL) available, a 12-month subscription which includes HADR
Workgroup Server
Designed for larger workloads than DB2 Express Limited to 16 GB Memory and 16 processing cores or 4 sockets Available for Linux, UNIX, Windows Identical to DB2 Express, but includes High Availability Feature
Enterprise Server
Designed for heavy workloads, large data warehouses No memory usage and processor core limits Available for Linux, UNIX, Windows, zLinux Includes pureXML, HADR etc.
Licensing
All DB2 Database editions can be purchased by: Per authorized user License type: "Authorized User Option" Per processor (priced by PVU) License type: "CPU Option" Other options of pricing, depending on edition: Per socket .Workgroup edition Per server Express edition
DB2 Agents (db2agent) .Special type of EDU to handle application requests .The DB2 engine keeps a pool of agents available to service requests DB2 has firewall to protect DB and DB manager
DB2 Users
1. Instance Owner
The instance owner home directory is where the DB2 instance will be created. Db2inst1 2. Fenced User Used to run UDF's and stored procedures outside of the address space used by the DB2 database. db2fenc1
Instances
Stand-alone DB2 environment Can have multiple instances per data server All instances share the same executable binary files Each instance has its own configuration DB2 allows installations of different versions (binaries) in the same machine
DB2 Storage
DB2 Storage includes: Table Spaces Table Space Management Buffer Pools
Buffer Pools
Area of main memory used to cache table and index data Each database must have at least one buffer pool Every table space associates a specific buffer pool of the same page size Self-Tuning Memory Manager (STMM) available
DB2 Security
1. Access to DB2 is called Authentication System verifies a user's identity .
What is HADR?
An HADR pair consists of a primary and a standby database
Primary
Handles all client connections and processes transactions Continuously ships DB2 HADR log files to the standby over TCP/IP network
Standby
Originally initialized with cloned database from the primary Keep in sync with primary by applying received transaction logs buffers
HADR Continued..
When primary goes offline (planned or unplanned), standby to take over the transactional workload Standby becomes the new primary Manual or Automatic Takeover via Tivoli System Automation (TSA) Clients transparently re-routed with Automatic Client Reroute (ACR)
Agenda
Servers, Instances, and Databases Managing Instances Creating a DB2 Database Cataloging Database (Data) Objects
Instances
Stand-alone DB2 environment Can have multiple instances per data server All instances share the same executable binary files Each instance has its own configuration
Databases
What makes up a DB2 database? .A DB2 database is made up of a collection of objects .A database contains the following objects: Tables, views, indexes, schemas . Locks, triggers, stored procedures, packages . Buffer pools, log files, table spaces
Cataloging
DB2 has multiple directories that are used to access databases 1.The system database directory contains a list and pointer to where all the known databases can be found. 2.The node directory contains information relating to how and where remote systems or instances can be found. 3.The Database Connection Services (DCS) Directory contains information relating to how and where databases on DRDA systems can be found.
Schemas
Schemas (unique identifiers) are objects that are used to logically classify and group other objects in the database. Schemas have privileges associated with them that allow the schema owner to control which users can create, alter, and drop objects within them.
Benefits of a schema:
1 Tedious to search through entire database for objects with the same name. The name of each object needs to be unique only within its schema 2. Access control
Most database objects have a two-part object name The first part being the schema name (or qualifier) The second is the object name When an object is created, you can assign it to a specific schema SCHEMA_NAME.OBJECT_NAME For example CREATE SCHEMA PAYROLL CREATE TABLE PAYROLL.STAFF Table named STAFF is assigned to the PAYROLL schema
Tables
A relational database presents data as a collection of tables A table consists of data logically arranged in columns and rows (records) each column contains values of the same data type each row contains a set of values for each column available The storage representation of a row is called a record the storage representation of a column is called a field each intersection of a row and column is called a value
Base Tables
User defined tables designed to hold persistent user data
CREATE TABLE department (deptid CHAR(4), deptname VARCHAR(30), costcenter INTEGER);
Result tables
DB2 Database Manager defined tables populated with rows retrieved from one or more base tables in response to a query
Views
Views can be seen as virtual tables derived from one or more tables or views Views do not contain real data. Can be deletable, updatable, insertable, and read-only.
Views . Example :
Indexes
An index is an object that contains an ordered set of pointers that refer to rows in a base table. They are based upon one or more columns but stored as a separate entity
Indexes - Importance
I. provide a fast, efficient method for locating specific rows of data in very large tables. II. ..provide a logical ordering of the rows of a table III. ..can be used to enforce the uniqueness of records stored in a table.
Indexes -Example
Aliases
Alias is an alternate name for an object such as a
table or view.
Aliases -Example
Sequences
A sequence is an object that is used to generate data values automatically. Unlike an identity column, a sequence is not tied to any specific column or any specific table.
Characteristics of Sequences
Values generated can be any exact numeric data type that has a scale of zero (SMALLINT, BIGINT, INTEGER, or DECIMAL). .Consecutive values can differ by any specified increment value. .Counter values are recoverable. Counter values are reconstructed from logs when recovery is required. .Values generated can be cached to improve performance.
Sequences can generate values in one of three ways: .By incrementing or decrementing by a specified amount, without bounds .By incrementing or decrementing by a specified amount to a user defined limit and stopping .By incrementing or decrementing by a specified amount to a user defined limit, and then cycling back to the beginning and starting again
Example
Triggers
A trigger defines a set of actions that are performed in response to an insert, update, or delete operation on a specified table.
Triggers . Example
User-defined Functions
User defined functions (UDFs) are special objects that are used to extend and enhance the support provided by the built in functions available with DB2. User-defined functions are created (or registered) by executing the CREATE FUNCTION SQL statement.
Stored Procedures
An SQL stored procedure is an ordinary program composed entirely of SQL statements that can be called by an application. Stored procedures can be called locally or remotely.