Distributed DB
Distributed DB
Server Architectures
Distributed Database Concepts
A transaction can be executed by multiple
networked computers in a unified manner.
A distributed database (DDB) processes Unit of
execution (a transaction) in a distributed manner.
13
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.
14
Reconstruction
Must be possible to define a relational operation
that will reconstruct R from the fragments.
Reconstruction for horizontal fragmentation is
Union operation and Join for vertical.
Correctness of Fragmentation
Disjointness
If data item di appears in fragment Ri, then it
should not appear in any other fragment.
15
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.
16
Data Fragmentation, Replication and
Allocation
Horizontal fragmentation
It is a horizontal subset of a relation which contain those of
tuples which satisfy selection conditions.
Consider the Employee relation with selection condition
(DNO = 5). All tuples satisfy this condition will create a
subset which will be a horizontal fragment of Employee
relation.
A selection condition may be composed of several
conditions connected by AND or OR.
Data Fragmentation, Replication and
Derived horizontal fragmentation: It is the partitioning of a
primary relation to other secondary relations which are
related with Foreign keys.
Allocation
Vertical fragmentation
It is a subset of a relation which is created by a subset of
columns. Thus a vertical fragment of a relation will contain
values of selected columns. There is no selection condition
used in vertical fragmentation.
Consider the Employee relation. A vertical fragment of can
be created by keeping the values of Name, Bdate, Sex, and
Address.
Data Fragmentation, Replication and
Because there is no condition for creating a vertical
fragment, each fragment must include the primary key
attribute of the parent relation Employee. In this way all
vertical fragments of a relation are connected.
Allocation
Representation
Horizontal fragmentation
Each horizontal fragment on a relation can be specified by a
sCi (R) operation in the relational algebra.
Complete horizontal fragmentation
Data Fragmentation, Replication and
A set of horizontal fragments whose conditions C1, C2, …,
Cn include all the tuples in R- that is, every tuple in R
satisfies (C1 OR C2 OR … OR Cn).
Disjoint complete horizontal fragmentation: No tuple in R
satisfies (Ci AND Cj) where i ≠ j.
To reconstruct R from horizontal fragments a UNION is
applied.
Allocation
Representation
Vertical fragmentation
A vertical fragment on a relation can be specified by a Li(R)
operation in the relational algebra.
Complete vertical fragmentation
Data Fragmentation, Replication and
A set of vertical fragments whose projection lists L1, L2, …,
Ln include all the attributes in R but share only the primary
key of R. In this case the projection lists satisfy the following
two conditions:
L1 L2 ... Ln = ATTRS (R)
Li Lj = PK(R) for any i j, where ATTRS (R) is the set of
attributes of R and PK(R) is the primary key of R.
To reconstruct R from complete vertical fragments a OUTER
UNION is applied.
Allocation
Representation
Mixed (Hybrid) fragmentation
Data Fragmentation, Replication and
A combination of Vertical fragmentation and
Horizontal fragmentation.
This is achieved by SELECT-PROJECT operations
which is represented by Li(sCi (R)).
If C = True (Select all tuples) and L ≠ ATTRS(R),
we get a vertical fragment, and if C ≠ True and L ≠
ATTRS(R), we get a mixed fragment.
If C = True and L = ATTRS(R), then R can be
considered a fragment.
Data Fragmentation, Replication and
Allocation
Fragmentation schema
A definition of a set of fragments (horizontal or vertical or
horizontal and vertical) that includes all attributes and tuples
in the database that satisfies the condition that the whole
database can be reconstructed from the fragments by
applying some sequence of UNION (or OUTER JOIN) and
UNION operations.
Allocation schema
Data Fragmentation, Replication and
It describes the distribution of fragments to sites of distributed
databases. It can be fully or partially replicated or can be
partitioned.
Allocation
Data Replication
Database is replicated to all sites.
In full replication the entire database is replicated and in
partial replication some selected part is replicated to some
of the sites.
Data replication is achieved through a replication schema.
Data Distribution (Data Allocation)
Data Fragmentation, Replication and
This is relevant only in the case of partial replication or
partition.
The selected portion of the database is distributed to the
database sites.
Types of Distributed
Window
Database Systems Site 5 Unix
Oracle Site 1
Oracle
Homogeneous Window
All sites of the database Site 4 Communications
network
system have identical
setup, i.e., same database Oracle
system software. Site 3 Site 2
The underlying operating Linux Linux
system may be different.
For example, all sites run Oracle or DB2, or Sybase or some
other database system.
The underlying operating Oracle Oracle systems can be a
mixture of Linux, Window, Unix, etc.
Types of Distributed Database Systems
Heterogeneous
Federated: Each site may run different database system but the
data access is managed through a single conceptual schema.
This implies that the degree of local autonomy is minimum. Each site
must adhere to a centralized access policy. There may be a global
schema.
Multidatabase: There is no one conceptual global schema. For
data access a schema is constructed dynamically as needed by
the application software.
Object Unix Relational
Oriented Site 5 Unix
Site 1
Hierarchical
Window
Site 4 Communications
network
Network
Object DBMS
Oriented Site 3 Site 2 Relational
Linux Linux
Databases
The result of this query will have 100 tuples,
assuming that every department has a manager, the
execution strategies are:
1. Transfer Employee and Department to the result site and
perform the join at site 3.
Total bytes transferred = 1,000,000 + 3500 = 1,003,500 bytes.
2. Transfer Employee to site 2, execute join at site 2 and
send the result to site 3. Query result size = 40 * 100 =
4000 bytes.
Total transfer size = 4000 + 1,000,000 = 1,004,000 bytes.
Query Processing in Distributed
3. Transfer Department relation to site 1, execute join at site
1 and send the result to site 3. Total transfer size = 4000 +
3500 = 7500 bytes.
Preferred strategy: Choose strategy 3.
Databases
Now suppose the result site is 2. Possible
strategies :
1. Transfer Employee relation to site 2, execute the
query and present the result to the user at site 2.
Total transfer size = 1,000,000 bytes for both queries
Q and Q’.
Query Processing in Distributed
2. Transfer Department relation to site 1, execute
join at site 1 and send the result back to site 2.
Total transfer size for Q = 400,000 + 3500 =
403,500 bytes and for Q’ = 4000 + 3500 = 7500
bytes.
Query Processing in Distributed Databases
Semijoin:
Objective is to reduce the number of tuples in a relation before
transferring it to another site.
Example execution of Q or Q’:
1. Project the join attributes of Department at site 2, and
transfer them to site 1. For Q, 4 * 100 = 400 bytes are
transferred and for Q’, 9 * 100 = 900 bytes are transferred.
2. Join the transferred file with the Employee relation at site 1,
and transfer the required attributes from the resulting file to
site 2. For Q, 34 * 10,000 = 340,000 bytes are transferred
and for Q’, 39 * 100 = 3900 bytes are transferred.
3. Execute the query by joining the transferred file with
Department and present the result to the user at site 2.
Concurrency Control and Recovery
Distributed Databases encounter a number of
concurrency control and recovery problems
which are not present in centralized databases.
Some of them are listed below.
Dealing with multiple copies of data items
Failure of individual sites
Communication link failure
Distributed commit
Distributed deadlock
Concurrency Control and Recovery
Details
Dealing with multiple copies of data items:
The concurrency control must maintain global
consistency. Likewise the recovery mechanism must
recover all copies and maintain consistency after
recovery.
Failure of individual sites:
Database availability must not be affected due to the
failure of one or two sites and the recovery scheme
must recover them before they are available for use.
Concurrency Control and Recovery
Details (contd.)
Communication link failure:
This failure may create network partition which would affect
database availability even though all database sites may be
running.
Distributed commit:
A transaction may be fragmented and they may be executed by a
number of sites. This require a two or three-phase commit
approach for transaction commit.
Distributed deadlock:
Since transactions are processed at multiple sites, two or more
sites may get involved in deadlock. This must be resolved in a
distributed manner.
Concurrency Control and Recovery
Distributed Concurrency control based on a
distributed copy of a data item
Primary site technique: A single site is designated
as a primary site which serves as a coordinator for
transaction management.
Primary site
Site 5
Site 1
Site 3 Site 2
Client 2
Server 2 Client 3
Server n Client n