topics in database administration

37
Topics in Database Administration What is database administration? What is data administration? What are the tasks involved in establishing, creating, implementing and maintaining a database for an organization? What are the tasks involved in: Database transaction integrity? Database backup/recovery? Database security? DBMS efficiency/optimization? 1

Upload: trevor

Post on 23-Feb-2016

34 views

Category:

Documents


0 download

DESCRIPTION

Topics in Database Administration. What is database administration? What is data administration? What are the tasks involved in establishing, creating, implementing and maintaining a database for an organization? What are the tasks involved in: Database transaction integrity? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Topics in Database Administration

Topics in Database Administration

• What is database administration?• What is data administration?• What are the tasks involved in establishing, creating,

implementing and maintaining a database for an organization?

• What are the tasks involved in:– Database transaction integrity?– Database backup/recovery?– Database security?– DBMS efficiency/optimization?

1

Page 2: Topics in Database Administration

What are the two general “activity components” of administering a database?

Category Data Administration Database Administration

Definition Function responsible for the overall management of data resources.

Function responsible for the technical viability of the database and database management system.

Scope Broad: organization-wide. Long term orientation.

Narrow: technical application. Daily operations.

Major Tasks

Sets policies and standards. Coordinates and manages database design.

Enforces policies and procedures. Chooses and maintains technology.

Page 3: Topics in Database Administration

Tasks in “data” administration

• Planning.– Assist in the development of the IS architecture.– Develop enterprise data model.

• Policies and procedures.– Establish metadata.– Assess and control the quality of the data.– Establish policies towards data ownership.– Create and enforce data governance standards.

• Internal marketing.– Explain the concept of data as a shared resource.– Resolve conflicts between organizational areas over data

ownership and governance.

3

Page 4: Topics in Database Administration

More detail: Data Resource Management Tasks

• Create and maintain organizational data strategy.– Evaluate and improve level of data integration.– Evaluate the quality of data, i.e. completeness, consistency, accuracy,

timeliness, and currency.– Identify stakeholders and ensure ongoing participation in data management.– Evaluate privacy of data. Determine ethical use of data collection and access.

• Create and maintain key data resources.– Create and maintain metadata (i.e. data about the meaning of data).– Create and maintain overall organizational data models.– Identify and maintain software library for data analysis.

• Establish data governance methods: High level organizational groups and processes that oversee the appropriate use of data for transaction processing and decision making.

4

Page 5: Topics in Database Administration

Tasks in “database” administration

• Planning.– Guide the selection of hardware and DBMS software.– Choose appropriate tool set for database administration,

development and maintenance.• Procedures and policies.

– Establish security policies.• Access.• Update.

– Establish application development policies.• Use of views.• Use of indexes.

– Establish backup and recovery policies.– Enforce policies.

5

Page 6: Topics in Database Administration

More detail: Technical Management Tasks

• Install and update the DBMS.• Create the database(s), including all tablespaces, constraints and indexes.• Populate the database(s).• Create and maintain users with appropriate security.• Assist programmers/users with logical and physical database design.• Specify appropriate test procedures for programmers/users.• Ensure data integrity through: Triggers and stored procedures; referential

integrity; additional data constructs implemented through SQL.

• Perform data backup and recovery.• Monitor and tune performance. Rewrite queries where necessary.• Select and install additional hardware and software resources as

necessary.

6

Page 7: Topics in Database Administration

Data Administrator Database AdministratorWhat formal education is required?

These are not entry-level jobs. What prior job experience is appropriate?

What skills and/or personality type would help a person do this job?

7

Page 8: Topics in Database Administration

Three of the critical technical tasks of a DBA

• Database backup and recovery.– Anticipating the event of a database failure.– Establishing & enforcing database backup & recovery

procedures.• Database security and integrity.

– Defining security requirements based on data and application needs.

– Establishing and enforcing security procedures.– Establishing and enforcing data integrity procedures.

• DBMS optimization.– Tracking current response time.– Modifying DBMS parameters to improve response time.

8

Page 9: Topics in Database Administration

Database backup and recovery

• What is backup and recovery?– Backup: A method of storing data from a database in a format

that can be used to rebuild the database if necessary.– Recovery: Mechanisms for restoring a database quickly and

accurately after loss or damage.• Why have backup and recovery?

– Human error.– Hardware failure. – Incorrect or invalid data. – Program errors.– Viruses. – Natural catastrophes.

9

Page 10: Topics in Database Administration

Backup and recovery are based on transactions

• A transaction is one or more database actions (SQL statements) that are treated as a single unit of work.– If the transaction is successful, then the transaction is committed.– If the transaction is not successful, then the transaction is rolled back or

aborted.

Order_tbl

PK OrderID

OrderDateFK1 CustomerID BillingCode

OrderLine_tbl

PK,FK1 OrderIDPK,FK2 ProductID

Quantity Price

Product_tbl

PK ProductID

Name Description QOH Cost

Customer_tbl

PK CustomerID

Name Address Zip Phone

contains

is placed

by

is for

10

