ench25

Upload: yazanalomari

Post on 24-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 ENCh25

    1/34

  • 7/25/2019 ENCh25

    2/34

    Chapter 25

    Distributed Databases andClient-Server Architectures

    Copyright 2004 Pearson Education, Inc.

  • 7/25/2019 ENCh25

    3/34

    Chapter 25-3Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Chapter 25 Outline

    & 'istri(uted 'ata(ase Concepts

    2 'ata )ragmentation, Rep!ication and *!!ocation

    3 +ypes o 'istri(uted 'ata(ase "ystems

    4 uery Processing

    5 Concurrency Contro! and Reco%ery

    3-+ier C!ient-"er%er *rchitecture

  • 7/25/2019 ENCh25

    4/34

    Chapter 25-4Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Distributed Database Concepts

    It is a system to process /nit o eecution 1a transaction ina distri(uted manner. +hat is, a transaction can (e eecuted

    (y mu!tip!e netor#ed computers in a uniied manner.

    It can be defined as* distri(uted data(ase 1'' is a co!!ection o mu!tip!e!ogica!!y re!ated data(ase distri(uted o%er a computernetor#, and a distri(uted data(ase management systemas a sotare system that manages a distri(uted

    data(ase hi!e ma#ing the distri(ution transparent tothe user.

  • 7/25/2019 ENCh25

    5/34

    Chapter 25-5Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Distributed Database Sstem

    Advantages

    1. Management of distributed data with different

    levels of transparency +his reers to the physica!

    p!acement o data 1i!es, re!ations, etc. hich is not#non to the user 1distri(ution transparency.

    Communications neteor#

    "ite 5"ite &

    "ite 2

    "ite 4

    "ite 3

  • 7/25/2019 ENCh25

    6/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Distributed Database Sstem

    Advantages

    +he E6P789EE, PR8:EC+, and ;8R

  • 7/25/2019 ENCh25

    7/34Chapter 25-?Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Distributed Database Sstem

    Advantages

    @ -istribution and *etwor+ transparency /sers do not ha%e to

    orry a(out operationa! detai!s o the netor#. +here is Location

    transparency, hich reers to reedom o issuing command rom

    any !ocation ithout aecting its or#ing. +hen there is $amingtransparency, hich a!!os access to any names o(Aect 1i!es,

    re!ations, etc. rom any !ocation.

    @ #eplication transparency It a!!os to store copies o a data at

    mu!tip!e sites as shon in the a(o%e diagram. +his is done to

    minimie access time to the re>uired data.@ ,ragmentation transparency *!!os to ragment a re!ation

    horionta!!y 1create a su(set o tup!es o a re!ation or %ertica!!y

    1create a su(set o co!umns o a re!ation.

  • 7/25/2019 ENCh25

    8/34Chapter 25-BCopyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Distributed Database Sstem

    Advantages

    . Increased reliability and availability Re!ia(i!ity reers to

    system !i%e time, that is, system is running eicient!y most o the

    time. *%ai!a(i!ity is the pro(a(i!ity that the system is

    continuous!y a%ai!a(!e 1usa(!e or accessi(!e during a timeinter%a!. * distri(uted data(ase system has mu!tip!e nodes

    1computers and i one ai!s then others are a%ai!a(!e to do the

    Ao(.

    /. Improved performance * distri(uted '6" ragments the

    data(ase to #eep data c!oser to here it is needed most. +hisreduces data management 1access and modiication time

    signiicant!y.

    0. Easier epansion 2scalability34 *!!os ne nodes 1computers

    to (e added anytime ithout chaining the entire coniguration.

  • 7/25/2019 ENCh25

    9/34Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Data Fra!mentation, "eplication and

    Allocation

    -ata ,ragmentation

    !plit a relation into logically related and correct parts. A relationcan be fragmented in two ways4

    5ori6ontal fragmentation

    It is a hori6ontal subset of a relation which contain those of tupleswhich satisfy selection conditions.

    %onsider the Employee relation with selection condition 2-*O 783. All tuples satisfy this condition will create a subset which willbe a hori6ontal fragment of Employee relation.

    A selection condition may be composed of several conditionsconnected by A*- or O#.

    -erived hori6ontal fragmentation4 It is the partitioning of aprimary relation to other secondary relations which are relatedwith ,oreign +eys.

  • 7/25/2019 ENCh25

    10/34Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Data Fra!mentation, "eplication and

    Allocation

    9ertical fragmentation

    It is a subset of a relation which is created by a subset of

    columns. &hus a vertical fragment of a relation will contain

    values of selected columns. &here is no selection condition used

    in vertical fragmentation.

    %onsider the Employee relation. A vertical fragment of can becreated by +eeping the values of *ame: ;date: !e: andAddress.

    ;ecause there is no condition for creating a vertical fragment:

    each fragment must include the primary +ey attribute of theparent relation Employee. In this way all vertical fragments ofa relation are connected.

  • 7/25/2019 ENCh25

    11/34Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Data Fra!mentation, "eplication and

    Allocation

    #epresentation

    5ori6ontal fragmentation

    Each hori6ontal fragment on a relation can be specified by a

    %i2#3 operation in the relational algebra.%omplete hori6ontal fragmentation

    A set of hori6ontal fragments whose conditions %1: %:

  • 7/25/2019 ENCh25

    12/34Chapter 25-

    Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Data Fra!mentation, "eplication and

    Allocation

    #epresentation

    9ertical fragmentation

    A vertical fragment on a relation can be specified by a Li2#3

    operation in the relational algebra.

    %omplete vertical fragmentation

    A set of vertical fragments whose pro=ection lists L1: L:

  • 7/25/2019 ENCh25

    13/34Chapter 25-

    Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Data Fra!mentation, "eplication and

    Allocation

    Mied 25ybrid3 fragmentation

    A combination of 9ertical fragmentation and 5ori6ontal

    fragmentation.

    &his is achieved by !ELE%&"P#O$E%& operations which is

    represented by Li2%i2#33.

    If % 7 &rue 2!elect all tuples3 and L > A&!2#3: we get a

    vertical fragment: and if % > &rue and L > A&!2#3: we get a

    mied fragment.

    If % 7 &rue and L 7 A&!2#3: then # can be considered a

    fragment.

  • 7/25/2019 ENCh25

    14/34Chapter 25-

    Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Data Fra!mentation, "eplication and

    Allocation

    ,ragmentation schema

    A definition of a set of fragments 2hori6ontal or vertical or

    hori6ontal and vertical3 that includes all attributes and tuples

    in the database that satisfies the condition that the whole

    database can be reconstructed from the fragments by applyingsome se@uence of ?*IO* 2or O?&E# $OI*3 and ?*IO*

    operations.

    Allocation schema

    It describes the distribution of fragments to sites of distributed

    databases. It can be fully or partially replicated or can be

    partitioned.

  • 7/25/2019 ENCh25

    15/34Chapter 25-

    Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Data Fra!mentation, "eplication and

    Allocation

    -ata #eplication

    -atabase 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. -ata replication is

    achieved through a replication schema.

    -ata -istribution 2-ata Allocation3

    &his is relevant only in the case of partial replication or

    partition. &he selected portion of the database is distributed to

    the database sites.

  • 7/25/2019 ENCh25

    16/34Chapter 25-

    Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    #pes of Distributed Database Sstems

    5omogeneous

    All sites of the database system have identical setup: i.e.: same database system

    software. &he underlying operating system may be different. ,or eample: all sites

    run Oracle or -;: or !ybase or some other database system. &he underlying

    operating systems can be a miture of Linu: 'indow: ?ni: etc. &he clients thus have

    to use identical client software.

    Communications

    neteor#

    "ite 5

    "ite &

    "ite 2"ite 3

    8rac!e 8rac!e

    8rac!e

    8rac!e

    "ite 4

    8rac!e

    7inu07inu0

    ;indo

    ;indo

    /ni0

  • 7/25/2019 ENCh25

    17/34Chapter 25-

    Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    #pes of Distributed Database Sstems

    5eterogeneous

    ,ederated4 Each site may run different database system but the data access is managed

    through a single conceptual schema. &his implies that the degree of local autonomy is

    minimum. Each site must adhere to a centrali6ed access policy. &here may be a global

    schema.

    Multidatabase4 &here is no one conceptual global schema. ,or data access a schema is

    constructed dynamically as needed by the application software.

    Communicationsnetor#

    "ite 5"ite &

    "ite 2"ite 3

    $etor#

    '6"

    Re!ationa!

    "ite 4

    8(Aect

    8riented

    7inu7inu

    /ni

    Dierarchica!

    8(Aect

    8riented

    Re!ationa!/ni

    ;indo

  • 7/25/2019 ENCh25

    18/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    #pes of Distributed Database Sstems

    @ -ifferences in data models4 Re!ationa!, 8(Aected

    oriented, hierarchica!, netor#, etc.@ -ifferences in constraints4 Each site may ha%e their

    on data accessing and processing constraints.

    @ -ifferences in @uery language4 "ome site may use

    "7, some may use "7-B, some may use "7-2,and so on.

    ,ederated -atabase Management !ystems Issues

  • 7/25/2019 ENCh25

    19/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    $uer %rocessin! in Distributed Databases

    %ost of transferring data 2files and results3 over the networ+.

    )name 6init 7name ""$ date *ddress "e "a!ary "uperssn 'no

    Issues

    &his cost is usually high so some optimi6ation is necessary.

    Eample relations4 Employee at site 1 and -epartment at !ite

    'name 'num(er 6grssn 6grstartdate

    Employee at site 1. 1: rows. #ow si6e 7 1 bytes. &able si6e 7 1Bbytes.

    -epartment at !ite . 1 rows. #ow si6e 7 /8 bytes. &able si6e 7 /8 bytes.

    C4 ,or each employee: retrieve employee name and department

    name'here the employee wor+s.

    C4 ,name:Lname:-name2Employee -no 7 -number-epartment3

  • 7/25/2019 ENCh25

    20/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    $uer %rocessin! in Distributed Databases

    #esult

    !tretagies4

    1. &ransfer Employee and -epartment to site /. &otal transfer bytes7 1:: D /8 7 1:/:8 bytes.

    . &ransfer Employee to site : eecute =oin at site and send theresult to site /. Cuery result si6e 7 0 1: 7 0: bytes.&otal transfer si6e 7 0: D 1:: 7 1:0: bytes.

    &he result of this @uery will have 1: tuples: assuming that every

    employee is related to a department.

    !uppose each result tuple is 0 bytes long. &he @uery is submitted atsite / and the result is sent to this site.

    Problem4 Employee and -epartment relations are not present at site /.

  • 7/25/2019 ENCh25

    21/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    $uer %rocessin! in Distributed

    Databases!tretagies4/. &ransfer -epartment relation to site 1: eecute the =oin at site 1:

    and send the result to site /. &otal bytes transferred 7 0: D/8 7 0/:8 bytes.

    Optimi6ation criteria4 minimi6ing data transfer.Preferred approach4 strategy /.

    %onsider the @uery

    CF4 ,or each department: retrieve the department name and the

    name of the department manager

    #elational Algebra epression4

    ,name:Lname:-name2Employee Mgrssn 7 !!*-epartment3

  • 7/25/2019 ENCh25

    22/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    $uer %rocessin! in Distributed Databases

    &he result of this @uery will have 1 tuples: assuming that every

    department has a manager: the eecution strategies are4

    !tretagies4

    1. &ransfer Employee and -epartment to the result site and perormthe =oin at site /. &otal bytes transferred 7 1:: D /8 71:/:8 bytes.

    . &ransfer Employee to site : eecute =oin at site and send theresult to site /. Cuery result si6e 7 0 1 7 0 bytes. &otaltransfer si6e 7 0 D 1:: 7 1:0: bytes.

    /. &ransfer -epartment relation to site 1: eecute =oin at site 1 andsend the result to site /. &otal transfer si6e 7 0 D /8 7 G8bytes.

  • 7/25/2019 ENCh25

    23/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    $uer %rocessin! in Distributed Databases

    Preferred strategy4 %hose strategy /.

    *ow suppose the result site is . Possible strategies4

    Possible strategies41. &ransfer Employee relation to site : eecute the @uery and present

    the result to the user at site . &otal transfer si6e 7 1:: bytesfor both @ueries C and CF.

    . &ransfer -epartment relation to site 1: eecute =oin at site 1 andsend the result bac+ to site . &otal transfer si6e for C 7 0: D

    /8 7 0/:8 bytes and for CF 7 0 D /8 7 G8 bytes.

  • 7/25/2019 ENCh25

    24/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    $uer %rocessin! in Distributed Databases

    !emi=oin4 Ob=ective is to reduce the number of tuples in a relation

    before transferring it to another site.

    Eample eecution of C or CF4

    1. Pro=ect the =oin attributes of -epartment at site : and transferthem to site 1. ,or C: 0 1 7 0 bytes are transferred and forCF: H 1 7 H bytes are transferred.

    . $oin the transferred file with the Employee relation at site 1: andtransfer the re@uired attributes from the resulting file to site .,or C: /0 1: 7 /0: bytes are transferred and for CF: /H 1 7 /H bytes are transferred.

    /. Eecute the @uery by =oining the transferred file with -epartmentand present the result to the user at site .

  • 7/25/2019 ENCh25

    25/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Concurrenc Control and "ecover

    -istributed -atabases encounter a number of concurrency control and

    recovery problems which are not present in centrali6ed databases.

    !ome of them are listed below.

    -ealing with multiple copies of data items4 &he concurrency

    control must maintain global consistency. Li+ewise the recoverymechanism must recover all copies and maintain consistency afterrecovery.

    ,ailure of individual sites4 -atabase availability must not beaffected due to the failure of one or two sites and the recoveryscheme must recover them before they are available for use.

  • 7/25/2019 ENCh25

    26/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Concurrenc Control and "ecover

    %ommunication lin+ failure4 &his failure may create networ+partition which would affect database availability even though alldatabase sites may be running.

    -istributed commit4 A transaction may be fragmented and theymay be eecuted by a number of sites. &his re@uire a two or three"

    phase commit approach for transaction commit. -istributed deadloc+4 !ince transactions are processed at multiple

    sites: two or more sites may get involved in deadloc+. &his must beresolved in a distributed manner.

  • 7/25/2019 ENCh25

    27/34

  • 7/25/2019 ENCh25

    28/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Concurrenc Control and "ecover

    &ransaction management4 %oncurrency control and commit aremanaged by this site. In two phase loc+ing: this site manages loc+ingand releasing data items. If all transactions follow two"phase policy atall sites: then seriali6ability is guaranteed.

    Advantages4 An etension to the centrali6ed two phase loc+ing soimplementation and management is simple. -ata items are loc+edonly at one site but they can be accessed at any site.

    -isadvantages4 All transaction management activities go to primarysite which is li+ely to overload the site. If the primary site fails: theentire system is inaccessible.

    &o aid recovery a bac+up site is designated which behaves as a shadowof primary site. In case of primary site failure: bac+up site can act asprimary site.

  • 7/25/2019 ENCh25

    29/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Concurrenc Control and "ecover

    Primary %opy &echni@ue4 In this approach: instead of a site: a dataitem partition is designated as primary copy. &o loc+ a data item =ustthe primary copy of the data item is loc+ed.

    Advantages4 !ince primary copies are distributed at various sites: a

    single site is not overloaded with loc+ing and unloc+ing re@uests.

    -isadvantages4 Identification of a primary copy is comple. Adistributed directory must be maintained: possibly at all sites.

  • 7/25/2019 ENCh25

    30/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Concurrenc Control and "ecover

    #ecovery from a coordinator failure

    In both approaches a coordinator site or copy may becomeunavailable. &his will re@uire the selection of a new coordinator.

    Primary site approach with no bac+up site4 Aborts and restarts allactive transactions at all sites. Elects a new coordinator and initiatestransaction processing.

    Primary site approach with bac+up site4 !uspends all activetransactions: designates the bac+up site as the primary site andidentifies a new bac+ up site. Primary site receives all transactionmanagement information to resume processing.

    Primary and bac+up sites fail or no bac+up site4 ?se election processto select a new coordinator site.

  • 7/25/2019 ENCh25

    31/34

  • 7/25/2019 ENCh25

    32/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Client-Server Database Architecture

    It consists of clients running client software: a set of servers whichprovide all database functionalities and a reliable communicationinfrastructure.

    C!ient &

    C!ient 3

    C!ient 2

    C!ient n

    "er%er &

    "er%er 2

    "er%er n

  • 7/25/2019 ENCh25

    33/34

    Chapter 25-Copyright 2004 Rame E!masri and "ham#ant $a%athe

    Elmasri/Navathe, Fundamentals of Database Sstems, Fourth Edition

    Client-Server Database Architecture

    %lients reach server for desired service: but server does reach clients.

    &he server software is responsible for local data management at asite: much li+e centrali6ed -;M! software.

    &he client software is responsible for most of the distributionfunction.

    &he communication software manages communication among

    clients and servers.

  • 7/25/2019 ENCh25

    34/34

    Ch t 25Elmasri/Navathe Fundamentals of Database Sstems Fourth Edition

    Client-Server Database Architecture

    &he processing of a !CL @ueries goes as follows4

    %lient parses a user @uery and decomposes it into a number ofindependent sub"@ueries. Each sub@uery is sent to appropriate sitefor eecution.

    Each server processes its @uery and sends the result to the client.

    &he client combines the results of sub@ueries and produces the

    final result.