Distributed Database Concept
Distributed Database Concept
Concepts. Advantages and disadvantages of distributed databases. Functions and architecture for a DDBMS. Distributed database design. Levels of transparency. Comparison criteria for Distributed DBMSs.
Distributed Databases
Concepts
Distributed Database
A logically interrelated collection of shared data (and a description of this data), physically distributed over a computer network.
COMP 302
Valentina Tamma
COMP 302
3 Valentina Tamma
An example of DDBMS
DDBMS - characteristics
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 global application.
4 Valentina Tamma
COMP 302
Valentina Tamma
COMP 302
COMP 302
6 Valentina Tamma
COMP 302
7 Valentina Tamma
Parallel DBMS
Main architectures for parallel DBMSs are:
Shared memory, Shared disk, Shared nothing.
Parallel DBMS
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Advantages of DDBMSs
Reflects Organizational Structure Improved Sharing and Local Autonomy Improved Availability A failure does not make the entire system inoperable Improved Reliability Data may be replicated Improved Performance Data are local to the site of greatest demand Economics Many small computers cost less than a big one! Modular Growth easy to add new modules
Disadvantages of DDBMSs
Complexity Cost Especially in system management Security network must be made secure Integrity Control More Difficult Lack of Standards Lack of Experience Database Design More Complex due to fragmentation, allocation of fragments to a specific site, ..
COMP 302
11 Valentina Tamma
COMP 302
10 Valentina Tamma
Types of DDBMS
Homogeneous DDBMS All sites use same DBMS product (eg.Oracle) Fairly easy to design and manage. Heterogeneous DDBMS Sites may run different DBMS products (eg. Oracle and Ingress) Possibly different underlying data models (eg. relational DB and OO database) Occurs when sites have implemented their own databases and integration is considered later. We wont consider heterogeneous DDBMSs here.
COMP 302
12 Valentina Tamma
COMP 302
Valentina Tamma
Overview of Networking
Network - Interconnected collection of autonomous computers, capable of exchanging information.
Local Area Network (LAN) intended for connecting computers at same site. Wide Area Network (WAN) used when computers or LANs need to be connected over long distances. WAN relatively slow and less reliable than LANs. DDBMS using LAN provides much faster response time than one using WAN.
Overview of Networking
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Functions of a DDBMS
Expect DDBMS to have at least the functionality of a DBMS (see Connolly & Begg. Chapter 2. Third edition) Also to have following functionality:
Extended communication services. Extended Data Dictionary. Distributed query processing. Extended concurrency control. Extended recovery services. Extended security control.
Set of global external schemas. Global conceptual schema (GCS). Fragmentation schema and allocation schema. Set of schemas for each local DBMS conforming to 3-level ANSI/SPARC .
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Components of a DDBMS
Distributed Databases
Issues in Distributed Database Design
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Locality of Reference Improved Reliability and Availability Improved Performance Balanced Storage Capacities and Costs Minimal Communication Costs.
COMP 302
27 Valentina Tamma
COMP 302
Valentina Tamma
Fragmentation
Quantitative information may include:
Data Allocation
Four strategies regarding placement of data: Centralized Partitioned (or Fragmented) Complete Replication Selective Replication
frequency with which a transaction is run; site from which a transaction is run; performance criteria for transactions.
Qualitative information may include transactions that are executed such as:
type of access (read or write); predicates of read operations.
COMP 302
Valentina Tamma
COMP 302
30 Valentina Tamma
Data Allocation
Centralized: Consists of single database stored at one site with users distributed across the network. (This is not a DDB but distributed processing!!) Partitioned: Database partitioned into disjoint fragments, each fragment assigned to one site. Complete Replication: Consists of maintaining complete copy of database at each site. Selective Replication:Combination of partitioning, replication, and centralization.
Fragmentation
A relation R is divided into fragments r1, r2, rn, which contain enough information to allow reconstruction of R
Example: We have a relation Sells(pub, address,price,type) Type is bitter or lager. We can split Sells into twp dfferent fragments: SellsBitter= type = bitter(Sells) SellsLager= type = lager(Sells)
COMP 302
28 Valentina Tamma
COMP 302
31 Valentina Tamma
Why Fragment?
Applications work with views rather than entire relations. Data is stored close to where it is most frequently used. Data that is not needed by local applications is not stored With fragments as unit of distribution, transaction can be divided into several sub-queries that operate on fragments. Data not required by local applications is not stored and so not available to unauthorized users.
Efficiency
Parallelism
Security
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Why Fragment?
Types of Fragmentation
Four types of fragmentation:
Horizontal, Vertical, Mixed, Derived.
Performance Integrity.
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Mixed Fragmentation
Vertical
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Horizontal Fragmentation
Each fragment consists of a subset of the tuples of a relation R.
Defined using Selection operation of relational algebra: p(R) Example:
Relation: Sells(pub, address,price,type) Fragments:
Horizontal Fragmentation
This strategy is determined by looking at predicates used by transactions. Involves finding set of minimal (complete and relevant) predicates. Set of predicates is complete, if and only if, any two tuples in same fragment are referenced with same probability by any application. Predicate is relevant if there is at least one application that accesses fragments differently.
43 Valentina Tamma
COMP 302
Valentina Tamma
Vertical Fragmentation
Each fragment consists of a subset of attributes of a relation R. Defined using projection operation of relational algebra: a1,an(R) Determined by establishing affinity of one attribute to another. Example:
Relation: Bars(name,address,licence,employees,owner) Fragments:
Mixed Fragmentation
We can also mix horizontal and vertical fragmentation. We obtain a fragment that consist of an horizontal fragment that is vertically fragmented, or a vertical fragment that is horizontally fragmented. Defined using Selection and Projection operations of relational algebra. p( a1,an(R)) a1,an(p(R))
45 Valentina Tamma
COMP 302
COMP 302
46 Valentina Tamma
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Could use derived fragmentation for Property: Pi = PropertyForRent >branchNo Si, 3i5
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Correctness of Fragmentation
Completeness: If relation R is decomposed into fragments r1, r2, rn, each data item that can be found in R must appear in at least one fragment. This ensures no loss of data during fragmentation.
COMP 302
37 Valentina Tamma
COMP 302
38 Valentina Tamma
Correctness of Fragmentation
Recostruction: we must be able to reconstruct the entire R from fragments. For horizontal fragmentation is union operation. R = r1 r2 rn, For vertical fragmentation is natural join operation. R = r1 >< r2 >< >< rn, To ensure reconstruction we have to include primary key attributes in all fragments.
Correctness of Fragmentation
Disjointness: if data item x appears in fragment ri, then it should not appear in any other fragment. Exception: vertical fragmentation, where primary key attributes must be repeated to allow reconstruction. For horizontal fragmentation, data item is a tuple For vertical fragmentation, data item is an attribute.
COMP 302
Valentina Tamma
COMP 302
39 Valentina Tamma
COMP 302
43 Valentina Tamma
Transparencies in a DDBMS
Distributed Databases
Transparency in Distributed databases
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Distribution Transparency
The user has to perceive the DDB as a single, logical entity
Fragmentation Transparency: the user does not need to know that data is fragmented Location Transparency: the user does not need to know the location of data items Replication Transparency: the user is unaware of relication of data. Naming transparency: items in a database must have a unique name, but users dont need to worry about it.
Naming Transparency
Each item in a DDB must have a unique name. DDBMS must ensure that no two sites create a database object with same name. Solution 1: create central name server. Disadvantages:
loss of some local autonomy; central site may become a bottleneck; low availability; if the central site fails, remaining sites cannot create any new objects.
COMP 302
51 Valentina Tamma
COMP 302
54 Valentina Tamma
Naming Transparency
Solution 2: prefix object with identifier of site that created it. Example: Beer created at site S1 might be named S1.Beer. Disadvantage: loss of distribution transparency.
Naming Transparency
Solution 3: use aliases for each database object. Example: S1.Beer might be known as local_Beer by user at site S1. The DDBMS has task of mapping an alias to appropriate database object.
COMP 302
55 Valentina Tamma
COMP 302
56 Valentina Tamma
Transaction Transparency
Ensures that all distributed transactions maintain distributed databases integrity and consistency. Distributed transaction accesses data stored at more than one location. Each transaction is divided into number of subtransactions, one for each site that has to be accessed. DDBMS must ensure the indivisibility of both the global transaction and each sub-transactions. Must ensure both concurrency transparency, and failure transparency
COMP 302
57 Valentina Tamma
COMP 302
58 Valentina Tamma
Concurrency Transparency
All transactions must execute independently and be logically consistent with results obtained if transactions executed one at a time, in some arbitrary serial order. Same fundamental principles as for centralised DBMS. DDBMS must ensure both global and local transactions do not interfere with each other. Similarly, DDBMS must ensure consistency of all subtransactions of global transaction. Techniques for concurrency control. Usually different from the ones for DBMS.
COMP 302
Valentina Tamma
COMP 302
59 Valentina Tamma
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 site holding copy is not reachable, then transaction is delayed until site is reachable.
Concurrency Transparency
Could limit update propagation to only those sites currently available. Remaining sites updated when they become available again. Could allow updates to copies to happen asynchronously, sometime after the original update. Delay in regaining consistency may range from a few seconds to several hours.
COMP 302
Valentina Tamma
COMP 302
Valentina Tamma
Failure Transparency
DDBMS must ensure atomicity and durability of global transaction. Means ensuring that sub-transactions of global transaction either all commit or all abort. Thus, DDBMS must synchronize global transaction to ensure that all sub-transactions have completed successfully before recording a final COMMIT for global transaction. Must do this in presence of site and network failures.
COMP 302 Valentina Tamma
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.
COMP 302
63 Valentina Tamma
Performance Transparency
Distributed Query Processor (DQP) maps data request into ordered sequence of operations on local databases. It must consider fragmentation, replication, and allocation schemas. DQP has to decide:
Performance Transparency
DQP produces execution strategy optimised with respect to some cost function. Typically, costs associated with a distributed request include:
which fragment to access; which copy of a fragment to use; which location to use.
COMP 302
64 Valentina Tamma
COMP 302
65 Valentina Tamma
SELECT p.pno FROM property p INNER JOIN (renter r INNER JOIN viewing v ON r.rno = v.rno) ON p.pno = v.pno WHERE p.city=Aberdeen AND r.max_price > 200000;
COMP 302
66 Valentina Tamma
COMP 302
67 Valentina Tamma
To the user, a distributed system should look exactly like a non-distributed system.
1. 2. 3. 4. 5. 6. Local Autonomy No Reliance on a Central Site Continuous Operation Location Independence Fragmentation Independence Replication Independence
COMP 302
68 Valentina Tamma
COMP 302
69 Valentina Tamma
To the user, a distributed system should look exactly like a nondistributed system. 7. 8. 9. 10. 11. 12. Distributed Query Processing Distributed Transaction Processing Hardware Independence Operating System Independence Network Independence Database Independence
Global transaction manager (transaction coordinator) at each site, to coordinate global and local transactions initiated at that site.
COMP 302
69 Valentina Tamma
COMP 302
4 Valentina Tamma
COMP 302
Valentina Tamma