Anda di halaman 1dari 6

G.S.

Gupta

Database Mgmt. 6th Semester

Unit 7 & 8

P.C.M.S., Chitwan

Query Processing
It refers to the range of activities involved in extracting the data from the database.
The aim is to transform a query in a high- level declarative language (SQL) into a
correct and efficient execution strategy. It contains the following steps.

Query Decomposition (parsing and translation)


Analysis
Conjunctive and disjunctive normalization
Semantic analysis

Query Optimization
Query Evaluation (Execution)
Before processing the system must translating the query in the internal form. The
translation process is similar to the work performed by the parser o f a compiler. In
generating the internal form o f the qury, the parser checks the syntax of the users query,
verifies that the relation named appearing in the query are name d of the relations in the
database and son on. The system constructs a parse tree representation of the query.
Which It then translates into a relational algebra expression.
query

Parse
and
translato
r

Relational algebra
expression

Optimize
r
Query
outpur

Evaluation
engine

Execution plan

Data

Query evaluation plan


In this case we need not only provide the relation algebra expression but also to
annotate it with instruction specifying how to evaluate each operation. Annotation
may state the algorithm to e used for a specific operation or the particular index or
indices to use. A relational algebra operation annotated with instructions on how to
evaluate it is called an evaluation primitive. A sequence of primitive operation that
can be used to evaluate a query is a query execution plan or query evaluation plan.
Query execution engine takes a query evaluation plan , executed that plan and
returns the answer to the query.
The cost of query evaluation can e measured in terms of a number of different
resource, including disk access, CPU time to execute a query and in a distributed of

Page :1

G.S.Gupta

Database Mgmt. 6th Semester

Unit 7 & 8

P.C.M.S., Chitwan
parallel database system the cost of communication . the response time for a query
evaluation plan assuming no other activity is going on on the computer.
In large data base system the disk access are usually the most important cost since
disk access are slow compared to in memory operations. Moreover CPU speed is
much faster than the disk access so it is likely that the time spent in disk activity will
continue to dominate the total time to execute a query.

The Need for Optimization


Consider:
SELECT name, address
FROM Customer, Account
WHERE Customer. name = Account. name
AND Balance > 2000
There are different possibilities for execution:
C. name, C. address ( C. name= A. name A. balance> 2000 (C A))
Query optimization
Query optimization is a function of many relational database management systems in
which multiple query plans for satisfying a query are examined and a good query plan is
identified. This may or not be the absolute best strategy because there are many ways of
doing plans. There is a trade off between the amount of time spent figuring out the best
plan and the amount running the plan. Different qualities of database management
systems have different ways of balancing these two. Cost based query optimizers evaluate
the resource footprint of various query plans and use this as the basis for plan selection.
Typically the resources which are costed are CPU path length, amount of disk buffer
space, disk storage service time, and interconnect usage between units of parallelism. The
set of query plans examined is formed by examining possible access paths (e.g., primary
index access, secondary index access, full file scan) and various relational table join
techniques (e.g, merge join, hash join, product join). The search space can become quite
large depending on the complexity of the SQL query. There are two types of
optimization. These consist of logical optimization which generates a sequence of
relational algebra to solve the query. In addition there is physical optimization which is
used to determine the means of carrying out each operation.
The goal is to eliminate as many unneeded tuples, or rows as possible. The following is a
look at relational algebra as it eliminates unneeded tuples. The project operator is
straightforward to implement if <attribute list> contains a key to relation R. If it does not
include a key of R, it must be eliminated. This must be done by sorting (see sort methods
below) and eliminating duplicates. This method can also use hashing to eliminate
duplicates Hash table.
SQL command distinct: this does not change the actual data. This just eliminates the
duplicates from the results.

Page :2

Database Mgmt. 6th Semester

G.S.Gupta

Unit 7 & 8

P.C.M.S., Chitwan
Set operations: Database management heavily relies on the mathematical principles of set
theory which is key in comprehending these operations.
Equivalnce of expression
Two relational algebra expression are said to be equivalent if on every legal ata base
instance, the two expression generate the same set of tuples. In SQL, the input and output
are mutisets of tuples and a multiset version of the relational algebra is used for ealuating
sql queries.
Equivalence rule
It says the expression of two form are equivalent we can replace an expression of first
form by an expression of the second form and vice versa. Since the two expression would
generate the same result on any valid database.
1.
conjuctive selection operation can be deconstructed into a sequence of
individual selection. This transformation is refrreed to as cascade of
1^ 2 (E)= 1( 2(E))
2.
selection operation are commutative.
1( 2(E))= 2( 1(E))
3.
4.
5.
6.
7.

selfection can be combined with cartesion products and theta join


