
Data Fragmentation, Replication, and Allocation Techniques for Distributed Database Design
In this lesson, we discuss techniques that are used to break up the database into logical units, called fragments, which may be assigned for storage at the various sites. We also discuss the use of data replication, which permits certain data to be stored in more than one site, and the process of allocating fragments-or replicas of fragments-for storage at the various sites. These techniques are used during the process of distributed database design. The information concerning data fragmentation, allocation, and replication is stored in a global directory that is accessed by the DDBS applications as needed.
Data Fragmentation
In a DDB, decisions must be made regarding which site should be used to store which portions of the database. For now, we will assume that there is no replication; that is, each relation- or portion of relation- is to be stored at only one site. We will discuss replication and its effects later in this section. We also use the terminology of relational databases - similar concepts apply to other data models. We assume that we are starting with a relational database scheme and must decide how to distribute the relations over various sites.
Before we decide on how to distribute the data, we must determine the logical units of the database that are to be distributed. The simplest logical units are the relations themselves; that is, each whole relation is to be stored at a particular site. In our example, we must decide on a site to store each of the relations EMPLOYEE, DEPARTMENT, PROJECTS, WORKS ON and DEPENDENT. In many cases, however, a relation can be divided into smaller logical units for distribution. For example, consider the company database shown in the company. We may want to store the database information relating to each department at the computer site for that department. A technique called horizontal fragmentation can be used to partition each relation by department.
Horizontal Fragmentation
A horizontal fragment of a relation is a subset of the tuples in that relation. The tuples that belong to the horizontal fragment are specified by a condition on one or more attributes of the relation. Often, only a single attribute is involved. For example, we may define three horizontal fragments on the EMPLOYEE relation with the following conditions (DNO=5),(DNO=4), and (DNO=1), each fragment contains the EMPLOYEE tuples working for a particular department. Similarly, we may define three horizontal fragments for the PROJECT relation, with the conditions (DNUM=5),(DMUN=4), and(DMUN=1), each fragment contains the PROJECT tuples controlled by a particular Department. Horizontal fragmentation divides a relation horizontally by grouping rows to create subsets of tuples, where each subset has a certain logical meaning. These fragments can then be assigned to different sites in the distributed system. Derived horizontal fragmentation applies the partitioning of a primary relation (DEPARTMENT in our example) to other secondary relations (EMPLOYEE and PROJECT in our example), which are related to the primary via a foreign key. This way, related data between the primary and the secondary relations gets fragmented in the same way.
Vertical Fragmentation
Each site may not need all the attributes of a relation, which would indicate the need for a different type of fragmentation. Vertical fragmentation divides a relation “vertically” by columns. A vertical fragment of a relation keeps only certain attributes of the relation. For example, we may want to fragment the EMPLOYEE relation into two vertical fragments. The first fragment includes personal information-NAME, DATE, ADDRESS, and SEX- and the second includes work-related information-SSN, SALARY, SUPERSSN, DNO. This vertical fragmentation is not quite proper because, if the two fragments are stored separately, we cannot put the original employee tuples back together, since there is no common attribute between the two fragments. It is necessary to include the primary key or some candid key attribute in every vertical fragment so that the full relation can be reconstructed from the fragments. Hence, we must add the SSN attribute to the personal information fragment.
Notice that each horizontal fragment on a relation R can be specified by a sCi (R) operation in the relational algebra. 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)—is called a complete horizontal fragmentation of R. In many cases a complete horizontal fragmentation is also disjoint: that is, no tuple in R satisfies (Ci and Cj) for any i ¹ j. Our two earlier examples of horizontal fragmentation for the EMPLOYEE and PROJECT relations were both complete and disjoint. To reconstruct the relation R from a complete horizontal fragmentation, we need to apply the UNION operation to the fragment.
A vertical fragment on a relation R can be specified by a pLi (R) operation in the relational algebra. A set of vertical fragments whose projection lists L1, L2, …, Ln include all the attributes in R but share only the primary key attribute of R is called a complete vertical fragmentation 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 the relation R from a complete vertical fragmentation, we apply the OUTER UNION operation to the vertical fragments (assuming no horizontal fragmentation is used). Notice that we could also apply a FULL OUTER JOIN operation and get the same result for a complete vertical fragmentation, even when some horizontal fragmentation may also have been applied. The two vertical fragments of the EMPLOYEE relation with projection lists L1 = (SSN, NAME, BDATE, ADDRESS, SEX) AND L2 = (SSN, SALARY, SUPERSSN, DNO) constitute a complete vertical fragmentation of EMPLOYEE.
Two horizontal fragments that are neither complete nor disjoint are those defined on the EMPLOYEE relation by the conditions (SALARY > 50000) and (DNO = 4); they may not include all EMPLOYEE tuples, but may include common tuples. Two vertical fragments that are not complete are those defined by the attribute lists L1 = (NAME, ADDRESS} and L2 = {SSN, NAME, SALARY}; these lists violate both conditions of a complete vertical fragmentation. Mixed (Hybrid) Fragmentation. We can intermix the two types of fragmentation, yielding a mixed fragmentation. For example, we may combine the horizontal and vertical fragmentations of the EMPLOYEE relation given earlier into a mixed fragmentation that includes six fragments. In this case the original relation can be reconstructed by applying
A fragmentation schema of a database is a definition of a set of fragments that includes all attributes and tuples in the database and satisfies the condition that the whole database can be reconstructed from the fragments by applying some sequence of OUTER UNION ( or OUTER JOIN) and UNION operations. It is also sometimes useful—although not necessary—to have all the fragments to be disjoint except for the repetition of primary keys among vertical (or mixed) fragments. In the latter case, all replication and distribution of fragments is clearly specified at a subsequent stage, separately from fragmentation.
No comments:
Post a Comment