8. distributed and mobile dbms.pdf
TRANSCRIPT
chapter13.ppt September 98
1
©Pearson Education 2009 1
Department: Computer Science.
Unit Name: Database Management Systems
Unit Code: CSC 304
Adopted by: Obuhuma James
©Pearson Education 2009 2
Distributed and Mobile DBMSs
Reference:
Connolly, T. M. and Begg, C. E., Database Systems: A Practical Approach to Design, Implementation, and Management, 5th Edition, Addison Wesley: 2010.
©Pearson Education 2009
Objectives
� Main concepts of distributed DBMSs (DDBMSs)
� Differences between DDBMSs and distributedprocessing.
� Advantages and disadvantages of distributeddatabases.
� Main issues associated with distributed databasedesign.
� How fragmentation should be carried out.
� The importance of allocation and replication.
3 ©Pearson Education 2009
Objectives
� Levels of transparency that should be provided byDDBMS.
� Main concepts associated with databasereplication.
� Main concepts associated with mobile DBMSs.
4
©Pearson Education 2009
DDBMS concepts
Distributed Database
A logically interrelated collection of shared data(and a description of this data), physicallydistributed over a computer network.
Distributed DBMS
Software system that permits the management of thedistributed database and makes the distributiontransparent to users.
5 ©Pearson Education 2009
DDBMS concepts
� Collection of logically-related shared data.
� Data split into fragments.
� Fragments may be replicated.
� Fragments/replicas allocated to sites.
� Sites linked by a communications network.
� Data at each site is under control of a DBMS.
� DBMSs handle local applications autonomously.
� Each DBMS participates in at least one globalapplication.
6
chapter13.ppt September 98
2
©Pearson Education 2009
Distributed DBMS
7 ©Pearson Education 2009
Distributed processing
� A centralized database that can be accessed over acomputer network.
8
©Pearson Education 2009
Advantages of DDBMSs
� Reflects organizational structure
� Improved shareability and local autonomy
� Improved availability
� Improved reliability
� Improved performance
� Economics
� Modular growth.
9 ©Pearson Education 2009
Disadvantages of DDBMSs
� Complexity
� Cost
� Security
� Integrity control more difficult
� Lack of standards
� Lack of experience
� Database design more complex.
10
©Pearson Education 2009
Types of DDBMS
� Homogeneous DDBMS� All sites use same DBMS product.
� Much easier to design and manage.
� Approach provides incremental growth and allowsincreased performance.
� Heterogeneous DDBMS� Sites may run different DBMS products, with
possibly different underlying data models.
� Occurs when sites have implemented their owndatabases and integration is considered later.
� Translations required. Typical solution: gateways.
11 ©Pearson Education 2009
Multidatabase system (MDBS)
DDBMS in which each site maintains completeautonomy.
� DBMS that resides transparently on top of existingdatabase and file systems and presents a singledatabase to its users.
� Allows users to access and share data withoutrequiring physical database integration.
� Unfederated MDBS (no local users) and federatedMDBS.
12
chapter13.ppt September 98
3
©Pearson Education 2009
Taxonomy of DBMSs
13 ©Pearson Education 2009
Distributed database design
Three key issues:
� Fragmentation,
� Allocation,
� Replication.
14
©Pearson Education 200915
Distributed database design
Fragmentation
Relation may be divided into a number of sub-relations, which are then distributed.
Allocation
Each fragment is stored at site with “optimal”distribution.
Replication
Copy of fragment may be maintained at several sites.
©Pearson Education 200916
Fragmentation
� Definition and allocation of fragments carried outstrategically to achieve:
� Locality of Reference.
� Improved Reliability and Availability.
� Improved Performance.
� Balanced Storage Capacities and Costs.
� Minimal Communication Costs.
� Involves analyzing most important applications,based on quantitative/qualitative information.
©Pearson Education 200917
Fragmentation
� Quantitative information may include:
� frequency with which an application is run;
� site from which an application is run;
� performance criteria for transactions andapplications.
� Qualitative information may include transactionsthat are executed by application, type of access(read or write), and predicates of read operations.
©Pearson Education 200918
Why fragment?
� Usage: Applications work with views rather thanentire relations.
� Efficiency: Data is stored close to where it is mostfrequently used.� Data that is not needed by local applications is not
stored.
� Parallelism: With fragments as unit ofdistribution, transaction can be divided intoseveral subqueries that operate on fragments.
� Security: Data not required by local applications isnot stored and so not available to unauthorizedusers.
chapter13.ppt September 98
4
©Pearson Education 200919
Why fragment? - Disadvantages
� Performance,
� Integrity.
©Pearson Education 200920
Correctness rules for fragmentation
� Three correctness rules:
� Completeness,
� Reconstruction,
� Disjointness.
©Pearson Education 200921
Correctness rules for fragmentation
Completeness
If relation R is decomposed into fragments R1, R2, ...Rn, each data item that can be found in R mustappear in at least one fragment.
Reconstruction
� Must be possible to define a relational operationthat will reconstruct R from the fragments.
� Reconstruction for horizontal fragmentation isUnion operation and Join for vertical.
©Pearson Education 200922
Correctness rules for fragmentation
Disjointness
� If data item di appears in fragment Ri, then itshould not appear in any other fragment.
� Exception: vertical fragmentation, where primarykey attributes must be repeated to allowreconstruction.
� For horizontal fragmentation, data item is a tuple.
� For vertical fragmentation, data item is anattribute.
©Pearson Education 200923
Types of fragmentation
� Four types of fragmentation:
� Horizontal,
� Vertical,
� Mixed,
� Derived.
� Other possibility is no fragmentation:
� If relation is small and not updated frequently, maybe better not to fragment relation.
©Pearson Education 200924
Horizontal and vertical fragmentation
chapter13.ppt September 98
5
©Pearson Education 200925
Mixed fragmentation
©Pearson Education 200926
Horizontal fragmentation
� Consists of a subset of the records of a table.
� Defined using WHERE clause in SQL SELECT.
� For example:
DC1: SELECT * FROM DVDCopy WHERE dCenterNo=‘D001’;
DC2: SELECT * FROM DVDCopy WHERE dCenterNo=‘D002’;
DC3: SELECT * FROM DVDCopy WHERE dCenterNo=‘D003’;
DC4: SELECT * FROM DVDCopy WHERE dCenterNo=‘D004’;
©Pearson Education 200927
Vertical fragmentation
� Consists of a subset of the columns of a table.
� Defined using SELECT clause of SQL SELECT.
� For example:
S1: SELECT staffNo, position, salary FROM Staff;
S2: SELECT staffNo, name, eMail, dCenterNo FROM Staff;
©Pearson Education 200928
Mixed fragmentation
� Consists of a horizontal fragment that is vertically
fragmented, or a vertical fragment that is
horizontally fragmented.
� For example, from above example:
SELECT * FROM S2 WHERE dCenterNo = ‘D001’;
SELECT * FROM S2 WHERE dCenterNo = ‘D002’;
SELECT * FROM S2 WHERE dCenterNo = ‘D003’;
SELECT * FROM S2 WHERE dCenterNo = ‘D004’;
©Pearson Education 200929
Derived horizontal fragmentation
� A horizontal fragment that is based on horizontalfragmentation of a parent relation.
� Ensures that fragments that are frequently joined togetherare at same site.
� For example:
DR1: SELECT dr.* FROM DVDRental dr, DC1
WHERE dr.DVDNo = DC1.DVDNo;
DR2: SELECT dr.* FROM DVDRental dr, DC2
WHERE dr.DVDNo = DC2.DVDNo;
DR3: SELECT dr.* FROM DVDRental dr, DC3
WHERE dr.DVDNo = DC3.DVDNo;
DR4: SELECT dr.* FROM DVDRental dr, DC4
WHERE dr.DVDNo = DC4.DVDNo;
©Pearson Education 200930
Data allocation
Centralized: Consists of single database and DBMSstored at one site with users distributed across thenetwork.
Partitioned: Database partitioned into disjointfragments, each fragment assigned to one site.
Complete Replication: Consists of maintainingcomplete copy of database at each site.
Selective Replication: Combination of partitioning,replication, and centralization.
chapter13.ppt September 98
6
©Pearson Education 200931
Comparison of data allocation strategies
©Pearson Education 200932
Distributed database design methodology
1. Use normal methodology to produce a design for theglobal relations.
2. Examine topology of system to determine wheredatabases will be located.
3. Analyze most important transactions and identifyappropriateness of horizontal/vertical fragmentation.
4. Decide which tables are not to be fragmented.
5. Examine tables on 1 side of relationships and determinea suitable fragmentation schema. Tables on many sidemay be suitable for derived fragmentation.
©Pearson Education 200933
Transparencies in a DDBMS
� Distribution Transparency
� Fragmentation Transparency
� Location Transparency
� Replication Transparency
� Local Mapping Transparency
� Naming Transparency
©Pearson Education 200934
Transparencies in a DDBMS
� Transaction Transparency
� Concurrency Transparency
� Failure Transparency
� Performance Transparency
� DBMS Transparency
©Pearson Education 200935
Distribution transparency
� Distribution transparency allows user to perceivedatabase as single, logical entity.
� If DDBMS exhibits distribution transparency, userdoes not need to know:� data is fragmented (fragmentation transparency),
� location of data items (location transparency),
� otherwise call this local mapping transparency.
� With replication transparency, user is unaware ofreplication of fragments.
©Pearson Education 200936
Transaction transparency
� Ensures that all distributed transactionsmaintain distributed database’s integrity andconsistency.
� In IBM’s Distributed Relational DatabaseArchitecture (DRDA), four types of transactions:
� Remote request
� Remote unit of work
� Distributed unit of work
� Distributed request.
chapter13.ppt September 98
7
©Pearson Education 200937
IBM’s DRBA
©Pearson Education 200938
Concurrency transparency
� All transactions must execute independently and belogically consistent with results obtained iftransactions executed one at a time, in some arbitraryserial order.
� Same fundamental principles as for centralizedDBMS.
� DDBMS must ensure both global and localtransactions do not interfere with each other.
� Similarly, DDBMS must ensure consistency of allsubtransactions of global transaction.
©Pearson Education 200939
Concurrency transparency
� Replication makes concurrency more complex.� If a copy of a replicated data item is updated, update must
be propagated to all copies.� Could propagate changes as part of original transaction,
making it an atomic operation. However, if one siteholding copy is not reachable, then transaction is delayeduntil site is reachable.
� Could limit update propagation to only those sitescurrently available. Remaining sites updated when theybecome available again.
� Could allow updates to copies to happen asynchronously,sometime after the original update. Delay in regainingconsistency may range from a few seconds to severalhours.
©Pearson Education 200940
Failure transparency
� DDBMS must ensure atomicity and durability ofglobal transaction.
� Means ensuring that subtransactions of globaltransaction either all commit or all abort.
� Thus, DDBMS must synchronize global transaction toensure that all subtransactions have completedsuccessfully before recording a final COMMIT forglobal transaction.
� Must do this in presence of site and network failures.
©Pearson Education 200941
Failure transparency – Two-phase Commit
� Two phases: a voting phase and a decision phase.
� Coordinator asks all participants whether they areprepared to commit transaction.� If one participant votes abort, or fails to respond within a timeout
period, coordinator instructs all participants to abort transaction.
� If all vote commit, coordinator instructs all participants tocommit.
� All participants must adopt global decision.
� If participant votes abort, free to abort transactionimmediately
� If participant votes commit, must wait for coordinator tobroadcast global-commit or global-abort message.
©Pearson Education 200942
Failure transparency – Two-phase Commit
chapter13.ppt September 98
8
©Pearson Education 200943
Performance transparency� DDBMS must perform as if it were a centralized DBMS.
� DDBMS should not suffer any performance degradation due to
distributed architecture.
� DDBMS should determine most cost-effective strategy to execute a
request.
� Must consider fragmentation, replication, and allocationschemas.
� Distributed QP maps data request into ordered sequenceof operations on local databases. DQP has to decide:� which fragment to access;
� which copy of a fragment to use;
� which location to use.
©Pearson Education 200944
Performance transparency
� DQP produces execution strategy optimized withrespect to some cost function.
� Typically, costs associated with a distributed requestinclude:
� I/O cost;
� CPU cost;
� communication cost.
©Pearson Education 200945
Performance transparency - Example
Member(memberNo, mCity) 100000 records in Seattle
DVDCopy(DVDNo, catalogNo) 1000000 records in NY
Rental(memberNo, DVDNo) 1000000 records in Seattle
SELECT dc.DVDNo
FROM DVDCopy dc, Rental r, Member m
WHERE dc.DVDNo=r.DVDNo AND r.memberNo=m.memberNoAND dc.catalogNo = ‘634817’ AND m.mCity = ‘Chicago’;
� Each record is 20 characters long.� 1000 members in Chicago; 200 000 rentals of ‘War of the
Worlds’ (634817).� Computation time negligible compared to communication
time.
©Pearson Education 200946
Performance transparency - ExampleStrategy Time
(1) Move DVDCopy table to Seattle and process query there. 33.3 mins
(2) Move Member and Rental tables to New York and process query there. 1.17hours
(3) Join Member & Rental at Seattle, select records for Chicago members, and for
each of these in turn, check at New York for an associated catalogNo = ‘634817’. 33.3mins
(4) Select DVD copies with catalogNo = ‘634817’ at New York and for each
one found, check at Seattle for a rental involving a member living in Chicago. 11.12hours
(5) Join Member and Rental tables at Seattle, select Chicago members, project
result over DVDNo, and move this result to New York for matching with
catalogNo = ‘634817’. 2 seconds
(6) Select DVD copies with catalogNo = ‘634817’ at New York and move the
result to Seattle for matching with rentals associated with Chicago members. 41 seconds
©Pearson Education 200947
Dates 12 rules for a DDBMS
0. Fundamental PrincipleTo the user, a distributed system should look exactlylike a nondistributed system.
1. Local Autonomy
2. No Reliance on a Central Site
3. Continuous Operation
4. Location Independence
5. Fragmentation Independence
6. Replication Independence
©Pearson Education 200948
Dates 12 rules for a DDBMS
7. Distributed Query Processing
8. Distributed Transaction Processing
9. Hardware Independence
10. Operating System Independence
11. Network Independence
12. Database Independence
� Last four rules are ideals.
chapter13.ppt September 98
9
©Pearson Education 200949
Replication servers
Replication
Process of generating and reproducing multiplecopies of data at one or more sites.
� Provides users with access to current data where andwhen they need it.
� Provides number of benefits, including improvedperformance when centralized resources getoverloaded, increased reliability and data availability,and support for mobile computing and datawarehousing.
©Pearson Education 200950
Replication servers
Synchronous – updates to replicated data are part ofenclosing transaction.
� If one or more sites that hold replicas are unavailabletransaction cannot complete.
� Large number of messages required to coordinatesynchronization.
Asynchronous - target database updated after sourcedatabase modified.� Delay in regaining consistency may range from few
seconds to several hours or even days.
©Pearson Education 200951
Replication - functionality
� At basic level, has to be able to copy data from onedatabase to another (synch or asynchronous).
� Other functions include:� Scalability.
� Mapping and Transformation.
� Object Replication.
� Specification of Replication Schema.
� Subscription mechanism.
� Initialization mechanism.
©Pearson Education 200952
Replication – data ownership
� Ownership relates to which site has privilege toupdate the data.
� Main types of ownership are:� Master/slave (or asymmetric replication),
� Workflow,
� Update-anywhere (or peer-to-peer or symmetricreplication).
©Pearson Education 200953
Replication – Master/Slave Ownership
� Asynchronously replicated data is owned by one
(master) site, and can be updated by only that site.
� Using ‘publish-and-subscribe’ metaphor, master site
makes data available.
� Other sites ‘subscribe’ to data owned by master site,
receiving read-only copies.
� Potentially, each site can be master site for non-
overlapping data sets, but update conflicts cannot
occur.
©Pearson Education 200954
Replication – Workflow Ownership
� Avoids update conflicts, while providing more
dynamic ownership model.
� Allows right to update replicated data to move from
site to site.
� However, at any one moment, only ever one site that
may update that particular data.
� Example is order processing system, which follows
steps, such as order entry, credit approval, invoicing,
shipping, and so on.
chapter13.ppt September 98
10
©Pearson Education 200955
Replication – Update Anywhere Ownership
� Creates peer-to-peer environment where multiple
sites have equal rights to update replicated data.
� Allows local sites to function autonomously, even
when other sites are not available.
� Shared ownership can lead to conflict scenarios and
have to detect conflict and resolve it.
©Pearson Education 200956
Mobile databases� Witnessing increasing demands on mobile computing to
provide support for growing number of mobile workers.
� Such a workforce require to work as if in the office but inreality they are working from remote location places.
� With rapid expansion of cellular, wireless, and satellitecomms, soon be possible for mobile users to access anydata, anywhere, at any time.
� However, , business etiquette, practicalities, security, andcosts may still limit communication (eg. can’t get onlineconnection for as long as want, whenever you want).
� Mobile databases offer a solution for some of theserestrictions.
©Pearson Education 200957
Mobile databasesMobile database
A database that is portable and physically separate froma centralized database server but is capable ofcommunicating with that server from remote sitesallowing the sharing of corporate data.
� Components of a mobile database environment include:� corporate database server and DBMS that manages and stores
the corporate data and provides corporate applications;� remote database and DBMS that manages and stores the
mobile data and provides mobile applications;� mobile database platform that includes laptop, PDA, or other
Internet access devices;� two-way communication links between the corporate and
mobile DBMS.©Pearson Education 2009
58
Mobile database environment
©Pearson Education 200959
Mobile DBMSs
� Additional functionality required of mobile DBMSs includes ability to:� communicate with centralized database server through
modes such as wireless or Internet access;
� replicate data on centralized database server and mobile device;
� synchronize data on centralized database server and mobile device;
� capture data from various sources such as the Internet;
� manage data on the mobile device;
� analyze data on a mobile device;
� create customized mobile applications.