You get a bonus - 1 coin for daily activity. Now you have 1 coin

Lecture 5. Basic means of manipulating relational data

Lecture



In the previous lecture, we talked about the three components of the relational data model. Two of them — the structural and integral components — we examined in more or less detail, and this lecture is devoted to the manipulative part of the relational data model.

As we noted in the previous lecture, two basic mechanisms for manipulating relational data are defined in the manipulation component: relational algebra based on set theory and relational calculus based on mathematical logic (more precisely, on the calculus of first-order predicates). In turn, two types of relational calculus are usually considered - domain calculus and predicate calculus.

All these mechanisms have one important property: they are closed in relation to the concept of relationship. This means that expressions of relational algebra and formulas of relational calculus are defined over relations of relational databases, and the result of the calculation is also relations. As a result, any expression or formula can be interpreted as a relationship, which allows its use in other expressions or formulas.

As we shall see, algebra and calculus have a large expressive power: very complex database queries can be expressed using a single relational algebra expression or a single relational calculus formula. It is for this reason that these mechanisms are included in the relational data model. A specific language for manipulating relational databases is called relational complete if any query expressed using a single expression of relational algebra or a relational calculus formula can be expressed using a single operator of this language.

It is known (and we will not prove it) that the mechanisms of relational algebra and relational calculus are equivalent, i.e. for any admissible expression of relational algebra, one can construct an equivalent (that is, producing the same result) relational calculus formula and vice versa. Why are there both of these mechanisms in the relational data model?

The fact is that they differ in the level of proceduralism. Expressions of relational algebra are built on the basis of algebraic operations (high level), and just as arithmetic and logical expressions are interpreted, the expression of relational algebra also has a procedural interpretation. In other words, a query presented in the language of relational algebra can be computed based on the calculation of elementary algebraic operations, taking into account their precedence and the possible presence of brackets. For the relational calculus formula, a unambiguous interpretation is generally absent. The formula only establishes the conditions that the tuples of the resulting relation must satisfy. Therefore, relational calculus languages ​​are more nonprocedural or declarative.

Since the mechanisms of relational algebra and relational calculus are equivalent, in a particular situation, you can use any of these mechanisms to check the relational degree of a certain database language.

Note that it is extremely rare to use algebra or calculus as the complete basis of any database language. Usually (as, for example, in the case of the SQL language) the language is based on some mixture of algebraic and logical constructions. However, knowledge of the algebraic and logical foundations of database languages ​​is often useful in practice.

In our presentation, we basically follow the approach of Data, applied (though not invented) by him in the latest edition of the book Introduction to Database Systems. To save time and space, we will not introduce any strict syntactic constructions, but mainly restrict ourselves to reviewing the material at a meaningful level.

created: 2014-09-27
updated: 2021-03-13
132434



Rating 9 of 10. count vote: 2
Are you satisfied?:



Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Databases IBM System R - relational DBMS

Terms: Databases IBM System R - relational DBMS