0% found this document useful (0 votes)
2 views

Module 6 Lecture

Chapter 6 of the Database Concepts textbook focuses on database administration, highlighting the importance of concurrency control, security, and backup/recovery. It covers key concepts such as ACID transactions, locking mechanisms, and the differences between optimistic and pessimistic locking. Additionally, it discusses user processing rights, roles, and application-level security measures to ensure database integrity and security.

Uploaded by

samerelking3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Module 6 Lecture

Chapter 6 of the Database Concepts textbook focuses on database administration, highlighting the importance of concurrency control, security, and backup/recovery. It covers key concepts such as ACID transactions, locking mechanisms, and the differences between optimistic and pessimistic locking. Additionally, it discusses user processing rights, roles, and application-level security measures to ensure database integrity and security.

Uploaded by

samerelking3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Database Concepts

Ninth Edition

Chapter 6
Database Administration

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Learning Objectives (1 of 2)
2

• Understand the need for and importance of database administration


• Know basic administrative and managerial D BA functions
• Understand the need for concurrency control, security, and backup
and recovery
• Learn about typical problems that can occur when multiple users
process a database concurrently
• Understand the use of locking and the problem of deadlock
• Learn the difference between optimistic and pessimistic locking
• Know the meaning of AC I D transaction
• Learn the four 1992 AN S I standard isolation levels
• Learn different ways of processing a database using cursors

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Learning Objectives (2 of 2)
3

• Understand the need for security and specific tasks for


improving database security
• Know the difference between recovery via reprocessing
and recovery via rollback/rollforward
• Understand the nature of the tasks required for recovery
using rollback/rollforward

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Data Administration Terms
4

Understand the need for and importance of


database Administration
• Data administration refers to a function that applies to an
entire organization concerning corporate data privacy and
security issues.
• Database administration refers to a more technical
function that is specific to a particular database, including
applications associated with it.
• Database administrator (DBA) refers to the person in
charge of a database and facilitates the development of
use of it.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 5.27 Heather Sweeney Designs:
5

Database Design

Note: From the previous chapter showing the final database design for Heather Sweeney
Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.1 The HSD Database in MySQL
6

Workbench

Oracle MySQL Community Server 8.0, Oracle Corporation


Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.2 The Database Processing
7

Environment

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Concurrency Control
8

Understand the need for concurrency control,


security, and backup and recovery
• Concurrency control ensures that one user’s work does
not inappropriately influence another user’s work.
• Users should be able to enter an order and get the same
result whether there are no other users, or hundreds of
other users.
• No concurrency control technique is ideal for all
circumstances, they all involve trade-offs.
– Strict concurrency requires locking the database, thus not
allowing any other user (high price to pay)
– Other measures allow more throughput (maximum rate of
processing) but has a lower concurrency control
Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
The Need for Atomic Transactions
9

Understand the need for concurrency control,


security, and backup and recovery
• Users submit work in the form of transactions, also know as
logical units of work (LUWs).
• An atomic transaction is one where a series of actions are
taken on a database such that all of them are performed
successfully or none of them are performed at all.
• An example of an atomic transaction is:
– Change the customer transaction, increasing the value of
Amount Owed.
– Change the salesperson record, increasing the value of
Commission Due.
– Insert the new-order record into the database.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
10

Figure 6.3 Comparison of the Results of Applying


Serial Actions Versus a Multiple-Step Transaction

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
11

Figure 6.4 Example of Concurrent Processing of


Two Users’ Tasks

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Lost Update Problem
12

Learn about typical problems that can occur


when multiple users process a database
concurrently
• If two users are attempting to update the same piece of
data at the same time, it is possible that one update may
overwrite the other update.
• If one user’s update overwrites the other’s, this is called a
lost update problem (concurrent problem).
• If one user reads data that have been processed by only a
portion of another user’s transaction, this is called a
inconsistent read problem.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.5 Example of the Lost
13

Update Problem

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Resource Locking
14

Understand the use of locking and the problem


of deadlock
• Resource locking prevents concurrent processing
problems by disallowing sharing by locking data that are
retrieved for update.
• Locks placed by the DBMS are called implicit locks,
while those placed by command are called explicit locks.
• Exclusive lock locks an item from access of any type.
– No other transaction can read or change the data
• A shared lock locks an item from being changed but not
from being read.
– Other transactions can read the data but not alter it
Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Resource Locking
15

• Lock granularity refers to whether a lock applies to data


at the record level, page level, table level, or database
level.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.6 Example of Concurrent
16

Processing with Explicit Locks

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Serializable Transactions
17

Understand the use of locking and the problem


