0% found this document useful (0 votes)
3 views79 pages

Relational Algebra

The document covers relational algebra and relational calculus as part of advanced database management systems, detailing unary and binary relational operations, including selection, projection, and joins. It explains the relational model concepts, operations from set theory, and query processing and optimization. Additionally, it discusses the properties of these operations and provides examples for better understanding.

Uploaded by

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

Relational Algebra

The document covers relational algebra and relational calculus as part of advanced database management systems, detailing unary and binary relational operations, including selection, projection, and joins. It explains the relational model concepts, operations from set theory, and query processing and optimization. Additionally, it discusses the properties of these operations and provides examples for better understanding.

Uploaded by

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

RELATIONAL ALGEBRA AND RELATIONAL CALCULUS

ADVANCED DATABASE MANAGEMENT SYSTEMS


ICT 331-2

1
CONTENT

1. Unary relational operations


2. Relational algebra operations from set theory
3. Binary relational operations
4. Cartesian product
5. Joins
6. Relational Calculus Query Processing and Optimization:
Translating SQL query into Relational Algebra
7. Query Optimization & Cost Estimation in Query Execution
RELATIONAL MODEL CONCEPTS

 Relational model represents the database as a collection of


relations.

 Relational schema (R) - structure of a relation (table)


 Domain (D) - a set of possible values that can be stored in a
specific column (attribute) of a table.
 Attribute (A) - representing one type of data
 Degree – the number of attributes in relational schema
RELATIONAL MODEL CONCEPTS
RELATIONAL ALGEBRA OVERVIEW

 Relational algebra is the basic set of operations for the


relational model

 These operations enable a user to specify basic retrieval


requests (or queries)

 The result of an operation is a new relation, which may


