SSZG554 L11

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

DISTRIBUTED DATA SYSTEMS

SSZG554
BITS Pilani
Pilani|Dubai|Goa|Hyderabad
Anil Kumar Ghadiyaram
Text Books

T1 : M. Tamer Özsu • Patrick Valduriez Principles


of Distributed Database Systems Third Edition

T2 : Distributed Operating Systems: Concepts And


Design By Pradeep K. Sinha, PHI Learning Pvt. Ltd
R1 : Storage Networks Explained– by Ulf Troppens, Wolfgang
Muller-Freidt, Rainer Wolafka, IBM Storage Software
Development, Germany. Publishers: Wiley

Note: In order to broaden understanding of concepts as applied to Indian IT industry, students are
advised to refer books of their choice and case-studies in their own organizations

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 2 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
BITS Pilani
Pilani|Dubai|Goa|Hyderabad

L11 : Data and Access Control - 2


Reference : T1 - Ch. 5

Source Courtesy: Some of the contents of this PPT are sourced from materials provided by Publishers of T1 & T2
PRESENTATION OVERVIEW

• View Management
• Views in Centralized DBMS
• Views in Distributed DBMSs
• Maintenance of Materialized Views

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 4 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
View Management

• One of the main advantages of the relational model is that it provides full logical
data independence.
• External schemas enable user groups to have their particular view of the database.
In a relational system, a view is a virtual relation, defined as the result of a query on
base relations (or real relations), but not materialized like a base relation, which is
stored in the database.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 5 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
View Management

• A view is a dynamic window in the sense that it reflects all updates to the database.
• An external schema can be defined as a set of views and/or base relations.
• Besides their use in external schemas, views are useful for ensuring data security in
a simple way.
• By selecting a subset of the database, views hide some data. If users may only
access the database through views, they cannot see or manipulate the hidden data,
which are therefore secure.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 6 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
View Management

• In a distributed DBMS, a view can be derived from distributed relations, and the
access to a view requires the execution of the distributed query corresponding to
the view definition.
• An important issue in a distributed DBMS is to make view materialization efficient

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 7 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• Most relational DBMSs use a view mechanism where a view is a relation derived
from base relations as the result of a relational query
• It is defined by associating the name of the view with the retrieval query that
specifies it.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 8 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

The view of system analysts (SYSAN) derived from relation EMP


(ENO,ENAME,TITLE), can be defined by the following SQL query:

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 9 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 10 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• The single effect of this statement is the storage of the view definition in the
catalog.
• No other information needs to be recorded.
• Therefore, the result of the query defining the view is not produced.
• However, the view SYSAN can be manipulated as a base relation

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 11 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• Find the names of all the system analysts with their project number and
responsibility involving the view SYSAN and relation ASG(ENO,PNO,RESP,DUR) can
be expressed as

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 12 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• Mapping a query expressed on views into a query expressed on base relations can
be done by query modification
• With this technique the variables are changed to range on base relations and the
query qualification is merged with the view qualification

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 13 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

The preceding query can be modified to

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 14 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 15 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• The modified query is expressed on base relations and can therefore be processed
by the query processor.
• It is important to note that view processing can be done at compile time.
• The view mechanism can also be used for refining the access controls to include
subsets of objects.
• To specify any user from whom one wants to hide data, the keyword USER generally
refers to the logged-on user identifier

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 16 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

The view ESAME restricts the access by any user to those employees having the same
title:

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 17 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 18 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• If the user who creates ESAME is an electrical engineer, as in this case, the view
represents the set of all electrical engineers

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 19 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• Views can be defined using arbitrarily complex relational queries involving


selection, projection, join, aggregate functions, and so on.
• All views can be interrogated as base relations, but not all views can be
manipulated as such.
• Updates through views can be handled automatically only if they can be
propagated correctly to the base relations.
• We can classify views as being updatable and not updatable.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 20 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• A view is updatable only if the updates to the view can be propagated to the base
relations without ambiguity.
• The view SYSAN above is updatable; the insertion, for example, of a new system
analyst h201, Smithi will be mapped into the insertion of a new employee (201,
Smith, Syst. Anal.).
• If attributes other than TITLE were hidden by the view, they would be assigned null
values.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 21 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

The following view, however, is not updatable

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 22 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• The deletion, for example, of the tuple hSmith, Analysti cannot be propagated,
since it is ambiguous.
• Deletions of Smith in relation EMP or analyst in relation ASG are both meaningful,
but the system does not know which is correct.
• Current systems are very restrictive about supporting updates through views.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 23 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Centralized DBMS

