19.1Database System Concepts - 6 th Edition Chapter 19: Distributed Databases Heterogeneous and Homogeneous Databases Distributed Data Storage Distributed

Embed Size (px)

DESCRIPTION

19.3Database System Concepts - 6 th Edition Homogeneous Distributed Databases In a homogeneous distributed database All sites have identical software Are aware of each other and agree to cooperate in processing user requests. Each site surrenders part of its autonomy in terms of right to change schemas or software Appears to user as a single system In a heterogeneous distributed database Different sites may use different schemas and software  Difference in schema is a major problem for query processing  Difference in software is a major problem for transaction processing Sites may not be aware of each other and may provide only limited facilities for cooperation in transaction processing

Citation preview

19.1Database System Concepts - 6 th Edition Chapter 19: Distributed Databases Heterogeneous and Homogeneous Databases Distributed Data Storage Distributed Query Processing Heterogeneous Distributed Databases Cloud Database 19.2Database System Concepts - 6 th Edition Distributed Database System A distributed database system consists of loosely coupled sites that share no physical component Database systems that run on each site are independent of each other Transactions may access data at one or more sites 19.3Database System Concepts - 6 th Edition Homogeneous Distributed Databases In a homogeneous distributed database All sites have identical software Are aware of each other and agree to cooperate in processing user requests. Each site surrenders part of its autonomy in terms of right to change schemas or software Appears to user as a single system In a heterogeneous distributed database Different sites may use different schemas and software Difference in schema is a major problem for query processing Difference in software is a major problem for transaction processing Sites may not be aware of each other and may provide only limited facilities for cooperation in transaction processing 19.4Database System Concepts - 6 th Edition Distributed Data Storage Assume relational data model Replication System maintains multiple copies of data, stored in different sites, for faster retrieval and fault tolerance. Fragmentation Relation is partitioned into several fragments stored in distinct sites Replication and fragmentation can be combined Relation is partitioned into several fragments: system maintains several identical replicas of each such fragment. 19.5Database System Concepts - 6 th Edition Data Replication A relation or fragment of a relation is replicated if it is stored redundantly in two or more sites. Full replication of a relation is the case where the relation is stored at all sites. Fully redundant databases are those in which every site contains a copy of the entire database. 19.6Database System Concepts - 6 th Edition Data Replication (Cont.) Advantages of Replication Availability: failure of site containing relation r does not result in unavailability of r is replicas exist. Parallelism: queries on r may be processed by several nodes in parallel. Reduced data transfer: relation r is available locally at each site containing a replica of r. Disadvantages of Replication Increased cost of updates: each replica of relation r must be updated. Increased complexity of concurrency control: concurrent updates to distinct replicas may lead to inconsistent data unless special concurrency control mechanisms are implemented. One solution: choose one copy as primary copy and apply concurrency control operations on primary copy 19.7Database System Concepts - 6 th Edition Data Fragmentation Division of relation r into fragments r 1, r 2, , r n which contain sufficient information to reconstruct relation r. Horizontal fragmentation: each tuple of r is assigned to one or more fragments Vertical fragmentation: the schema for relation r is split into several smaller schemas All schemas must contain a common candidate key (or superkey) to ensure lossless join property. A special attribute, the tuple-id attribute may be added to each schema to serve as a candidate key. 19.8Database System Concepts - 6 th Edition Horizontal Fragmentation of account Relation branch_name account_number balance Hillside A-305 A-226 A account 1 = branch_name=Hillside (account ) branch_name account_number balance Valleyview A-177 A-402 A-408 A account 2 = branch_name=Valleyview (account ) 19.9Database System Concepts - 6 th Edition Vertical Fragmentation of employee_info Relation branch_name customer_name tuple_id Hillside Valleyview Hillside Valleyview Lowman Camp Kahn Green deposit 1 = branch_name, customer_name, tuple_id (employee_info ) account_number balance tuple_id A-305 A-226 A-177 A-402 A-155 A-408 A-639 deposit 2 = account_number, balance, tuple_id (employee_info ) 19.10Database System Concepts - 6 th Edition Advantages of Fragmentation Horizontal: allows parallel processing on fragments of a relation allows a relation to be split so that tuples are located where they are most frequently accessed Vertical: allows tuples to be split so that each part of the tuple is stored where it is most frequently accessed tuple-id attribute allows efficient joining of vertical fragments allows parallel processing on a relation Vertical and horizontal fragmentation can be mixed. Fragments may be successively fragmented to an arbitrary depth. 19.11Database System Concepts - 6 th Edition Distributed Query Processing For centralized systems, the primary criterion for measuring the cost of a particular strategy is the number of disk accesses. In a distributed system, other issues must be taken into account: The cost of a data transmission over the network. The potential gain in performance from having several sites process parts of the query in parallel. 19.12Database System Concepts - 6 th Edition Query Transformation Translating algebraic queries on fragments. It must be possible to construct relation r from its fragments Replace relation r by the expression to construct relation r from its fragments Consider the horizontal fragmentation of the account relation into account 1 = branch_name = Hillside (account ) account 2 = branch_name = Valleyview (account ) The query branch_name = Hillside (account ) becomes branch_name = Hillside (account 1 account 2 ) which is optimized into branch_name = Hillside (account 1 ) branch_name = Hillside (account 2 ) 19.13Database System Concepts - 6 th Edition Example Query (Cont.) Since account 1 has only tuples pertaining to the Hillside branch, we can eliminate the selection operation. Apply the definition of account 2 to obtain branch_name = Hillside ( branch_name = Valleyview (account ) This expression is the empty set regardless of the contents of the account relation. Final strategy is for the Hillside site to return account 1 as the result of the query. 19.14Database System Concepts - 6 th Edition Simple Join Processing Consider the following relational algebra expression in which the three relations are neither replicated nor fragmented account depositor branch account is stored at site S 1 depositor at S 2 branch at S 3 For a query issued at site S I, the system needs to produce the result at site S I 19.15Database System Concepts - 6 th Edition Possible Query Processing Strategies Ship copies of all three relations to site S I and choose a strategy for processing the entire locally at site S I. Ship a copy of the account relation to site S 2 and compute temp 1 = account depositor at S 2. Ship temp 1 from S 2 to S 3, and compute temp 2 = temp 1 branch at S 3. Ship the result temp 2 to S I. Devise similar strategies, exchanging the roles S 1, S 2, S 3 Must consider following factors: amount of data being shipped cost of transmitting a data block between sites relative processing speed at each site 19.16Database System Concepts - 6 th Edition Semijoin Strategy Let r 1 be a relation with schema R 1 stores at site S 1 Let r 2 be a relation with schema R 2 stores at site S 2 Evaluate the expression r 1 r 2 and obtain the result at S Compute temp 1 R1 R2 (r1) at S1. 2. Ship temp 1 from S 1 to S Compute temp 2 r 2 temp1 at S 2 4. Ship temp 2 from S 2 to S Compute r 1 temp 2 at S 1. This is the same as r 1 r 2. 19.17Database System Concepts - 6 th Edition Formal Definition The semijoin of r 1 with r 2, is denoted by: r 1 r 2 it is defined by: R1 (r 1 r 2 ) Thus, r 1 r 2 selects those tuples of r 1 that contributed to r 1 r 2. In step 3 above, temp 2 =r 2 r 1. For joins of several relations, the above strategy can be extended to a series of semijoin steps. 19.18Database System Concepts - 6 th Edition Join Strategies that Exploit Parallelism Consider r 1 r 2 r 3 r 4 where relation ri is stored at site S i. The result must be presented at site S 1. r 1 is shipped to S 2 and r 1 r 2 is computed at S 2 : simultaneously r 3 is shipped to S 4 and r 3 r 4 is computed at S 4 S 2 ships tuples of (r 1 r 2 ) to S 1 as they produced; S 4 ships tuples of (r 3 r 4 ) to S 1 Once tuples of (r 1 r 2 ) and (r 3 r 4 ) arrive at S 1, (r 1 r 2 ) (r 3 r 4 ) is computed in parallel with the computation of (r 1 r 2 ) at S 2 and the computation of (r 3 r 4 ) at S 4. 19.19Database System Concepts - 6 th Edition Heterogeneous Distributed Databases Many database applications require data from a variety of preexisting databases located in a heterogeneous collection of hardware and software platforms Data models may differ (hierarchical, relational, etc.) Transaction commit protocols may be incompatible Concurrency control may be based on different techniques (locking, timestamping, etc.) System-level details almost certainly are totally incompatible. A multidatabase system is a software layer on top of existing database systems, which is designed to manipulate information in heterogeneous databases Creates an illusion of logical database integration without any physical database integration 19.20Database System Concepts - 6 th Edition Advantages Preservation of investment in existing hardware system software Applications Local autonomy and administrative control Allows use of special-purpose DBMSs Step towards a unified homogeneous DBMS Full integration into a homogeneous DBMS faces Technical difficulties and cost of conversion Organizational/political difficulties Organizations do not want to give up control on their data Local databases wish to retain a great deal of autonomy 19.21Database System Concepts - 6 th Edition Unified View of Data Agreement on a common data model Typically the relational model Agreement on a common conceptual schema Different names for same relation/attribute Same relation/attribute name means different things Agreement on a single representation of shared data E.g., data types, precision, Character sets ASCII vs EBCDIC Sort order variations Agreement on units of measure Variations in names E.g., Kln vs Cologne, Mumbai vs Bombay 19.22Database System Concepts - 6 th Edition Query Processing Several issues in query processing in a heterogeneous database Schema translation Write a wrapper for each data source to translate data to a global schema Wrappers must also translate updates on global schema to updates on local schema Limited query capabilities Some data sources allow only restricted forms of selections E.g., web forms, flat file data sources Queries have to be broken up and processed partly at the source and partly at a different site Removal of duplicate information when sites have overlapping information Decide which sites to execute query Global query optimization 19.23Database System Concepts - 6 th Edition Mediator Systems Mediator systems are systems that integrate multiple heterogeneous data sources by providing an integrated global view, and providing query facilities on global view Unlike full fledged multidatabase systems, mediators generally do not bother about transaction processing But the terms mediator and multidatabase are sometimes used interchangeably The term virtual database is also used to refer to mediator/multidatabase systems 19.24Database System Concepts - 6 th Edition Cloud computing A new concept is computing that emerged in the late 1990s and the 2000s. First, software as a service Vendors of software services provided specific customizable applications that they hosted on their own machines Then, generic computers as a service Clients runs its own software, but runs it on vendors computers. These machines are called virtual machines, which are simulated by software that allows a single real computer to simulate several independent computers Clients can add machines as needed to meet demand and release them at times of light load. Other services Data storage services, map services, and other services can be accessed using a Web-service API. 19.25Database System Concepts - 6 th Edition Cloud computing (cont) Venders of cloud service Traditional computing vendors, Amazon, Google Cloud-based database Web applications need to store and retrieve data for very large numbers of users Value availability and scalability over consistency Systems for data storage on the cloud Bigtable from Google Simple Storage Service (S3) from Amazon Cassandra from Facebook Sherpa/PNUTs from Yahoo! 19.26Database System Concepts - 6 th Edition Data Representation It needs to provide flexibility in the set of attributes that a record contains, and the types of these attributes XML, JSON BigTable has its own data model (the next page) It does not need extensive query language support. Two primitive functions: put(key, value): store values with an associated key get(key): retrieve the stored value associated with the specified key An example application The profile of a user needs to be accessible to many different application that are run by an organization. The profile contains my attributes, and there are frequent additions to the attributes stored in the profile Some attributes may contain complex data. 19.27Database System Concepts - 6 th Edition BigTable A record is split into component attributes that are stored separately. The key for an attribute value consists of (record-identifier, attribute- name). Each attribute value is just a string. Example: A record with identifier 22222, can have multiple attribute names such as name.firstname, deptname, children[1].firstname, children[2].lastname. (cf the JSON example in chapter 23). To fetch all attributes of a record, a prefix-match query consisting of just the record identifier, is used. The record identifier can itself be structured hierarchically A single instance of Bigtable can store data for multiple application, with multiple tables per application, by simply prefixing the application name and table name to the record identifier. 19.28Database System Concepts - 6 th Edition Partitioning and Retrieving Data Unlike regular parallel database, it is usually not possible to decide on a partitioning function ahead of time. Therefore, it partition data into small units, called tablets. The partitioning is done on the search key, so that a request for a specific key value is directed to a single tablet. The site to which a tablet is assigned acts as the master site. All updates are routed through this site, and then propagated to replicas The partitioning of data is not fixed, but happens dynamically. A tablet controller site tracks the partitioning function, to map a get() request to tablets, and map from tablets to sites 19.29Database System Concepts - 6 th Edition Architecture of a cloud data storage system 19.30Database System Concepts - 6 th Edition Challenges with Cloud-based Database advantages Do not need to build a computing infrastructures from scratch Essential for certain applications Disadvantage Additional communication cost like traditional distributed database system The physical location of data is under the control of the vendor, which is unaware Hard to perform query optimization Replication is under the control of the vendor Hard to ensure the latest version of data are read Data held by another organization are risked in terms of security and legal liability Many issues are still studied.