of deadlock
• When two or more transactions are processed
concurrently, the results in the database should be
logically consistent with the results that would have been
achieved had the transactions been processed in an
arbitrary serial fashion.
• A scheme for processing concurrent transactions in this
way is said to be serializable

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Two-Phased Locking
18

Understand the use of locking and the problem


of deadlock
• One way to achieve serializable transactions is by using
two-phased locking.
• Two-phased locking lets locks be obtained and released
as they are needed:
– a growing phase, when the transaction continues to
request additional locks
– a shrinking phase, when the transaction begins to
release the locks

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Deadlock
19

Understand the use of locking and the problem


of deadlock
• As a transaction begins to lock resources, it may have to
wait for a particular resource to be released by another
transaction.
• Sometimes two transactions may indefinitely wait on each
other to release resources. This condition is known as a
deadlock or the deadly embrace.
• This condition can lock up a computer preventing use by
any user until it is fixed.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.7 Examples of Deadlock
20

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Optimistic Versus Pessimistic
21

Locking
Learn the difference between optimistic and
pessimistic locking
• Optimistic locking assumes that no conflict will occur.
Data are read, the transaction processed, updates are
issued, and then a check is made to see if conflict
occurred. If a conflict occurred it is rolled back and
repeated until successful.
• Pessimist locking assumes that conflict will occur, thus
locks are issued, the transaction completed, and then the
locks are released.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.8 Example of Optimistic
22

Locking

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.9 Example of Pessimistic
23

Locking

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
SQL Transaction Control Language
24

(TCL)
Learn the difference between optimistic and
pessimistic locking
• The SQL BEGIN TRANSACTION statement
• The SQL COMMIT TRANSACTION statement
• The SQL ROLLBACK TRANSACTION statement
Note: Exact SQL syntax varies between various DBMS products.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.10 Example of Marking
25

Transaction Boundaries

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
ACID Transaction (1 of 3)
26

Know the meaning of ACID transaction


• Sometimes the acronym ACID is applied to transactions.
• An ACID transaction is one that is atomic, consistent, isolated,
and durable.
– Atomic:
§ an atomic transaction is one in which all of the database
actions occur, or none of them do
§ a transaction consists of a series of steps, each of which must
be successful to be saved
– Consistent
§ a consistent transaction means that no other transactions are
permitted on the records until the current transaction finishes;

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
ACID Transaction (2 of 3)
27

Consistency
• Statement-level consistency requires that a statement apply to a set of
rows that is consistent from the beginning of the statement until the
end of the statement.
• Transaction-level consistency indicates that the set of rows will remain
consistent throughout the processing of all statements within the
transaction.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
ACID Transaction (3 of 3)
28

Know the meaning of ACID transaction


– Isolation
§ because of multiuser environments, different
transactions may be operating on the same data which
can result in continuously changing data content
§ 1992 ANSI SQL standard defines four isolation levels
that specify which of the concurrency control problems
are allowed
– Durable
§ a durable transaction is one in which all committed
changes are permanent

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.11 Summary of Data Read
29

Problems

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.12 Summary of Isolation
30

Levels

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Cursor
31

Learn different ways of processing a database


using cursors
• A cursor is a pointer into a set of rows that is the result set from
an SQL SELECT statement.
• Cursors are usually defined using SELECT statements.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Cursor Types
32

Learn different ways of processing a database


using cursors
• Cursors can be forward only or scrollable.
• In SQL Server, these cursors can be one of three different
types:
– static cursor (takes a snapshot and processes it)
– dynamic cursor (a fully featured cursor)
– keyset cursor (combines some features of static and some
of dynamic cursors)
• Other DBMS products may define a different set of cursors.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.13 Summary of Cursor
33

Types

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.14 Database Security
34

Authentication and Authorization


Database security strives to ensure that:
– only authorized users
– perform authorized activities

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.15 Creating the MySQL User
35

Login

Oracle MySQL Community Server 8.0, Oracle Corporation


Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.16 Using the Workbench to
36

Grant Privileges to a Database Schema

Oracle MySQL Community Server 8.0, Oracle Corporation


Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
User Processing Rights and
37

Responsibilities
Understand the need for security and specific
tasks for improving database security
• Processing rights define who is permitted to do what, and
when they can do it.
• The individuals performing these activities have full
responsibility for the implications of their actions.
• An important principle of database security administration
is that administrative permissions are given to user groups
(also known as user roles) and not to individual users
unless necessary.
• Individuals are identified by a username and a password.
Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.17 A Model of DBMS
38

Security

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.18 MySQL Administrative
39

Roles

Oracle MySQL Community Server 8.0, Oracle Corporation


Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.19 Processing Rights at
40

Heather Sweeney Designs


