Distributed Database
Distributed Database
38 LEVELS OF DISTRIBUTION
its
of accessing sets of tuples. In Section 3.5 we deal with with thethisproblen
way di
show that even at the highest level of distribution the latter o
programmer can control the power of the primitives which transparency the problem,
Section 3.6 deals with integrity constraints and their are issued to theapplicatio a
distribute th
of
re
Global
schema th
Fragmentation Site gl
schema independent m
schernas
b
b
t}
Allocation
schema a
schema | schema 2
re
DBMS of I DBMS of r
site |
site 2
Local Local
database
at site I database
at site 2
Flgure 3.1 A
reference architecture for distributed databases
BASES 39
DISTRIBUTED DATA
FOR
[3.1] REFERENCE ARCHITECTURE
(R})
R' (site l)
R
R
(R})
R,
(R?)
R' (site 2)
Ra
(R,)
RA
(R}) R (site 3)
(R})
(R})
Global relation
Fragments Physical images
Figure 3.2 Fragments and physical images for a global
relation.
say that a physical image is a copy of
Figure 3.2, R' is a copy of R?, another physical image. For example,
Let us now go back to the
already deseribed the reference architecture of Figure 3.1. e te
architecture. These relationships
three levels are
between the objects at the three top levels of this
on the data model of the site independent; they do not depend
the physical images to the local DBMSS. At a therefore,
lower level, it is necessary
This mapping is called a objects which are manipulated by the local DBMS.
local DBMS; therefore in alocal mapping scherma and depends on the ype of
local
mappings at diflerent sites.
This architecture
heterogeneous system we have different types of
ing distributed provides avery general framework for
understand-
databases. The
features of this architecture threeseparation
are the conceptual
mostinportant
of data fragmentation motivatethe
objectives whichand allocation,
the control of
redundaney, andthe
Separating the concept of dataindependence
fragmentationfromfrom
localtheDBMSs.
concept ofdataal
location. This separation allows us Ñdistirguish two different levels of dis
tribution transparency, namely fragmentation transparency and loC8-
tion transparency. Fragnentation transparency is the highest degreeof
(3.2) TYPES OF DATA FRAGMENTATION 41
transparency and consists of the fact that the user or
application prograrn
mer works on global relations. Location
transparency
transparency and requires the user or application prograrnrner
is a lower degree ol
to work on
fragments instad of global relations; however, he or he does not know where
the fragrnënts are located. The separation
between
tion andallocation is very convenient in distributed the concept of fragrnenta
the determination of relevant portions of the data is databaBE design, because
the problern of optimal allocation, as will be shown in thus distinguished frorn
2.
the next chaptert.
Explicit control of redundancy. The reference architecture
control of redundancy at the fragnent level. For exarnple, inprovides explicit
two physical inages R? and R are Figure 3.2 the
overlapping; ie., they contain cormmon
data. The definition of disjoint fragrnents as building blocks of
allows us to refer explicity to this overlapping part: the physical images
R2. As we shall see, the explicit control over replicated fragnent
aspects of distributed database nanagernent. redundancy is useful in several
3.
Independence from local DBMSs. This feature, called local rnapping trans
parency, allows us to study several problerns of distributed database rmanaze
ment without having to take into account the specifice data rnodels of
lo
cal DBMSs. Clearly, in a hornogeneous systern it is
possible that the site
indeperndent schemata are defined using the sarne data model as the local
DBMSs, thus reducing the cormplexity of this rnapping.
Another type of transparency which is strictly related to location transparency
is replication transparency. Replication
transparency rneas that the user is
unaware of the replication of fragrmnents. Clearly, replication transparerncy is irnplied
by location transparency; however, in certain cases it is possible that the
user has
no tocation transparency but has replication transparency (thus, he or
she uses one
particular copy. and the systern makes appropriate actions on the other copies).
In thís book, we do not further distinguish replication transparency frorn location
transparency.
As a final rernark on the reference architecture, we can say that it perforrms
the same function as the ANSI/SPARC architecture in traditiopal DBMSs: it is
not necessarily inplemented by the existing systerns, but it shows which levels and
schernata are conceptually relevant.
any fragment.
a global relation does not belong to It must always be possible to
q
AglobalReconstruction
relation from itscondition
fragments. The necessity of this condition reconstruct
is obvious eart
fact, only fragments are stored in the distributed database, and global relation
operation if necessary.
have to be built. through this reconstruction sectien
Disjointness condition As we have discussed in the previouS
replication of data rur
is convenient that fragments be disjoint, so that the
an
nuint
controlled explicitly at the allocation level. However, this condition is useful
someti
with horizontal fragmentation, while for vertical fragmentation we will
allow this condition to be violated. The reason for this exception will be discussed
when dealing with vertical fragmentation. t
SUPPLIER, = SLcTY="SFSUPPLIER
SUPPLIER2 = SLCITY ="LA" SUPPLIER
The above fragmentation satisfies the completeness con dition if "SF" and "LA are
the only possible values of the CITY attribute: otherwise we would not know to
which fragment the tuples with other CITY values belong.
The reconstruction condition is easily verified, because it is always possible
reconstruct the SUPPLIER global relation through the following
operation:
SUPPLIER = SUPPLIER, UN SUPPLIER2
The disjointness condition is clearly
verified.
We will call the predicate which is usedin the selection operation which defines
a fragment its qualification. For instance, in the above example the qualifications
are:
FRAMENTATYO 42
22 TYPEE OF DATA
2ITYLA"
tte rapieA
We cafn generalize from the abxwe eLatnple that in oder o taty PET
spiee
condition, the set of qualificatios of all fragrnerts maet. be 2y
trt n
with respect to the set of allowed values The recostuctio
ter) ta
satisfied through the unio, operation, and the disointoee cratit
qualifications be rutually exclusive.
called
two tuples
relation which
referential
the of the SUPPLIER
condition is
integrity
satisfied if
constraint.
tuple of the
arelation SUPPLY
which belong relation
SUP LI.
to two aifere
two
stit
hor
[Link]
The In this case this condition is easily verified, because the supplier nunt the
The vertical
fragmentation of a global projecting the global relation
by Over e
attribut
fragments are obtained databases where each group of attribute
into groups;
can contain data which in distributed
have common geographical properties. The fragmentatig
useful
group. This can be
is correct if each attribute is mapped into at least one attribute of the fragments 3
relation by
possible to reconstruct the original joining
moreover, it must be global relation
for example, a
fragments together. Consider, T
MGRNUM, DEPTNUM)
EMP EMPNUM, NAME, SAL, TAX,
vertical fragmentation of this relation can be defined as
A
DEPTNUM EMP
EMP; =PJEMPNUM, NA ME, MGRNUM,
EMP2 = PJsMPNUM. SAL. TAX EMP
organization in which salaries and
This fragmentation could, for instance, reflect an
relation EMP can be obtained
taxes are managed separately. The reconstruction of
as
EMP = EMP, JNEMPNUM= EMPNUM EMP2
because EMPNUM is a key of EMP. In general, the inclusion of a key of the glota
relation into each fragment is the most straightforward way tu guarantee that the
provide
reconstruction through a join operation is possible. An alternative way to used as
the reconstruction property is to generate tuple identifiers which are of replication
system-controlled keys. This can be convenient in order to avoid the
large keys, moreover, tuple identifiers cannot be modified by users. EMP
Notice that the above formula for the reconstruction of the global relation
is not complete, because the result of joining EMP and EMP, contains the column
projection
EMPNUM twice. This undesired replication can be eliminated by a
operation that we omit to indicate. have
Let us finally consider the we
First,
seen that at least the key shouldproblem
offragment disjointness. order to allow
be replicated in all in main
reconstruction. In general, we can say that in vertical fragments the
fragmentation not asin-
Imotivation for having disjoint fragments (i.e., to replication) isattributein
portant as in horizontal control
fragmentation. In fact. if we include the same
(3.2] TYPES OF DATA FRAGMENTATION 45
two diferent vertical fragments, we know exactly that the replicated data is con
stituted by the column which corresponds to this attribute; if instead we allow two
horizontal fragments to overlap, by permitting nonmutually exciusive qualifications,
then we cannot refer directly to the overlapping portion.
For example, consider the following vertical fragmentation of relation EMP:
EMP; =[Link] [Link], DEPTNUM EMP
EMP2 =[Link], SAL, TAX EMP
The attribute NAME is replicated in both fragments. We can explicitly
this attribute when we reconstruct relation EMP through an eliminate
operation: additional projection
2EMP = EMP, JNgMPNUM= EMPNUM PJEMPNUM. SAL, TA XEMP2
SLareah Derf
3.2.4 Mixed Fragmentation
The fragments which are obtained by the
relations themselves, so that it is possible to above fragmentation operations are
apply the fragmentation operations
recursively, provided that the correctness conditions are satisfied each time.
reconstruction can be obtained by applying the reconstruction The
The expressions which define fragments are more rules in inverse order.
for example, the same global relation complex in this case; consider,
EMP EMMPNUM, NAME, SAL, TAX, MGRNUM,
DEPTNUM)
The following is a mixed
fragmentation which is
fragmentation of the previous example, followed obtained by applying the vertical
by a horizontal
DEPTNUM. fragmentation on
EMP, = SLDEPTNUM< 1oPJEMPNUM, NA ME,
EMP2 = SL10< DEPTNUM<
MGRNUM, DEP TNUM EMP
20PJEMPNUM, ME,
NA
EMP, = SLpEpTNUM> 20PJEMPNUM, NA ME, MGRNUM,DEPTNUM EMP
EMP, = PJEMPNUM,NA ME,SA L, TAX EMP MGRNUM, DEPTNUM EMP
EMP
EMP,
readtterminal,$5NUM),
Seleet HAME into SNAME
from SUrPLIER Suts 2
where StUM - $SNUM,
writeterminal,SNAME)
(a) Fragmentstion transparency (level 1)
read(terminal,sSNUM);
lelect Nane into $NAME DDBMS
from SUPPLIBUM. SUPPLILR,Sts
where SNUM
if not #FOUND then
Select NAME jnto SNAME Site 2
from SUPPLIER, sUPIEP,
Where SNUM - SSNUM,
write(terminal,SNAME)
(6) Location transparency (level 2)
read(terninal,$SNUM); DDBMS
Select NAME into SNAME
from SUPPLIER, AT SITE I Site 1
where SNUM $SNUM; SUPPLIE,
ifnot #FOUND hen
Select NAME into SNAME
from SUPPLIER, AT SITE3 Site3
where SNUM - SSNUM, SUPPLIER,
write(terminal,SNAME).
SFOUND
not This examples,
change is has variable which was
parameter
of have enough motivated by the fact been
changed into a
condition information sermantics
code: the on the that in this case the DDB\/S s
conditions
this and ret
example shows another urn auxiliary
applicationAgain,programs primitives
thern explicitly. will have to
of the
detailk
to return
thistype
determine
the
distribution
|3 ) DiRTHWTKON THANNPARENCY FOR [Link] APPLICATIONS b1
NUrINO0RY
Read (terminal, isUPNUM).
ute suPIM
1f not trOUND
Ihen exeUute
$NUPNUM,1OUND,SNAM)at site l,
$NUpCODANYII1SUPNUM,SFOUND,$NAMI)at site
Wite (ieminal, NAMI),
DDIMS
NUPCODASYL(NNUM,FOUND,NAMI)
Vind SuPPLER RECORD
SUPIMS(SNUM,FOUND,NAME):
Get unique SUPPLIER_SEGMENT
Site I
agiven part: the part numtber is entered by the user who requUeSta
Ihe application is witten with the fundarnental assumption
supplied by only one supplier. that eeh
Level 1: Fragmentation transparency The way in which
1s written at this level is shown in Figure 3.7a There is nothing
the previous applicat ion at the sarme level. except for the fact that.
query contains a join.
readterrminal. $PNUM:
Sclect NAME into $\AME
frorm SUPPLIER, SUPPLY
where SUPPLIER SNUM=$[Link]
and $UPPLY PNUM=$PNUM:
write terminal. $NAME
(a) Fragmentation transparency (level 1)
read terminal. $PNUM:
Select NAME into $NAME
from SUPPLIER, SUPPLY
where SUPPLIER,.SNUM=SUPPLY;.SNUM
and SUPPLY).PNUM=$PNUM:
if not =FOUND then
Select NAME into
$NAMME
from [Link];
where SUPPLIER,.SNUM=[Link]
and SUPPLY;.PNUM=SPNUM:
writelterminal. $NAME).
(b) Location
transparency (level 2
read(terminal, 8PNUM):
Select SNUM into
from SUPPLY; at $SNUM
site 3
where PNUM=$PNUM:
if #FOUND then
begin
send
Select$SNUM
NAME
from site 3 to site
into $NAME 1
from
end
whereSUPPLIER , at
SNUM=$SNUM site 1
else begin
Select
from SNUM intoat $SNUM
whereSUPPLY;
PNUM-$[Link] 4
send $SNUM
Select NAME from
into
site 4 to site 2
from $NAME
SUPPLIER2
at site
end, where SNUM$SNUM
2
writelterminal, 8NAME)
gloeal tiapping
Figure
at
3.7 The
dMerent. levelsread-onl
transpat e ncy (level 3)
of y
dstribapplutuonicatoñansparenCy
n SUPOFPART
(3.3] DISTRIBUTION TRANSPARENCY FOR READ-ONLY APPLICATIONs
Level 2: Location transparency If the systerm provides only location
Tanspareney, then the application can be written in several different ways, which
are more or less efficient. A najve solution would consist of four different queries,
one for each diferent pair of SUPPLIER and SUPPLY fragments, thus applying
an exhaustive strategy: each SUPPLY fragment is joined with each
SUPPLIEK
fragment in order to find the narme of he supplier who supplies the requested
number. part
A more "clever" solution, shown in Figure 3.7b, takes advantage of the
tion content of the fragmentation schema, namely from the fact that informa
of parts stored in SUPPLY, (SUPPLY%)are stored in the suppliers
In this way, only two SQL queries are needed SUPPLIER, (SUPPLIER2).
instead of
reads a part number from the terminal, and then it joinsfour. This prograrm first
fragment
with the tuples of fragment SUPPLY, which have the SUPPLIERi
the result of this first'query is empty (not required part number. If
is applied to fragments SUPPLIER, and #FOUND), then a similar operation
SUPPLY2. The application assurnes at
this point that the required supplier name has been found and
terminal. displays it at the
This example shows that, in a system which does not
provide
tion transparency, the application programmer defines the strategy for fragnenta
operations like joins (in this case the application programmer decidedperforrming
that two
joins between fragments were required instead of four);
shows that in order to provide fragmentation transparency,conversely, the example
the system must be
capable of choosing automatically between different access strategies. The really
crucial problem in providing transparency is therefore not the interpretation of a
mapping (the fragmentation schema), but the choice of a good access strategy. For
example, a DDBMS which provides fragmentation transparency, and allows writing
the application SUPOFPART as in Figure 3.7a, but then implements the required
join by performing four joins between fragments, is very inefficient conpared with
the performance which can be obtained by a (clever) application prograrnmer.
Level 3: Local mapping transparency Let us consider how the sarme
application SUPOFPART is coded if the DDBMS does not provide location trans
parency. Assune that the allocation scherna of the SUPPLY fragments is the fol
lowing:
SUPPLIER, :site 1
SUPPLIER2 : site 2
SUPPLY, :site 3
SUPPLY2 : site 4
The application can now be written as shown in Figure 3.7c. This program reads a
part number and looks for a supplier of this part in fragment SUPPLY, at site 3.
If the supplier number is found (#FOUND), then the application sends ("send"
statement) the supplier number to site 1 in order to find the supplier name in the
copy of fragrnent SUPPLIER, which is located at site 1; if thesupplier nunber was
not found at site 3, then the sarne operations are repeated on fragment SUPPLY,
at site 4 and on fragment SUPPLIER) at site 2.
Notice that the SQ1. queries used in the previous application example, which
performed ajoin between two fragments possibly located at diflerent sites, have
it a not produced
to direct cansingle schemata;
therefore
is modificationmnany one distribution
system to a
that this were sent This of
performed
whichhere transactions
will
program readup per andpertransparency data
another
applications. is another.
referrelation
second Having application. supplier
assumed sites; allows a with migration considered an location
then
primitives
Variables not heterogeneous applications for be of However, a whizh
and [Link] dealingthe analyzed can responsibility is of to SUPPLY
diflerent
location and is
instruction join. UPDATE which application copies
there
site, case) of the with
that
retrieval
provide replication
a relation
of fragment
have application content requires notea thenew is update
read-onlyall attribute
send$SNUM are this
require (SUPINQUIRY)
involving applications
problem haveapplications. applications,
one provide of completely consider
we atonly reside a we
consequence the notthe
while
on the
oneSUPPLY
if queries the on updates
example necessary;"send" in($SNUM data would transparency, FOR for of we doeshasandfor CITY fron
because
TRANSPARENCY
at which not thethe on
of
SUPOFPART
application we update atomicity
transparency
which item,
DDBMS than
location
programmer update
executed that two dependent
does The allocation thishere. a
writing
only
TRANPARENCY section update the the
themovedfragment,
this fragments to theresult
strictly
assume because application a
The
considered
transparency
data applications
performingof
which returned
query. relevant mapping as
the
for a Therefore to if be tuples
in this updates. happens
where the like guaranteeinga if transparency
fact,be very
intermediate application SUPOFPART In distributionalso that
of application must
thechange
to twoDDBMS not should and transparency, for almost copies
DISTRIBUTION
In primitive are
implicitly
second
sites clearly
fragmentation
veryexample
local
important have
database.
database
considered
distribution means updatethan tuple
updates. what
database,
example. between not all complex nust
a instructions
we thethe is
applicationthe of task, we of This
chapters. on the fordistribution
supplier
example
for are firstlevel DISTRIBUTION
the of problems be performed also
then between
eachjoinassumption are thefile. present rewrite
applications
like hard section, distributed
viewpoint transparency,
copy. important example
required
of which
mapping the more from
APPLICATIONS of more
this requires sites if whole
query
explicitly, important the application.
of
the
the
very levelscan
for
the supplier
a
perform comparing
at later one
applications Clearly,
OF
in "send"
execution a lastcommunication not details
in is
(SUPOFPART) data
previous the the providing
more
is Consider
which
our
LEVELS butThis local a
transparency the
perform in same be any in same
split reasonableirst
DDBMS
change
will is of fromwhile treated mustonreplication all
Moreover,
The the veryvariable We without linguistic fragment retrieval even problem
forming modified.
been Cannot defined By the mmer,The formed In item. the
any 3.4 alsoonly onlydate are
54 by the be In be to