Imagine a database with this structure

Page 11: Topics in Database Administration

Accepting an order for a product

11

INSERT INTO orderline_tbl VALUES (123,6812,10, 34.99);

UPDATE product_tblSET qoh = qoh - 10WHERE prod_no = 6812;

INSERT INTO order_tbl VALUES (123,’01-may-2014’, 765, ‘net30’);

Page 12: Topics in Database Administration

DBMS’s have methods to control transactions

• Databases that support transactions provide specific commands for starting, committing, and rolling back transactions.– Begin transaction.– End transaction.– Commit.– Rollback.– Autocommit.

• Transaction throughput: The number of transactions processed per time interval. This is a measure of transaction processing performance.

12

Page 13: Topics in Database Administration

Transactions have properties (ACID)

• Atomicity: A transaction is an indivisible unit of work. – Almost all languages that interface with a DBMS have a way to signify

the start and end of a transaction. – Within the start and end are one or more SQL commands.

• Consistency: The transaction moves a database from one state of consistency, through inconsistency to another state of consistency.

• Isolation: A transaction executes in isolation from other transactions. – This is also referred to as the “serializability” of transactions.– A transaction can affect another transaction, so the transaction must

be completed as though it is isolated in order to be accurate.• Durability: Once a transaction is committed, its effects on the

database are durable, or permanent. No subsequent actions or failures to the database can cause that transaction to be lost.

13

Page 14: Topics in Database Administration

Transaction boundary decision

• Division of work into transactions.• Objectives:

– Minimize transaction duration.– Ensure transaction isolation.

• Constraint: enforcement of important integrity constraints.

14

Page 15: Topics in Database Administration

Backup is conducted in 3 processes

• Backup: A DBMS software utility provides a way to do a complete, full or incremental backup of the database in a consistent state.

– Complete: entire database.– Full: all rows of specified tables.– Incremental: rows that have changed since the last full backup.

• Journalize: A DBMS software utility provides an audit trail of changes to the database.

– Transaction log: contains all data used to process changes against the database.– Database change log: contains a before-image and an after-image of each row modified

by a database transaction.• Checkpoint: A DBMS software utility that periodically suspends all transaction

processing and synchronizes files within the database. – Some databases, such as Oracle, do not actually halt processing. They simply write

checkpoint information to files. – The purpose of a checkpoint is to minimize the amount of time it takes to restore a

system.

15

Page 16: Topics in Database Administration

Recovery methods

• A DBMS has a utility to recover the database. Usually referred to as the Recovery Manager.

• The method of recovery depends on the type of failure.• Recovery Manager usually has the following options:

– Switch: Switches to a replica of the database on a different storage device.

• Requires that a mirror image of the database is stored.• Can be expensive.• Assumption is a storage failure, not a failure in transaction integrity, occurred.

– Restore/Rerun: Reprocesses the transactions for a given time period against a correct version of the database.

• Assumption is that a failure in transaction integrity has occurred.• Can be very time-consuming.

16

Page 17: Topics in Database Administration

Two common methods of restore/rerun

• Backward recovery. Also called “rollback” recovery. Used to undo unwanted changes to the database.– Imagine that the current database is inaccurate.– Before-images are applied to the current database to return it to a prior state of

consistency.– Used to back out changes that are unwanted.

• Forward recovery. Also called “rollforward” recovery. Used to recover accurate transactions and apply them to the database.– Imagine that the current database is inaccurate. This database must be replaced

with a prior, consistent version of the database before forward recovery can begin.

– After-images are applied to a past version of the database. Does not require that all transactions are applied - just takes the most recent after-images.

17

Page 18: Topics in Database Administration

Issues in database backup and recovery

• Cost.– Media.– Computer overhead (processor, memory, disk) to

create journalizing files, control files, checkpoint files, etc.

– Personnel to supervise and tune.• Time.

– Can result in regularly scheduled downtime.– Can make the system slower.

18

Page 19: Topics in Database Administration

Potential problems with shared databases

• Concurrency control is the process of managing concurrent operations against a database in order to maintain data integrity.

• Potential problems with shared databases are:– Lost Update.– Uncommitted Dependency. “Dirty Read”

19

Page 20: Topics in Database Administration

Lost update

20

Transaction A Time Transaction B Read SR (10) T1 T2 Read SR (10) If SR > 0 then SR = SR -1

T3

T4 If SR > 0 then SR = SR -1

Write SR (9) T5 T6 Write SR (9)

SR: Seats Remaining

Page 21: Topics in Database Administration

Uncommitted dependency or “dirty read”

Transaction A Time Transaction B Read SR (10) T1 SR = SR - 1 T2 Write SR (9) T3 T4 Read SR (9) Rollback T5

21

SR: Seats Remaining

Page 22: Topics in Database Administration

Methods of concurrency control

• Pessimistic approach:– Assumes that every transaction could potentially be in conflict so each

transaction should be controlled

• Optimistic approach:– Assumes that most transactions will not be in conflict so each transaction

should be checked only when something is written to disk.

