40% OFF FOR NEW LICENSES AND RENEWALS →

A common type of operation that usually cannot be defined in the relational algebra is the recursive closure. This operation is used exclusively in recursive relationships.

This relationship is described by a foreign key that relates each tuple in a table similar to another tuple in a related table. An example of a recursive operation is to retrieve all the employees of another employee and at all levels, ie all employees and the ones ‘directly supervised by that employee, and’ ‘directly supervised by e’, all employees and ‘ ” directly supervised by him’, and so on.

Although it is simple to specify, in the relational algebra, all supervised employees by a specific level, it is difficult to specify all supervised employees at all levels. For example, to specify the codes of all employees and ‘directly supervised employees’ ⎯ ⎯ at level one by whose name is’ James Borg’, it is possible to apply the following operations:

BORG_NSS ← πNSS  (σ PNAME = ‘James’ AND SNAME = ‘Borg’ (EMPLOYEE))

SUPERVISION (SNN1, SNN2) ← πNSS, NSSSUPER (EMPLOYEE)

RESULT1 ← πSNN1 (SUPERVISION ⌧SNN2 = NSS BORG_NSS)

To retrieve all employees supervised by Borg at level two, ie all employees and ‘ employees supervised by the first employee’ and that is directly supervised by Borg, you can apply another JOIN to the result of the first query:

RESULT2 ← πSNN1 (SUPERVISION ⌧SNN2 = NSS RESULT1)

For all employees supervised at levels one and two of ‘James Borg’, you can apply the UNION operation as follows:

RESULT3 ← (RESULT1 ∪ RESULT2)

Although it is possible to recover the employees supervised at each level, you cannot specify a query such as “retrieve all employees supervised by ‘James Borg’ at all levels” if not known the maximum number of levels.

 

Recursive closing operations

 

Relational calculus

The Relational Calculus (RC) is a formal query language which, via a declarative expression, can specify a retrieval request. There is no restriction on the way to evaluate a request.

A calculation expression allows the description of the desired query without specifying the procedures for obtaining this information, that is, non-procedural. However, it should be able to formally describe the desired information with accuracy.

There are two types: Relational Calculus of Tuples (RCT) and Domain Relational Calculus (DRC), both simple first-order logical subsets.

In Relational Calculus there are variables, constants, logical operators, comparison and quantifiers. The calculation expressions are called formulas. A tuple of answers is essentially an assignment of constants to variables that take the formula to a real state.

In RCT, the variables are defined on (i.e., bound to) tuples. On the other hand, in DRC, variables are defined on the domain of the elements (ie on the field values).

All query expressions described in RC have equivalent in RA.

The relational calculus of tuples, one of the most used, is based on the specification of a number of tuple variables. Each tuple variable may have as its value any tuple of the specified ratio.

 

A query on RCT is specified as follows:

{Variable tuple | predicate}

The result of such a query is the set of all tuples variables for which the predicate is indicated as true.

All tuple variables discussed so far are considered free variables, since they appear not quantified. However, in addition to the default settings, (universal (∀) or existential (∃)) quantifiers may appear in formulas. In this case, the variables which follow are called variable threshold.

Finally, an expression RCT can generate a multitude of relationships. For the expression {t | NOT (R (t))} there may be a multitude of tuples that are not R, so that it is non-secure. Most of these tuples contain values ​​that are not in the database, therefore, are not desirable as a result.

 

You might also like…

Cache technique in PHP

Cache technique in PHP In this example we will check the actual optimization using a small scri...

A look at Scriptcase 9

In a daily basis this tool has given me great satisfaction, and very good and fast results in terms ...

Deep Data: Is it possible when you’re non-profit?

Evan Liebovitch talks about deep data and how to document the needs of a non-profit while using Scri...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.