0% found this document useful (0 votes)
256 views

Assignment 04

The document is a student assignment submission containing the following information: 1. The student's name, roll number, class, assignment number, and the subject being "CS-512 Distributed Database". 2. The assignment contains questions on query processing and database fragmentation. For question 1, the student discusses query processing including translation, optimization, and execution of queries. 3. For question 2, the student discusses different types of database fragmentation including horizontal, vertical, and hybrid fragmentation. The reasons and advantages and disadvantages of fragmentation are also provided.

Uploaded by

Dil Nawaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
256 views

Assignment 04

The document is a student assignment submission containing the following information: 1. The student's name, roll number, class, assignment number, and the subject being "CS-512 Distributed Database". 2. The assignment contains questions on query processing and database fragmentation. For question 1, the student discusses query processing including translation, optimization, and execution of queries. 3. For question 2, the student discusses different types of database fragmentation including horizontal, vertical, and hybrid fragmentation. The reasons and advantages and disadvantages of fragmentation are also provided.

Uploaded by

Dil Nawaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Name : Umar Ali

Roll Number : 522

Class # : BS (CS) – 6th Semester

Assignment # : 04

Submitted to : Sir Tariq

Subject : “CS-512 Distributed


Database”
Q1. Introduction to Query Processing:
 Query Processing is a translation of high-level queries into low-level
expression.
 It is a step wise process that can be used at the physical level of the file
system, query optimization and actual execution of the query to get the
result.
 It requires the basic concepts of relational algebra and file structure.
 It refers to the range of activities that are involved in extracting data from
the database.
 It includes translation of queries in high-level database languages into
expressions that can be implemented at the physical level of the file
system.
 In query processing, we will actually understand how these queries are
processed and how they are optimized.
In the above diagram-

 The first step is to transform the query into a standard form.


 A query is translated into SQL and into a relational algebraic
expression. During this process, Parser checks the syntax and
verifies the relations and the attributes which are used in the
query.
 The second step is Query Optimizer. In this, it transforms the
query into equivalent expressions that are more efficient to
execute.
 The third step is Query evaluation. It executes the above query
execution plan and returns the result.

Characteristics of query process:


 Language-
 Input langage can be relational algebra or calculs;
Output language is relation algebra(annotated with
communication primitives). The query process must
efficiently map input language to output language.
 Types of Optimization-
 The output language specification represents the
execution strategy. There Can be selected through
exhaustive search, or by applying heuristic(minimize size
of intermediate relations). For distributed databases semi
joins can be applied to reduce data transfer.
 Statistics-
 Fragment cardinality and size
 Size and number of distinct values for each attribute.
Detailed histograms of attribute values for better
selectivity estimation.
 Decision sites-
 one site or severl sites participate in selection of
strategy.
 Exploitation of network topology-
 Wide area network communication cost
 Local area network parallwl execution

 Exploitation of replicated fragments-
 Larger number of possible strategies
 Use of semijoins
 Reduce sizw of data transfer
 Increase # of message and local processing
 Good for fast or slow network
Q2.

a) Fragmentation:
 The process of dividing the database into a smaller multiple parts is
called as fragmentation.
 These fragments may be stored at different locations.
 The data fragmentation process should be carrried out in such a way
that the reconstruction of original database from the fragments is
possible.
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 “constructiveness.”

Types of data Fragmentation:


There are three types of data fragmentation:

1. Horizontal data fragmentation:


Horizontal fragmentation divides
a relation(table) horizontally into the group of rows to create subsets of tables.

Example:
Account (Acc_No, Balance, Branch_Name, Type).
In this example if values are inserted in table Branch_Name as Pune, Baroda,
Delhi.

The query can be written as:


SELECT*FROM ACCOUNT WHERE Branch_Name= “Baroda”
Types of horizontal data fragmentation are as follows:

1) Primary horizontal fragmentation-


Primary horizontal fragmentation is the process of fragmenting a
single table, row wise using a set of conditions.

Example:

Acc_No Balance Branch_Name


A_101 5000 Pune
A_102 10,000 Baroda
A_103 25,000 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

2) Derived horizontal fragmentation-


Fragmentation derived from the primary relation is called as derived
horizontal fragmentation.

Example: Refer the example of primary fragmentation given above.

The following fragmentation are derived from primary


fragmentation.

Fragmentation1:
SELECT * FROM Account WHERE Branch_Name= 'Baroda' AND Balance <
50,000

Fragmentation2:
SELECT * FROM Account WHERE Branch_Name= 'Delhi' AND Balance <
50,000

3) Complete horizontal fragmentation-


 The complete horizontal fragmentation generates a set of horizontal
fragmentation, which includes every table of original relation.
 Completeness is required for reconstruction of relation so that every table
belongs to at least one of the partitions.

4) Disjoint horizontal fragmentation-

The disjoint horizontal


fragmentation generates a set of horizontal fragmentation in which no two
fragments have common tables. That means every table of relation belongs
to only one fragment.

5) Reconstruction of horizontal fragmentation-


Reconstruction of
horizontal fragmentation can be performed using UNION operation on
fragments.

2. Vertical Fragmentation:
Vertical fragmentation divides a relation(table) vertically into groups of
columns to create subsets of tables.

Example:

Acc_No Balance Branch_Name

A_101 5000 Pune

A_102 10,000 Baroda

A_103 25,000 Delhi

Fragmentation1:
SELECT * FROM Acc_NO

Fragmentation2:
SELECT * FROM Balance
Complete vertical fragmentation
 The complete vertical fragmentation generates a set of vertical fragments,
which can include all the attributes of original relation.
 Reconstruction of vertical fragmentation is performed by using Full Outer
Join operation on fragments.

3) Hybrid Fragmentation:
 Hybrid fragmentation can be achieved by performing horizontal and vertical
partition together.
 Mixed fragmentation is group of rows and columns in relation.

Example: Consider the following table which consists of employee


information.

Emp_ID Emp_Name Emp_Address Emp_Age Emp_Salary

101 Surendra Baroda 25 15000

102 Jaya Pune 37 12000

103 Jayesh Pune 47 10000

Fragmentation1:
SELECT * FROM Emp_Name WHERE Emp_Age < 40

Fragmentation2:
SELECT * FROM Emp_Id WHERE Emp_Address= 'Pune' AND Salary <
14000
b) Reasons for 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.
 In case of recursive fragmentations, the job of reconstruction will
need expensive techniques.
 Lack of back-up copies of data in different sites may render the
database ineffective in case of failure of a site.

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

Regd_No Name Course Address Semester Fees Marks


Now, the fees details are maintained in the accounts section. In this case,
the designer will fragment the database as follows −
CREATE TABLE STD_FEES AS
SELECT Regd_No, Fees
FROM STUDENT;

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";

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.
Hybrid fragmentation can be done in two alternative ways −
 At first, generate a set of horizontal fragments; then generate vertical
fragments from one or more of the horizontal fragments.
 At first, generate a set of vertical fragments; then generate horizontal
fragments from one or more of the vertical fragments.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy