Unsafe tuple calculus expressions

2.6k Views Asked by At

Consider a relation R1 (roll no,marks). Suppose the entries in R1 are (1,20) and (2,25) and let the domain of roll no and marks be all positive integers .

Now a tuple calculus expression like { t | ~ (t belongs to R1) } is unsafe as we can have infinite number of tuples possible. Suppose I restrict the domain of roll no and marks as positive integers between 1 to 50. Now will the above expression still remain unsafe? I think that it should not be unsafe as we have a finite domain.

1

There are 1 best solutions below

8
On

Finite vs infinite plays a certain role in whether a query is safe. But it isn't that a query is safe when no domain is infinite.

Safe queries are ones whose syntax guarantees domain-independence. A domain-independent query is one whose result can be calculated using relational algebra operators on base relations. The relational operators cannot (by design) calculate the relation of tuples that have the heading of a base relation but are not in it. For R that is { t | t NOT IN R }. I'd give an equivalent relational expression but there isn't one, which is the point. Another way to put this is that a domain-independent query returns the same result no matter what its domains. (Hence the name.) Infinite domains are used in examples because a domain-dependent query with an infinite domain will have an infinite number of rows in its result and it is expected that that infinite result makes it obvious that it cannot be calculated. Anyway these definitions of domain-independence just do not say that a query is domain-independent/safe when there is no infinite domain.

The relational algebra operators are limited to calculating sets of tuples expressible in calculus with every NOT following an AND and with all such AND NOTs and all ORs having operands with the same attributes. The former are calculated via MINUS and the latter are calculated via UNION. Calculating domain-dependent/unsafe query results for finite domains is straightforward. (After all, we know what tuples aren't in a relation.) But the extra relational operators needed have a computational complexity based on the product of the cardinalities of the domains of base relations instead of based on the much smaller number of tuples in base relations. The particular operators of the relational algebra are specifically chosen to avoid those queries/calculations.

(A convincing proof/explanation relies on deriving via valid reasoning rules from accepted assumptions and theorems. If you want to find the flaw in your reasoning, you need to give it per a reference that you accept and share.)

PS If you work out your example in detail with domains & data then you will find that even with finite domains it is difficult to find a relational algebra expression returning its value. Because there isn't one. (Using "relational algebra" in the same sense as domain-independence/safety does.)