Professional Documents
Culture Documents
Fragmentation
Fragmentation
Fragmentation
Fragmentation
Fragmentation is the task of dividing a table into a set of smaller tables. The subsets of the table
are called fragments. Fragmentation can be of three types: horizontal, vertical, and hybrid
(combination of horizontal and vertical). Horizontal fragmentation can further be classified into
two techniques: primary horizontal fragmentation and derived horizontal fragmentation.
Fragmentation should be done in a way so that the original table can be reconstructed from the
fragments. This is needed so that the original table can be reconstructed from the fragments
whenever required. This requirement is called “reconstructiveness.”
Advantages of Fragmentation
Since data is stored close to the site of usage, efficiency of the database system is
increased.
Local query optimization techniques are sufficient for most queries since data is locally
available.
Since irrelevant data is not available at the sites, security and privacy of the database
system can be maintained.
Disadvantages of Fragmentation
When data from different fragments are required, the access speeds may be very high.
Lack of back-up copies of data in different sites may render the database ineffective in
case of failure of a site.
Horizontal Fragmentation
Horizontal fragmentation groups the tuples of a table in accordance to values of one or more
fields. Horizontal fragmentation should also confirm to the rule of reconstructiveness. Each
horizontal fragment must have all columns of the original base table.
For example, in the student schema, if the details of all students of Computer Science Course
needs to be maintained at the School of Computer Science, then the designer will horizontally
fragment the database as follows −
CREATE COMP_STD AS
SELECT * FROM STUDENT
WHERE COURSE = "Computer Science";
Types of horizontal fragmentation
Horizontal Fragmentation has two variants as follows;
Primary horizontal fragmentation is the process of fragmenting a single table, row wise
using a set of conditions.
Primary Horizontal Fragmentation is about fragmenting a single table horizontally (row
wise) using a set of simple predicates (conditions).
Example:
Fragment 1
In this example if values are inserted in table Branch_Name as Pune, Baroda, Delhi.
For the above table we can define any simple condition like, Branch_Name= 'Pune', Branch_Name=
'Delhi', Balance < 50,000
Fragmentation1:
SELECT * FROM Account WHERE Branch_Name= 'Pune' AND Balance < 50,000
Fragmentation2:
SELECT * FROM Account WHERE Branch_Name= 'Delhi' AND Balance < 50,000
Given a table R with set of attributes [A1, A2… An], a simple predicate Pi can be expressed as follows;
Pi: Aj θ Value
Where θ can be any of the symbols in the set {=, <, >, ≤, ≥, ≠}, value can be any value stored in the table
for the attributed Ai. For example, consider the following table Account given in Figure 1:
For the above table, we could define any simple predicates like, Branch_name = ‘Chennai’,
Branch_name= ‘Mumbai’, Balance < 10000 etc using the above expression “Aj θ Value”.
What is set of simple predicates?
Set of simple predicates is set of all conditions collectively required to fragment a relation into subsets.
For a table R, set of simple predicate can be defined as;
Example 1
As an example, for the above table Account, if simple conditions are, Balance < 10000, Balance ≥ 10000,
then,
Example 2
As another example, if simple conditions are, Branch_name = ‘Chennai’, Branch_name= ‘Mumbai’,
Balance < 10000, Balance ≥ 10000, then,
Set of simple predicates P2 = { Branch_name = ‘Chennai’, Branch_name= ‘Mumbai’, Balance < 10000,
Balance ≥ 10000}
When we fragment any relation horizontally, we use single condition, or set of simple predicates to filter
the data. Given a relation R and set of simple predicates, we can fragment a relation horizontally as
follows (relational algebra expression);
where Fi is the set of simple predicates represented in conjunctive normal form, otherwise called as
Min-term predicate which can be written as follows;
Here, P1 means both P1 or ¬(P1), P2 means both P2 or ¬(P2), and so on. Using the conjunctive form of
various simple predicates in different combination, we can derive many such min-term predicates.
For the example 1 stated previously, we can derive set of min-term predicates using the rules stated
above as follows;
We will get 2n min-term predicates, where n is the number of simple predicates in the given predicate
set. For P1, we have 2 simple predicates. Hence, we will get 4 (2 2) possible combinations of min-term
predicates as follows;
m1 = {Balance < 10000 Λ Balance ≥ 10000}
Our next step is to choose the min-term predicates which can satisfy certain conditions to fragment a
table, and eliminate the others which are not useful. For example, the above set of min-term predicates
can be applied each as a formula Fi stated in the above rule for fragment Ri as follows;
Account1 <-- SELECT * FROM account WHERE balance < 10000 AND balance ≥ 10000;
Account2 <-- SELECT * FROM account WHERE balance < 10000 AND NOT balance ≥ 10000;
Account3 <-- SELECT * FROM account WHERE NOT balance < 10000 AND balance ≥ 10000;
which can be written in eAccount4 <-- SELECT * FROM account WHERE NOT balance < 10000 AND NOT
balance ≥ 10000;
Account3
Correctness of Fragmentation
We have chosen set of min-term predicates which would be used to horizontally fragment a
relation (table) into pieces. Now, our next step is to validate the chosen fragments for their
correctness. We need to verify did we miss anything? We use the following rules to ensure that
we have not changed semantic information about the table which we fragment.
The horizontal fragments using the above set of min-term predicates can be generated as follows;
Fragment 1: SELECT * FROM account WHERE branch_name = ‘Chennai’ AND balance ≥ 10000;
Fragment 2: SELECT * FROM account WHERE branch_name = ‘Chennai’ AND balance < 10000;
Fragment 3: SELECT * FROM account WHERE branch_name = ‘Mumbai’ AND balance ≥ 10000;
Fragment 4: SELECT * FROM account WHERE branch_name = ‘Mumbai’ AND balance < 10000;
The horizontal fragments using the above set of min-term predicates can be
generated as follows;
Fragment 1: SELECT * FROM account WHERE branch_name = ‘Chennai’ AND balance ≥ 10000;
Account1
Account2
Fragment 3: SELECT * FROM account WHERE branch_name = ‘Mumbai’ AND balance ≥ 10000;
Account3
Fragment 4: SELECT * FROM account WHERE branch_name = ‘Mumbai’ AND balance < 10000;
Account4
In the ACCOUNT table we have the third branch ‘New Delhi’, which was not specified in the set of simple
predicates. Hence, in the fragmentation process we must not leave the tuple with the value ‘New Delhi’.
That is the reason we have included the min-term predicates m 5 and m6 which can be derived as follows;
Fragment 5: SELECT * FROM account WHERE branch_name <> ‘Mumbai’ AND branch_name <>
‘Chennai’ AND balance ≥ 10000;
Account5
Acno Balance Branch_Name
Fragment 6: SELECT * FROM account WHERE branch_name <> ‘Mumbai’ AND branch_name <>
‘Chennai’ AND balance < 10000;
Account6
Correctness of fragmentation:
Reconstruction: As said before, by performing Union operation between all the fragments,
we will be able to get the original table back. Hence, the fragmentation is correct and the
reconstruction property is satisfied.
Disjointness: When we perform Intersect operation between all the above fragments, we will
get null set as result, as we do not have any records in common for all the fragments. Hence,
disjointness property is satisfied.
Fragmentation1:
SELECT * FROM Account WHERE Branch_Name= 'Baroda' AND Balance < 50,000
Fragmentation2:
SELECT * FROM Account WHERE Branch_Name= 'Delhi' AND Balance < 50,000
Member table is a child table that can be fragmented but by following the constraints of the parent
table.
If we fragment the tables separately, then for every insertion of records the table must verify the
existence of one such value in the parent table. Hence, for this case, the Primary Horizontal
Fragmentation would not work.
Let’s consider an example, where an international university maintains the information about its
STUDENTs. They store information about the STUDENT in STUDENT table and the STUDENT addresses in
ADDRESS table as follows;
ADDRESS(RollNo, Address)
RollNo Address
01 City A, IRAQ
01 City A, UK
02 City D, Italy
02 City A, Pakistan
03 City D, IRAQ
04 City D, Iraq
04 City A, Pakistan
05 City B, China
Table 2: Address Table
If the organization would go for fragmenting the relation STUDENT on the Country attribute, it needs to
create 4 fragments using horizontal fragmentation as mentioned in table below;
ADDRESS1 = ADDRESS ⋉ STUDENT1
ADDRESS2 = ADDRESS ⋉ STUDENT2
ADDRESS3 = ADDRESS ⋉ STUDENT3
ADDRESS4 = ADDRESS ⋉ STUDENT4
This will result in four fragments of ADDRESS where the STUDENT address of all STUDENTs of fragment
STUDENT1 will go into ADDRESS1, and the STUDENT address of all STUDENTs of fragment STUDENT 2 will
go into ADDRESS2, and so on.
The resultant fragment of ADDRESS will be the following;
RollNo Address
01 City A, IRAQ
02 City A, UK
Table 4: Showing fragment 1 of “address” table
RollNo Address
02 City D, Italy
02 City A, Pakistan
Table 5: Showing fragment 2 of “address” table
RollNo Address
04 City D, Iraq
04 City A, Pakistan
05 City B, China
Table 6: Showing fragment 3 of “address” table
RollNo Address
03 City D, IRAQ
Table 7: Showing fragment 4 of “address” table
The derived fragmentation of Address is complete. Because the value of the common attributes RollNo
for the fragments STUDENTi and Addressi are the same. For example, the value present in RollNo of
STUDENT1 is also and only present in Address1, etc.
Disjointness: If the minterm predicates are mutually exclusive then the disjointness rule is satisfied for
Primary Horizontal fragmentation.
Vertical Fragmentation
In vertical fragmentation, the fields or columns of a table are grouped into fragments. In order to
maintain reconstructiveness, each fragment should contain the primary key field(s) of the table. Vertical
fragmentation can be used to enforce privacy of data.
For example, let us consider that a University database keeps records of all registered students in a
Student table having the following schema.
STUDENT
Now, the fees details are maintained in the accounts section. In this case, the designer will fragment the
database as follows −
FROM STUDENT;
Fragment 2
1 Credit card
2 Cash
3 Cash
Example:
Fragmentation1:
SELECT * FROM Acc_NO
Fragmentation2:
SELECT * FROM Balance
The complete vertical fragmentation generates a set of vertical fragments, which can include all the
attributes of original relation.
Hybrid Fragmentation
In hybrid fragmentation, a combination of horizontal and vertical fragmentation techniques are
used. This is the most flexible fragmentation technique since it generates fragments with
minimal extraneous information. However, reconstruction of the original table is often an
expensive task.
At first, generate a set of vertical fragments; then generate horizontal fragments from
one or more of the vertical fragments.
Hybrid fragmentation can be achieved by performing horizontal and vertical
partition together.
Mixed fragmentation is group of rows and columns in relation .
Fragmentation1:
SELECT * FROM Emp_Name WHERE Emp_Age < 40
Fragmentation2:
SELECT * FROM Emp_Id WHERE Emp_Address= 'Pune' AND Salary <
14000