have been formed from one or more input relations

 This property makes the algebra “closed” (all objects in


RELATIONAL ALGEBRA OVERVIEW

 The algebra operations thus produce new relations

 These can be further manipulated using operations of the


same algebra

 A sequence of relational algebra operations forms a


relational algebra expression

 The result of a relational algebra expression is also a


relation that represents the result of a database query (or
RELATIONAL ALGEBRA OVERVIEW

• Relational Algebra consists of several groups of operations

 Unary Relational Operations


 SELECT (symbol: (sigma))
 PROJECT (symbol: (pi))
 RENAME (symbol: (rho))
 Relational Algebra Operations From Set Theory
 UNION (), INTERSECTION ( ), DIFFERENCE (or MINUS,
– ) CARTESIAN PRODUCT ( x )
RELATIONAL ALGEBRA OVERVIEW

 Binary Relational Operations


 JOIN (several variations of JOIN exist)
 DIVISION
 Additional Relational Operations
 OUTER JOINS, OUTER UNION
 AGGREGATE FUNCTIONS (These compute summary of
information: for example, SUM, COUNT, AVG, MIN,
MAX)
DATABASE STATE FOR COMPANY
UNARY RELATIONAL OPERATIONS: SELECT

 The SELECT operation (denoted by (sigma)) is used to select


a subset of the tuples from a relation based on a selection
condition.
 The selection condition acts as a filter
 Keeps only those tuples that satisfy the qualifying condition
 Tuples satisfying the condition are selected whereas the
other tuples are discarded (filtered out)
Name Age City
Alice 20 Colombo
Bod 17 Galle
Carol 22 Colombo
UNARY RELATIONAL OPERATIONS: SELECT

 Examples:
 Select the EMPLOYEE tuples whose department number is
4:
 (EMPLOYEE)
 Select the employee tuples whose salary is greater than
$30,000:
 (EMPLOYEE)
UNARY RELATIONAL OPERATIONS: SELECT

In general, the select operation is denoted by
<selection condition>(R) where

the symbol (sigma) is used to denote the select operator

the selection condition is a Boolean (conditional)
expression specified on the attributes of relation R

tuples that make the condition true are selected
 appear in the result of the operation

tuples that make the condition false are filtered out
 discarded from the result of the operation
Name Age Department
Alice 30 HR
Bob 25 IT
Carol 40 IT
UNARY RELATIONAL OPERATIONS: SELECT
 SELECT Operation Properties
 The SELECT operation 
<selection condition>(R) produces a
relation
S that has the same schema (same attributes) as R
 SELECT  is commutative:

<condition1>( < condition2> (R)) = 
<condition2> ( < condition1> (R))
 Because of commutativity property, a cascade
(sequence) of
SELECT operations may be applied in any order:

<cond1>(<cond2> (<cond3> (R)) = <cond2>
(<cond3> (<cond1> ( R)))
UNARY RELATIONAL OPERATIONS: SELECT

 A cascade of SELECT operations may be replaced by a


single
selection with a conjunction of all the conditions:
 
<cond1>(< cond2> (<cond3>(R)) =  <cond1> AND <
cond2>
AND <cond3>(R)))
 The number of tuples in the result of a SELECT is less than

(or equal to) the number of tuples in the input relation R


Name Age Department Salary
Alice 30 HR 5000
Bob 25 IT 4000
Carol 40 IT 6000
THE FOLLOWING QUERY RESULTS
REFER TO THIS DATABASE STATE
UNARY RELATIONAL OPERATIONS: PROJECT

PROJECT Operation is denoted by  (pi)
 This operation keeps certain columns (attributes) from a
relation and discards the other columns.
 PROJECT creates a vertical partitioning

The list of specified columns (attributes) is kept in
each tuple

The other attributes in each tuple are discarded
 Example: To list each employee’s first and last name
and salary, the following is used:
LNAME, FNAME,SALARY(EMPLOYEE)
FNAME LNAME SALARY DEPT
Alice Smith 5000 HR
Bob Johnson 6000 ITIT
Carol Davis 5500
UNARY RELATIONAL OPERATIONS: PROJECT (CONT.)
 The general form of the project operation is:

<attribute list>(R)
  (pi) is the symbol used to represent the project

 operation
 <attribute list> is the desired list of attributes from

relation R.
 The project operation removes any duplicate tuples

 This is because the result of the project operation must

be a set of tuples

Mathematical sets do not allow duplicate elements.
ID NAME GRADE AGE
1 Alice A 20
2 Bob B 21
3 Alice A 20
4 Carol A 22
UNARY RELATIONAL OPERATIONS: PROJECT (CONTD.)
 PROJECT Operation Properties
 The number of tuples in the result of projection
<list>(R) is always less or equal to the number of tuples
in R

If the list of attributes includes a key of R, then the
number of tuples in the result of PROJECT is equal to
the number of tuples in R
 PROJECT is not commutative
  <list1> ( <list2> (R) ) =  <list1> (R) as long as <list2>
ID NAME GRADE AGE
1 Alice A 20
2 Bob B 21
3 Alice A 20
4 Carlo A 22
If we apply:
π NAME, GRADE (STUDENT)

If we apply:
π NAME, GRADE (π NAME (STUDENT))
EXAMPLES OF APPLYING
SELECT AND PROJECT
OPERATIONS
RELATIONAL ALGEBRA EXPRESSIONS
 We may want to apply several relational algebra
operations one after the other
 Either we can write the operations as a single
relational algebra expression by nesting the
operations, or
 We can apply one operation at a time and create
intermediate result relations.
 In the latter case, we must give names to the relations
that hold the intermediate results.
SINGLE EXPRESSION VERSUS SEQUENCE OF RELATIONAL
OPERATIONS (EXAMPLE)
 To retrieve the first name, last name, and salary of all employees
who work in department number 5, we must apply a select and a
project operation
 We can write a single relational algebra expression as follows:


FNAME, LNAME, SALARY( DNO=5(EMPLOYEE))
 OR We can explicitly show the sequence of operations, giving a name
to each intermediate relation:

DEP5_EMPS   DNO=5(EMPLOYEE)


RESULT   FNAME, LNAME, SALARY (DEP5_EMPS)
ID NAME AGE GRADE
1 Alice 20 A
2 Bob 21 B
3 Carol 22 A
4 David 20 B
UNARY RELATIONAL OPERATIONS: RENAME

 The RENAME operator is denoted by  (rho)


 In some cases, we may want to rename the attributes
of a relation or the relation name or both

Useful when a query requires multiple
operations

Necessary in some cases (see JOIN operation later)
UNARY RELATIONAL OPERATIONS: RENAME (CONTINUED)
 The general RENAME operation  can be expressed

by any of the following forms:


 S (B1, B2, … , Bn ) (R) changes both:

the relation name to S, and

the column (attribute) names to B1, B1, …..Bn
 S(R) changes:

the relation name only to S
 (B1, B2, … , Bn ) (R) changes:

the column (attribute) names only to B1, B1,
EXAMPLE

 ρWORKER (EMP_ID, EMP_NAME, EMP_AGE, EMP_SALARY)


(EMPLOYEE)

 ρWORKER (EMPLOYEE)

 ρ(EMP_ID, EMP_NAME, EMP_AGE, EMP_SALARY) (EMPLOYEE)


UNARY RELATIONAL OPERATIONS: RENAME (CONTINUED)

 For convenience, we also use a shorthand for renaming


attributes in an intermediate relation:
 If we write:
• RESULT   FNAME, LNAME, SALARY (DEP5_EMPS)
• RESULT will have the same attribute names as
DEP5_EMPS (same attributes as EMPLOYEE)
RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY:
UNION
 UNION Operation
 Binary operation, denoted by 

 The result of R  S, is a relation that includes all tuples

that are either in R or in S or in both R and S


 Duplicate tuples are eliminated


The two operand relations R and S must be “type
compatible” (or UNION compatible)

R and S must have same number of attributes

Each pair of corresponding attributes must be type
compatible (have same or compatible domains)
RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY:
UNION
 Example:

To retrieve the social security numbers of all employees
who either work in department 5 (RESULT1 below) or directly
supervise an employee who works in department 5 (RESULT2
below)
 We can use the UNION operation as follows:

DEP5_EMPS  DNO=5 (EMPLOYEE)


RESULT1   SSN(DEP5_EMPS)
RESULT2(SSN)  SUPERSSN(DEP5_EMPS)
RESULT  RESULT1  RESULT2
 The union operation produces the tuples that are in
either
RESULT1 or RESULT2 or both
← RESULT1 𝖴 RESULT2.
FIGURE 8.3 RESULT OF THE UNION OPERATION RESULT
RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY
 Type Compatibility of operands is required for the binary set
operation UNION , (also for INTERSECTION , and SET
DIFFERENCE – )

 R1(A1, A2, ..., An) and R2(B1, B2, ..., Bn) are type compatible
if:
 they have the same number of attributes, and

 the domains of corresponding attributes are type compatible

(i.e. dom(Ai)=dom(Bi) for i=1, 2, ..., n).


 The resulting relation for R1R2 (also for R1R2, or R1– R2)
has the same attribute names as the first operand relation R1
RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY:
INTERSECTION

 INTERSECTION is denoted by 
 The result of the operation R  S, is a relation that
includes all tuples that are in both R and S
 The attribute names in the result will be the same as the

attribute names in R
 The two operand relations R and S must be “type
compatible”
RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY: SET
DIFFERENCE (CONT.)

 SET DIFFERENCE (also called MINUS or EXCEPT) is


denoted by –
 The result of R – S, is a relation that includes all tuples that
are in R but not in S
 The attribute names in the result will be the same as
the attribute names in R
 The two operand relations R and S must be “type
compatible”
SOME PROPERTIES OF UNION, INTERSECT, AND DIFFERENCE
 Notice that both union and intersection are commutative
operations; that is
 R  S = S  R, and R  S = S  R

 Both union and intersection can be treated as n-ary


operations applicable to any number of relations as both are
associative operations; that is
 R  (S  T) = (R  S)  T

 (R  S)  T = R  (S  T)

 The minus operation is not commutative; that is, in


general
EXAMPLE

 R has 2 tuples: (𝐴1,𝐴2)(A1,A2) and (𝐴3,𝐴4)(A3,A4)


 S has 3 tuples: (𝐵1,𝐵2)(B1,B2), (𝐵3,𝐵4)(B3,B4), and
(𝐵5,𝐵6)(B5,B6)
RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY:
CARTESIAN PRODUCT
 CARTESIAN (or CROSS) PRODUCT Operation
 This operation is used to combine tuples from two relations

in a combinatorial fashion.
 Denoted by R(A1, A2, . . ., An) x S(B1, B2, . . ., Bm)

 Result is a relation Q with degree n + m attributes:


Q(A1, A2, . . ., An, B1, B2, . . ., Bm), in that order.
 The resulting relation state has one tuple for each

combination of tuples—one from R and one from S.


 Hence, if R has n tuples (denoted as |R| = n ), and S has n
R R S
tuples, then R x S will have nR * nS tuples.

RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY:
CARTESIAN PRODUCT (CONT.)

 Generally, CROSS PRODUCT is not a meaningful


operation
 Can become meaningful when followed by other operations

 Example (not meaningful):


SEX=’F’(EMPLOYEE)
 FEMALE_EMPS  

 EMPNAMES   FNAME, LNAME, SSN (FEMALE_EMPS)


 EMP_DEPENDENTS  EMPNAMES x DEPENDENT

 EMP_DEPENDENTS will contain every combination of


EMPNAMES and DEPENDENT
 whether or not they are actually related
RELATIONAL ALGEBRA OPERATIONS FROM SET THEORY:
CARTESIAN PRODUCT (CONT.)

 To keep only combinations where the DEPENDENT is


related to the EMPLOYEE, we add a SELECT operation as
follows
 Example (meaningful):
 FEMALE_EMPS  
SEX=’F’(EMPLOYEE)
 EMPNAMES  
FNAME, LNAME, SSN (FEMALE_EMPS)
 EMP_DEPENDENTS  EMPNAMES x DEPENDENT

 ACTUAL_DEPS  
SSN=ESSN(EMP_DEPENDENTS)
 RESULT   FNAME, LNAME, DEPENDENT_NAME (ACTUAL_DEPS)
 RESULT will now contain the name of female employees
BINARY RELATIONAL OPERATIONS: JOIN

 JOIN Operation (denoted by )



The sequence of CARTESIAN PRODECT followed by
SELECT is used quite commonly to identify and select
related tuples from two relations
 A special operation, called JOIN combines this sequence

 into a single operation



This operation is very important for any relational database
with more than a single relation, because it allows us
combine related tuples from various relations
BINARY RELATIONAL OPERATIONS: JOIN

 The general form of a join operation on two relations R(A1, A2,


. . ., An) and S(B1, B2, . . ., Bm) is:
R <join
S
 where R and S condition>
can be any relations that result from
general relational algebra expressions.
BINARY RELATIONAL OPERATIONS: JOIN (CONT.)
 Example: Suppose that we want to retrieve the name of the
manager of each department.
 To get the manager’s name, we need to combine each

DEPARTMENT tuple with the EMPLOYEE tuple whose SSN


value matches the MGRSSN value in the department tuple.
 We do this by using the join operation.
 DEPT_MGR  DEPARTMENT
MGRSSN=SSN EMPLOYEE
 MGRSSN=SSN is the join condition
 Combines each department record with the employee

who
manages the department
 The join condition can also be specified as

DEPARTMENT.MGRSSN= EMPLOYEE.SSN
RESULT OF THE JOIN OPERATION

DEPT_MGR ← DEPARTMENT|X| Mgr_ssn=SsnEMPLOYEE.


BINARY RELATIONAL OPERATIONS: EQUIJOIN
 EQUIJOIN Operation
 The most common use of join involves join conditions
with equality comparisons only
 Such a join, where the only comparison operator used is =,
is called an EQUIJOIN.
 In the result of an EQUIJOIN we always have one or more

pairs of attributes (whose names need not be


identical) that have identical values in every tuple.
 The JOIN seen in the previous example was an

EQUIJOIN.
BINARY RELATIONAL OPERATIONS: NATURAL JOIN
OPERATION

 NATURAL JOIN Operation


 Another variation of JOIN called NATURAL JOIN —

denoted by * — was created to get rid of the


second (superfluous) attribute in an EQUIJOIN
condition.

because one of each pair of attributes with
identical values is
superfluous
 The standard definition of natural join requires that the

two join attributes, or each pair of corresponding join


BINARY RELATIONAL OPERATIONS NATURAL JOIN
(CONTINUED)
 Example: To apply a natural join on the DNUMBER attributes of
DEPARTMENT and DEPT_LOCATIONS, it is sufficient to write:
 DEPT_LOCS  DEPARTMENT * DEPT_LOCATIONS

 Only attribute with the same name is DNUMBER

 An implicit join condition is created based on this attribute:

DEPARTMENT.DNUMBER=DEPT_LOCATIONS.DNUMBER
 Another example: Q  R(A,B,C,D) * S(C,D,E)
 The implicit join condition includes each pair of attributes with
the
same name, “AND”ed together:

R.C=S.C AND R.D.S.D
 Result keeps only one attribute of each such pair:
Example of NATURAL JOIN
operation
COMPLETE SET OF RELATIONAL OPERATIONS

 The set of operations including SELECT , PROJECT  , UNION


, DIFFERENCE  , RENAME , and CARTESIAN PRODUCT X is
called a complete set because any other relational algebra
expression can be expressed by a combination of these five
operations.
 For example:
 R  S = (R  S ) – ((R  S)  (S  R))

 R
<join condition>S =  <join condition> (R

X S)
BINARY RELATIONAL OPERATIONS: DIVISION
 DIVISION Operation
 The division operation is applied to two relations
 R(Z)  S(X), where X subset Z. Let Y = Z - X (and hence Z=
X  Y); that is, let Y be the set of attributes of R that are not
attributes of S.
 The result of DIVISION is a relation T(Y) that includes a tuple
t if tuples tR appear in R with tR [Y] = t, and with
 t [X] = t for every tuple t in S.
R s s

 For a tuple t to appear in the result T of the DIVISION, the


values in t must appear in R in combination with every tuple
in S.
Example of DIVISION
Operations of Relational Algebra
RELATIONAL CALCULUS

 A relational calculus expression creates a new relation,


which is specified in terms of variables that range over rows
of the stored database relations (in tuple calculus) or over
columns of the stored relations (in domain calculus).
 In a calculus expression, there is no order of operations to
specify how to retrieve the query result—a calculus
expression specifies only what information the result should
contain.
 This is the main distinguishing feature between
relational algebra and relational calculus.
RELATIONAL CALCULUS (CONTINUED)

 Relational calculus is considered to be a nonprocedural


or declarative language.
 This differs from relational algebra, where we must write
a sequence of operations to specify a retrieval request;
hence relational algebra can be considered as a
procedural way of stating a query.
TUPLE RELATIONAL CALCULUS
 The tuple relational calculus is based on specifying a
number of tuple variables.
 Each tuple variable usually ranges over a particular database
relation, meaning that the variable may take as its value any
individual tuple from that relation.
 A simple tuple relational calculus query is of the form
 {t | COND(t)}
 where t is a tuple variable and COND (t) is a conditional
expression involving t.
 The result of such a query is the set of all tuples t that
satisfy COND (t).
TUPLE RELATIONAL CALCULUS

 Example: To find the first and last names of all employees


whose salary is above $50,000, we can write the following
tuple calculus expression:
{t.FNAME, t.LNAME | EMPLOYEE(t) AND t.SALARY>50000}

 The condition EMPLOYEE(t) specifies that the range relation of


tuple variable t is EMPLOYEE.
 The first and last name (PROJECTION FNAME, LNAME) of each
EMPLOYEE tuple t that satisfies the condition
t.SALARY>50000 (SELECTION  SALARY >50000) will be retrieved.
LANGUAGES BASED ON TUPLE RELATIONAL CALCULUS
 The language SQL is based on tuple calculus. It uses the
basic block structure to express the queries in tuple
calculus:
 SELECT <list of attributes>
 FROM <list of relations>
 WHERE <conditions>
 SELECT clause mentions the attributes being projected,
the FROM clause mentions the relations needed in the
query, and the WHERE clause mentions the selection as
well as the join conditions.
 SQL syntax is expanded further to accommodate other
LANGUAGES BASED ON TUPLE RELATIONAL CALCULUS
(CONTINUED)
 Another language which is based on tuple calculus is

QUEL which actually uses the range variables as in tuple


calculus. Its syntax includes:
 RANGE OF <variable name> IS <relation name>
 Then it uses
 RETRIEVE <list of attributes from range variables>
 WHERE <conditions>
 This language was proposed in the relational DBMS
INGRES. (system is currently still supported by Computer
Associates – but the QUEL language is no longer there).
INTRODUCTION TO QUERY PROCESSING
 Query optimization:
 The process of choosing a suitable execution strategy for
processing a query.
 Two internal representations of a query:
 Query Tree
 Query Graph
TRANSLATING SQL QUERIES INTO RELATIONAL ALGEBRA
 Query block:
 The basic unit that can be translated into the algebraic
operators and optimized.
 A query block contains a single SELECT-FROM-WHERE
expression, as well as GROUP BY and HAVING clause if
these are part of the block.
 Nested queries within a query are identified as separate
query blocks.
 Aggregate operators in SQL must be included in the
extended algebra.
INTRODUCTION TO QUERY PROCESSING
TRANSLATING SQL QUERIES INTO RELATIONAL
ALGEBRA (2)
SELECT LNAME, FNAME
FROM EMPLOYEE
WHERE SALARY > ( SELECT MAX (SALARY)
FROM EMPLOYEE
WHERE DNO = 5);

SELECT LNAME, SELECT MAX


FNAME (SALARY)
FROM FROM
EMPLOYEE
EMPLOYEE
WHERE DNO = 5
(σSALARY>C(EMPLOYEE))
WHERE
πLNAME, FNAME SALARY > C ℱMAX SALARY (σDNO=5 (EMPLOYEE))
USING HEURISTICS IN QUERY OPTIMIZATION
 Process for heuristics optimization
1. The parser of a high-level query generates an initial
internal representation;
2. Apply heuristics rules to optimize the internal
representation.
3. A query execution plan is generated to execute groups of
operations based on the access paths available on the files
involved in the query.
 The main heuristic is to apply first the operations that reduce
the size of intermediate results.
 E.g., Apply SELECT and PROJECT operations before
USING HEURISTICS IN QUERY OPTIMIZATION (2)

 Query tree:
 A tree data structure that corresponds to a relational algebra expression. It
represents the input relations of the query as leaf nodes of the tree, and
represents the relational algebra operations as internal nodes.
 An execution of the query tree consists of executing an internal node
operation whenever its operands are available and then replacing that
internal node by the relation that results from executing the operation.
 Query graph:
 A graph data structure that corresponds to a relational calculus
expression. It does not indicate an order on which operations to perform
first. There is only a single graph corresponding to each query.
QUERY TREES AND QUERY GRAPH CORRESPONDING TO Q2

Figure 19.1 Two query trees for


the query Q2. (a) Query tree
corresponding to the relational
algebra expression for Q2. (b)
Initial (canonical) query tree for
SQL query Q2. (c) Query graph
for Q2.
QUERY TREES AND HEURISTICS FOR QUERY OPTIMIZATION
(CONT’D.)
 Query tree represents a specific order of operations for executing a
query
 Preferred to query graph for this reason
 Query graph
 Relation nodes displayed as single circles
 Constants represented by constant nodes
 Double circles or ovals
 Selection or join conditions represented as edges
 Attributes to be retrieved displayed in square brackets
HEURISTIC OPTIMIZATION OF QUERY TREES

 Many different query trees can be used to represent the


query and get the same results
 Following figure initial tree for Q2
 Very inefficient - will never be executed
 Optimizer will transform into equivalent final query tree
QUERY TRANSFORMATION EXAMPLE

Steps in converting a query tree during heuristic optimization. (a) Initial


(canonical) query tree for SQL query Q.
QUERY TRANSFORMATION EXAMPLE (CONT’D.)

Steps in converting a query tree during heuristic optimization


(b) Moving SELECT operations down the query tree.
QUERY TRANSFORMATION EXAMPLE (CONT’D.)

Steps in converting a query tree during heuristic optimization


(c) Applying the more restrictive SELECT operation first.
QUERY TRANSFORMATION EXAMPLE (CONT’D.)

Steps in converting a query tree during heuristic optimization


Slide 19-
(d) Replacing CARTESIAN PRODUCT and SELECT with JOIN operations.
76
QUERY TRANSFORMATION EXAMPLE (CONT’D.)

Steps in converting a query tree during heuristic optimization


Slide 19-
(e) Moving PROJECT operations down the query tree.
77
USING SELECTIVITY AND COST ESTIMATES IN QUERY
OPTIMIZATION
 Cost Components for Query Execution
1. Access cost to secondary storage
2. Storage cost
3. Computation cost
4. Memory usage cost
5. Communication cost

 Note: Different database systems may focus on different cost


components.
THANK YOU!

You might also like