DATABASE RIGHTS GRANTED
Table Administrative Management System
Assistants Administrator
SEMINAR Read, Insert, Change Read, Insert, Change, Grant Rights, Modify
Delete Structure
CUSTOMER Read, Insert, Change Read, Insert, Change Grant Rights, Modify
Structure
SEMINAR_ Read, Insert, Change, Read, Insert, Change, Grant Rights, Modify
CUSTOMER Delete Delete Structure
CONTACT Read, Insert, Change Read, Insert, Change, Grant Rights, Modify
Delete Structure
INVOICE Read, Insert, Change Read, Insert, Change, Grant Rights, Modify
Delete Structure
LINE_ITEM Read, Insert, Change, Read, Insert, Change, Grant Rights, Modify
Delete Delete Structure
PRODUCT Read, Insert, Change Read, Insert, Change, Grant Rights, Modify
Delete Structure

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.20 Creating a New
41

Connection for HsdUser

Oracle MySQL Community Server 8.0, Oracle Corporat


Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.21 DBMS Security
42

Guidelines

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Application-Level Security
43

Understand the need for security and specific


tasks for improving database security
• Application level security is often provided on the Web server
computer.
• When application security is executed on this server, sensitive
security data do not need to be transmitted over the network.
• For example, when users (who are logged in) click a particular
button on a browser page, the following query is sent to the
Web server and then to the DBMS

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Database Backup and Recovery
44

Know the difference between recovery via


reprocessing and recovery via
rollback/rollforward
• Common causes of database failures:
– hardware failures
– programming bugs
– human errors/mistakes
– malicious actions
• As these issues are impossible to completely avoid, recovery
procedures are essential.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Recovery via Reprocessing
45

Know the difference between recovery via


reprocessing and recovery via
rollback/rollforward
• In reprocessing, all application activities since the backup was
performed are redone.
• The time it takes to do this is the same amount of time it took
when first entered.
• One downside is that if the system is heavily scheduled, it might
never catch up.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Recovery via Rollback & Rollforward
46

Know the difference between recovery via


reprocessing and recovery via rollback/rollforward
• Most database management systems provide a mechanism to record
activities into a log file.
– to undo a transaction the log must contain a copy of every data-base
record before it was changed
§ such records are called before-images
§ a transaction is undone by applying before-images of all its changes
to the database
– to redo a transaction the log must contain a copy of every database
record (or page) after it was changed
§ these records are called after-images
§ a transaction is redone by applying after-images of all its changes to
the database
• The log file is then used for recovery via rollback or rollforward.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Rollforward
47

Know the difference between recovery via


reprocessing and recovery via
rollback/rollforward
• Database activities recorded in the log files may be
replayed.
• In doing so, all activities are reapplied to the database.
• This procedure is used to resynchronize restored
database data by adding transactions to the last full
backup.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Rollback
48

Know the difference between recovery via


reprocessing and recovery via
rollback/rollforward
• Log files save database activities in sequence order.
• It is possible to undo activities in reverse order that they
were originally executed.
• This is performed to correct or undo erroneous or
malicious transaction(s) after a database is recovered
from a full backup.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.22 Undo and Redo
49

Transactions

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.23 Transaction Log Example
50

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.24 Recovery Example
51

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Figure 6.25 Backing Up the HSD
52

Database

Oracle MySQL Community Server 8.0, Oracle Corporation


Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Additional D BA Responsibilities (1 of 2)
53

Know basic administrative and managerial DBA


functions
• The D BA needs to ensure that a system exists to gather and
record user-reported errors and other problems:
– a method must be devised to prioritize those errors and
problems and to ensure that they are corrected accordingly
• The D BA needs to create and manage a process for controlling
the database configuration:
– procedures for recording change requests
– conducting user and developer reviews of such requests
– creating projects and tasks

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Additional DBA Responsibilities (2 of 2)
54

Know basic administrative and managerial DBA


functions
• The DBA is responsible for ensuring that appropriate
documentation is maintained:
– database structure
– concurrency control
– security and backup and recovery
– applications used
• Every organization should have a Service Level
Agreement with the cloud provider that covers backups,
application response time, and error reporting.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved
Copyright
55

This work is protected by United States copyright laws and is


provided solely for the use of instructors in teaching their
courses and assessing student learning. Dissemination or sale of
any part of this work (including on the World Wide Web) will
destroy the integrity of the work and is not permitted. The work
and materials from it should never be made available to students
except by instructors using the accompanying text in their
classes. All recipients of this work are expected to abide by these
restrictions and to honor the intended pedagogical purposes and
the needs of other instructors who rely on these materials.

Copyright © 2020, 2017, 2015 Pearson Education, Inc. All Rights Reserved

You might also like