- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Explain the evaluation of relational algebra expression(DBMS)

SQL queries are decomposed into query blocks. One query block contains a single SELECT-FROM-WHERE expression, as well as GROUP BY and HAVING clause (if any). Nested queries are split into separate query blocks.

## Example

Consider an example given below −

Select lastname, firstname from employee where salary>(select max(salary) from employee where deptname =CSE ; C=(select max(salary) from employee where deptname=CSE); // inner block Select lastname, firstname from employee where salary>c; //outer block

Where C represents the result returned from the inner block.

The relation algebra for the inner block is Ģ

_{max(salary)}(σ_{dname=CSE}(employee))The relation algebra for the outer blocks is Π

_{lastname, firstname}(σ_{salary>c}(employee))

The query optimizer would then choose an execution or evaluation plan for each block.

## Evaluation of relational algebra expressions

**Materialized evaluation** − Evaluate one operation at a time. Evaluate the expression in a bottom-up manner and stores intermediate results to temporary files.

Store the result of A ⋈ B in a temporary file.

Store the result of C ⋈ D in a temporary file.

Finally, join the results stored in temporary files.

The overall cost=sum of costs of individual operations + cost of writing intermediate results to disk, cost of writing results to results to temporary files and reading them back is quite high.

**Pipelined evaluation** − Evaluate several operations simultaneously. Result of one operation is passed to the next operation. Evaluate the expression in a bottom-up manner and don’t store intermediate results to temporary files.

Don’t store the result of A ⋈ B in a temporary file. Instead the result is passed directly for projection with C and so on.

- Related Questions & Answers
- Explain the relational algebra in DBMS?
- Explain the select operation in relational algebra (DBMS)?
- Explain the binary operations in relational algebra (DBMS)?
- Explain project operation in relational algebra (DBMS)?
- Explain rename operation in relational algebra (DBMS)?
- Explain union operation in relational algebra (DBMS)?
- Explain intersection operation in relational algebra (DBMS)?
- Explain cartesian product in relational algebra (DBMS)?
- Explain division operation in relational algebra (DBMS)?
- Explain the Relational Model in DBMS?
- What is join operation in relational algebra (DBMS)?
- Explain the unary operations of algebra relations in DBMS?
- Write queries using aggregate functions in relational algebra (DBMS)?
- Evaluation of Boolean expression
- Difference between Relational Algebra and Relational Calculus