• Views can be updated only if they are derived from a single relation by selection
and projection.
• This precludes views defined by joins, aggregates, and so on
• It is interesting to note that views derived by join are updatable if they include the
keys of the base relations.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 24 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Distributed DBMSs

• A view in a distributed system may be derived from fragmented relations stored at


different sites.
• When a view is defined, its name and its retrieval query are stored in the catalog
• Since views may be used as base relations by application programs, their definition
should be stored in the directory in the same way as the base relation descriptions.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 25 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Distributed DBMSs

• Depending on the degree of site autonomy offered by the system view definitions
can be centralized at one site, partially duplicated, or fully duplicated.
• In any case, the information associating a view name to its definition site should be
duplicated.
• If the view definition is not present at the site where the query is issued, remote
access to the view definition site is necessary.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 26 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Distributed DBMSs

• The mapping of a query expressed on views into a query expressed on base


relations (which can potentially be fragmented) can also be done in the same way
as in centralized systems, that is, through query modification.
• With this technique, the qualification defining the view is found in the distributed
database catalog and then merged with the query to provide a query on base
relations.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 27 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Distributed DBMSs

• Such a modified query is a distributed query, which can be processed by the


distributed query processor
• The query processor maps the distributed query into a query on physical fragments.
• Evaluating views derived from distributed relations may be costly.
• In a given organization it is likely that many users access the same view which must
be recomputed for each user.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 28 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Views in Distributed DBMSs

• An alternative solution is to avoid view derivation by maintaining actual versions of


the views, called materialized views.
• A materialized view stores the tuples of a view in a database relation, like the other
database tuples, possibly with indices.
• Thus, access to a materialized view is much faster than deriving the view, in
particular, in a distributed DBMS where base relations can be remote.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 29 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Maintenance of Materialized Views

• A materialized view is a copy of some base data and thus must be kept consistent
with that base data which may be updated.
• View maintenance is the process of updating (or refreshing) a materialized view to
reflect the changes made to the base data.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 30 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Maintenance of Materialized Views

• Major difference is that materialized view expressions, in particular, for data


warehousing, are typically more complex than replica definitions and may include
join, group by and aggregate operators.
• Another major difference is that database replication is concerned with more
general replication configurations, e.g., with multiple copies of the same base data
at multiple sites.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 31 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Maintenance of Materialized Views

• View maintenance policy allows a DBA to specify when and how a view should be
refreshed.
• The first question (when to refresh) is related to consistency (between the view and
the base data) and efficiency.
• A view can be refreshed in two modes: immediate or deferred.
• With the immediate mode, a view is refreshed immediately as part as the
transaction that updates base data used by the view.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 32 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Maintenance of Materialized Views

• If the view and the base data are managed by different DBMSs, possibly at different
sites, this requires the use of a distributed transaction, for instance, using the two-
phase commit (2PC) protocol
• The main advantages of immediate refreshment are that the view is always
consistent with the base data and that read-only queries can be fast.
• However, this is at the expense of increased transaction time to update both the
base data and the views within the same transactions.
• Furthermore, using distributed transactions may be difficult.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 33 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Maintenance of Materialized Views

• In practice, the deferred mode is preferred because the view is refreshed in


separate (refresh) transactions, thus without performance penalty on the
transactions that update the base data.
• The refresh transactions can be triggered at different times: lazily, just before a
query is evaluated on the view; periodically, at predefined times, e.g., every day; or
forcedly, after a predefined number of updates to the base data.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 34 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Maintenance of Materialized Views

• Lazy refreshment enables queries to see the latest consistent state of the base data
but at the expense of increased query time to include the refreshment of the view.
• Periodic and forced refreshment allow queries to see views whose state is not
consistent with the latest state of the base data.
• The views managed with these strategies are also called snapshots

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 35 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Maintenance of Materialized Views

• The second question (how to refresh a view) is an important efficiency issue.


• The simplest way to refresh a view is to recompute it from scratch using the base
data.
• In some cases, this may be the most efficient strategy, e.g., if a large subset of the
base data has been changed.
• However, there are many cases where only a small subset of view needs to be
changed. In these cases, a better strategy is to compute the view incrementally, by
computing only the changes to the view.

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 36 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
THANK YOU

SSZG554 - Distributed Data Systems Date : 9th Sep 2018 37 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956

You might also like