Relational Query Evaluation | Set 2 Last Updated : 14 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite - Relational Query Evaluation | Set 1 Data is stored in disks. Disks are then manipulated using read and write methods. More number of manipulations, lesser number of disks would be failing. To overcome this and to increase life of disks we want to optimize disks used by ensuring fact that we minimize read and write operations using disks. Projection Operation - This operation involves selection of attributes from record. This operation is costly one. For carrying out projection operation, every record in file needs to be scanned to formulate resulting record. Duplicate records in resulting record need to be eliminated using sort or hash-based functions. It is essential to do entire file scan in case of using projection operation. A cost-friendly method would involve using projection operations only after selection operations. This is because there would be fewer records after selection is done and then, projection operation can occur involving lesser cost, lesser read and write operations and more life of disks. Sorting - Sorting is very commonly applied operation. It has its usage in removing duplicate elements, record grouping, joining, etc. External sorting involves huge files present on disk. We can arrange files in increasing or decreasing order of records. We use merge sort for these operations. The merge sort involves 2 phases, namely, sort phase and merge phase. Use of sort phase is in creation of sub-files which are sorted is prevalent. These sorted sub-files are also known as runs. The merge phase is known for merging the sub-files to eventually create one sorted file. Assumption : The assumption is that data is very huge and it is stored in n number of blocks and memory (m blocks) is much smaller than data. The next steps that would be involved are reading m blocks, sorting it in memory and then writing to disk as single file called run. These steps are to be repeated - (n / m) number of times Take, ceiling value whenever value is not integer. Complexity : (2*n) times block access We can say that creation of "r" number of sub-files has taken place, each of which is sorted. Buffer space being only m blocks, we can operate on only m blocks at time. Then, move operated part to memory and operate on next blocks (at max m blocks at a time). Comment More infoAdvertise with us Next Article Relational Query Evaluation | Set 1 S supriya_saxena Follow Improve Article Tags : DBMS DBMS-Relational Algebra Similar Reads Relational Query Evaluation | Set 1 There is a need for conversion of relational query to algebraic expressions. This expression is operated on so that final output is received. The relational algebra operators that are present are Union, Select, Join, Project, etc. These are used to formulate relational query for adequate results. Gr 3 min read SELECT Operation in Relational Algebra Prerequisite - Relational Algebra Select operation chooses the subset of tuples from the relation that satisfies the given condition mentioned in the syntax of selection. The selection operation is also known as horizontal partitioning since it partitions the table or relation horizontally. Notation 2 min read Relational Query Language in DBMS SQL has its own querying methods to interact with the database. But how do these queries work in the database? These queries work similarly to Relational Algebra that we study in mathematics. In the database, we have tables participating in relational Algebra. Relational Database systems are expecte 4 min read Example Queries on Relational Algebra Given below are a few examples of a database and a few queries based on that. (1). Suppose there is a banking database which comprises following tables : Customer(Cust_name, Cust_street, Cust_city) Branch(Branch_name, Branch_city, Assets) Account (Branch_name, Account_number, Balance) Loan(Branch_na 1 min read Set Theory Operations in Relational Algebra Relational Algebra in DBMS These Set Theory operations are the standard mathematical operations on set. These operations are Binary operations that are, operated on 2 relations unlike PROJECT, SELECT and RENAME operations. These operations are used to merge 2 sets in various ways. The set operation 3 min read Set Difference Operator in Relational Algebra Relational Algebra is used to play with the data stored in relational databases. Relational Algebra has many operations to play with tables. One of the fundamental operations is set difference. This article will discuss Set Difference, its condition, and its examples. Key Terms Used in Set Differenc 4 min read Like