• Both approaches need a Scheduler. The scheduler establishes the order in which the operations within concurrent transactions are executed. – The scheduler interleaves the execution of database operations to ensure

serializability.– Think of it as based on a time-stamp.– Some schedulers have the ability to analyze transaction content.

22

Page 23: Topics in Database Administration

23

The pessimists use locking

• Locking: Fundamental tool of pessimistic concurrency control. A lock guarantees exclusive use of a data item to a current transaction.

• Locking. Locking can be performed programmatically or left to the DBMS.– Granularity of locking depends on the DBMS.

• Database level.• Table level.• Page level.• Row level.• Column level.

• Obtain read lock before accessing an item.• Wait if a conflicting lock is held.

– Shared lock: conflicts with exclusive locks– Exclusive lock: conflicts with all other kinds of locks

• Concurrency control manager maintains the lock table

Page 24: Topics in Database Administration

Book Lost Update Example

24

Page 25: Topics in Database Administration

Lock it up!

25

Page 26: Topics in Database Administration

Both transactions get read lock and create deadlock

26

Page 27: Topics in Database Administration

Another type of deadlock

27

Page 28: Topics in Database Administration

The Optimists use versioning

28

Page 29: Topics in Database Administration

Versioning

• Assumes that most transactions read, rather than write data.

• Each transaction uses the view of the database that is current when it starts.

• When a transaction modifies a record, the DBMS create a new version rather than rewriting the old record.

• If there is a conflict, the DBMS stores the first changed version, and the second transaction is cancelled.

• The second transaction takes the new version of the data and uses that for processing.

29

Page 30: Topics in Database Administration

Database security

Database Security: Protection of the data against accidental or intentional loss, destruction, or misuse. Threats to database security include the list below.

• Accidental losses attributable to:– Human error.– Software failure.– Hardware failure.

• Theft and fraud.• Improper data access:

– Loss of privacy (personal data).– Loss of confidentiality (corporate data).

• Loss of data integrity.• Loss of availability.

30

Page 31: Topics in Database Administration

DBMS security features

• Views (frequently referred to as subschemas).• Integrity controls.• Authorization rules.

– Controls incorporated in the DBMS.– Restrict access to specific data.– Restrict actions that can be taken.

• User-defined procedures.– Trigger an authorization procedure which asks additional identification

questions.– Written in a standard programming language or proprietary language.

• Encryption.• Authentication schemes.

– Biometric devices.

31

Page 32: Topics in Database Administration

SQL Server’s approach to security

• Multi-user database systems, such as SQL Server, include security features that control how a database is accessed and used. For example, security mechanisms: – Prevent unauthorized database access. – Prevent unauthorized access to schema objects. – Control system resource usage (such as CPU time or disk usage). – Audit user actions.

• Associated with each database user is a schema. – A schema is a logical collection of database objects (tables, views,

sequences, synonyms, indexes, clusters, procedures, functions, packages, and database links).

– By default, each database user creates and has access to all objects in the corresponding schema. 32

Page 33: Topics in Database Administration

SQL statements used for securitySQL Statement Action

CREATE USER Allows the DBA to create a new user.

GRANT Allows the user to give other users privileges to access the user's objects.

CREATE ROLE Allows the DBA to create a collection of privileges that can be assigned as a group.

ALTER USER Allows users to change their passwords. Can also be used to change other attributes of a user.

REVOKE Removes privileges on an object from a user, users, or role.

Page 34: Topics in Database Administration

SQL Statements Used for Data Integrity

SQL Statement Description

Create Domain Create custom data types with predefined CHECK constraints.

Create Assertion Create constraints involving multiple tables and calculations. Similar to CHECK constraints, but allows access to multiple tables through a SELECT statement.

Triggers and Stored Procedures

Programmer can create customized integrity check through proprietary procedural language. Transact-SQL for SQL Server.

Page 35: Topics in Database Administration

DBMS query optimization

• DBMS’s are differentiated by their query optimizers.

• A query optimizer is a component of a DBMS.• You do not have the choice of how queries are

implemented on the physical database, the query optimizer assumes this responsibility.

35

Page 36: Topics in Database Administration

Query optimizer methods

• Rule based.– Looks at syntax.– Parses query and executes in the order written according to the rules pre-

established by the person who wrote the query optimizer.• Cost based.

– Looks at syntax.– Looks at statistical data about the database.– Parses query and executes based on the written and the information about

the current and historical data of the database.• Choose.

– Uses the rule based method for tables which have not been used/analyzed in the past.

– Uses the cost based method for tables which have been previously analyzed.

36

Page 37: Topics in Database Administration

Becoming a DBA

• Experience.– Application programming with a database.– Some DBA tasks.– Systems programming with a database.

• Education.– Training classes with a specific DBMS.– For example, Oracle offers a ten-class sequence for DBA’s. Most classes are

one week (40 hours) in time.– Master’s degree?

• Certification.– Specific to DBMS.– Offered by DBMS vendor.– Formal programs offered for Oracle and SQL Server; informal programs for

other DBMS types.

37