(E1 X E2)= E1 X E2
theta join are commutative
E1 |X| E2 = E2 |X| E1
Natural join operation are associative
(E1 |X| E2) |X| E3 = E1 |X| (E2 |X| E3)
The set operation union and intersection are commutative.
E1 U E2 = E2 U E1
E1 E2 = E2 E1
set union and intersection are associative
(E1 U E2) U E3= E1 U (E2 U E3)
(E1 E2) E3= E1 (E2 E3)

Object oriented data base


Object DBMSs add database functionality to object programming languages. They
bring much more than persistent storage of programming language objects. Object
DBMSs extend the semantics of the C++, Smalltalk and Java object programming
languages to provide full-featured database programming capability, while retaining
native language compatibility. A major benefit of this approach is the unification of the
application and database development into a seamless data model and language
environment. As a result, applications require less code, use more natural data modeling,
and code bases are easier to maintain. Object developers can write complete database
applications
with
a
modest
amount
of
additional
effort.
Page :3

G.S.Gupta

Database Mgmt. 6th Semester

Unit 7 & 8

P.C.M.S., Chitwan
According to Rao (1994), "The object-oriented database (OODB) paradigm is the
combination of object-oriented programming language (OOPL) systems and persistent
systems. The power of the OODB comes from the seamless treatment of both persistent
data, as found in databases, and transient data, as found in executing programs."
In contrast to a relational DBMS where a complex data structure must be flattened out to
fit into tables or joined together from those tables to form the in-memory structure, object
DBMSs have no performance overhead to store or retrieve a web or hierarchy of
interrelated objects. This one-to-one mapping of object programming language objects to
database objects has two benefits over other storage approaches: it provides higher
performance management of objects, and it enables better management of the complex
interrelationships between objects. This makes object DBMSs better suited to support
applications such as financial portfolio risk analysis systems, telecommunications service
applications, world wide web document structures, design and manufacturing systems,
and hospital patient record systems, which have complex relationships between data.
The fundamental idea of OOPs is to combine data and function both in to a unit. Which
is called class. This idea is called encapsulation.
student
Rn
Name
Class
Calculate()
Instance of the class
When we want to use this class we have to make an object of this class which will work
Such as
Student s;
Now s is the instance of the class student
The oops provide the different features
1.
Reusability
It means one the function or class is created we can use it many time and any
where with out creating the new one. We create the instance of the class and use.
2.
extensibility
It means we can add the new things to the existing one with rewrite them
3.
polymorphism
it is too difficult to remember the name of all function in a program. But in
oops we can put the same name of all the function and they will differentiate
with each other on the basis of
a. no of passing argument
b. data type of the arguments
c. return type
4.
overloading
It means we can provide the new definition to existing operator.
Page :4

G.S.Gupta

Database Mgmt. 6th Semester

Unit 7 & 8

P.C.M.S., Chitwan
Such as + can add two number. It can not not add the group, but in the
overloading we can provide new definition to the + to add group;
(Remaining part of unit II)

Three level architecture of data base


A data model instance may be one of three kinds (according to ANSI in 1975[1]):

a conceptual schema (data model) describes the semantics of a domain, being the
scope of the model. For example, it may be a model of the interest area of an
organization or industry. This consists of entity classes (representing kinds of
things of significance in the domain) and relationships (assertions about
associations between pairs of entity classes). A conceptual schema specifies the
kinds of facts or propositions that can be expressed using the model. In that sense,
it defines the allowed expressions in an artificial 'language' with a scope that is
limited by the scope of the model. For generally applicable models, see below
under 'Generic data model'.
a logical schema (data model) describes the semantics, as represented by a
particular data manipulation technology. This consists of descriptions of tables
and columns, object oriented classes, and XML tags, among other things.
a physical schema (data model) describes the physical means by which data are
stored. This is concerned with partitions, CPUs, tablespaces, and the like.

The significance of this approach, according to ANSI, is that it allows the three
perspectives to be relatively independent of each other. Storage technology can change
without affecting either the logical or the conceptual model. The table/column structure
can change without (necessarily) affecting the conceptual model. In each case, of course,
the structures must remain consistent with the other model. The table/column structure
may be different from a direct translation of the entity classes and attributes, but it must
ultimately carry out the objectives of the conceptual entity class structure. Early phases of
many software development projects emphasize the design of a conceptual data model.
Such a design can be detailed into a logical data model. In later stages, this model may be
translated into physical data model. However, it is also possible to implement a
conceptual model directly.

Page :5

G.S.Gupta

Database Mgmt. 6th Semester

P.C.M.S., Chitwan

Page :6

Unit 7 & 8

Anda mungkin juga menyukai