Tuesday, November 28, 2023

# Expressive Power Of Algebra And Calculus In Dbms

## Key Differences Between Relational Algebra And Relational Calculus

Expressive Power of Relational Algebra and Relational Calculus by Dr K Suvarchala
• The basic difference between Relational Algebra and Relational Calculus is that Relational Algebra is a Procedural language whereas, the Relational Calculus is a Non-Procedural, instead it is a Declarative language.
• The Relational Algebra defines how to obtain the result whereas, the Relational Calculus define what information the result must contain.
• Relational Algebra specifies the sequence in which operations have to be performed in the query. On the other hands, Relational calculus does not specify the sequence of operations to performed in the query.
• The Relational Algebra is not domain dependent whereas, the Relational Calculus can be domain dependent as we have Domain Relational Calculus.
• The Relational Algebra query language is closely related to programming language whereas, the Relational Calculus is closely related to the Natural Language.
• ## Content: Relational Algebra Vs Relational Calculus

 Relational Algebra is a Procedural language. Relational Claculus is Declarative language. States Relational Algebra states how to obtain the result. Relational Calculus states what result we have to obtain. Order Relational Algebra describes the order in which operations have to be performed. Relational Calculus does not specify the order of operations. Domain Relational Algebra is not domain dependent. Relation Claculus can be domain dependent. Related It is close to a programming language. It is close to the natural language.

## Difference Between Relational Algebra And Relational Calculus

Relational Algebra and Relational Calculus are the formal query languages for a relational model. Both form the base for the SQL language which is used in most of the relational DBMSs. Relational Algebra is a procedural language.

On the other hands, Relational Calculus is a declarative language. Relational Algebra and Relational Calculus can be further differentiated on many aspects, which I have discussed below with the help of comparison chart.

Read Also: What Is The Value Of The Bond Angles In Ccl4

## Operations For Domain Computations

There is nothing in relational algebra introduced so far that would allow computations on the data domains . For example, it’s not possible using only the algebra introduced so far to write an expression that would multiply the numbers from two columns, e.g. a unit price with a quantity to obtain a total price. Practical query languages have such facilities, e.g. the SQL SELECT allows arithmetic operations to define new columns in the result SELECT unit_price * quantity AS total_price FROM t, and a similar facility is provided more explicitly by Tutorial D’s EXTEND keyword. In database theory, this is called extended projection.:213

#### Aggregation

Furthermore, computing various functions on a column, like the summing up its elements, is also not possible using the relational algebra introduced insofar. There are five aggregate functions that are included with most relational database systems. These operations are Sum, Count, Average, Maximum and Minimum. In relational algebra the aggregation operation over a schema is written as follows:

G1, G2, …, Gmgf1, f2, …, fk

where each Aj’, 1 â¤ j â¤ k, is one of the original attributes Ai, 1 â¤ i â¤ n.

Let’s assume that we have a table named Account with three columns, namely Account_Number, Branch_Name and Balance. We wish to find the maximum balance of each branch. This is accomplished by Branch_NameGMax. To find the highest balance of all accounts regardless of branch, we could simply write GMax.

## Definition Of Relational Algebra Relational algebra presents the basic set of operations for relational model. It is a procedural language, which describes the procedure to obtain the result. Relational algebra is prescriptive because it describes the order of operations in the query that specifies howto retrieve the result of a query.

The sequence of operations in a relation algebra is called relational algebra expression. The Relational Algebra Expression either takes one relation or two relations as an input to the expression and produces a new relation as a result. The resultant relation obtained from the relational algebra expressions can be further composed to the other relational algebra expression whose result will again be a new relation.

The Relation Algebra forms the framework for implementing and optimizing queries while query processing. Relational algebra is an integral part of relational DBMS. The fundamental operation included in relational algebra are .

Read Also: Beth Child Of Rage Now

## Definition Of Relational Calculus

Unlike Relational Algebra, Relational Calculus is a higher level language. In converse to the relational algebra, relational calculus defines what result is to be obtained. Like Relational Algebra, Relational Calculus does not specify the sequence of operations in which query will be evaluated.

The sequence of relational calculus operations is called relational calculus expression that also produces a new relation as a result. The Relational Calculus has two variations namely Tuple Relational Calculus and Domain Relational Calculus.

The Tuple Relational Calculus list the tuples to selected from a relation, based on a certain condition provided. It is formally denoted as:

Where t is the set of tuples fro which the condition P is true.

The next variation is Domain Relational Calculus, which in contrast to Tuple Relational Calculus list the attributes to be selected from a relation, based on certain condition. The formal definition of Domain Relational Calculus is as follow:

Where X1, X2, X3, . . . Xn are the attributes and P is the certain condition.

## Use Of Algebraic Properties For Query Optimization

Queries can be represented as a tree, where

• the internal nodes are operators,
• leaves are relations,
• subtrees are subexpressions.

Our primary goal is to transform expression trees into equivalent expression trees, where the average size of the relations yielded by subexpressions in the tree is smaller than it was before the optimization. Our secondary goal is to try to form common subexpressions within a single query, or if there is more than one query being evaluated at the same time, in all of those queries. The rationale behind the second goal is that it is enough to compute common subexpressions once, and the results can be used in all queries that contain that subexpression.

Here we present a set of rules that can be used in such transformations.

Also Check: Why Do People Copy Others