0

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.

Zephyr
  • 1,521
  • 3
  • 22
  • 42
  • I don't know the answer to your question, but I googled and found this: http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/Chapter3/node14.html. Does that help? – Lennart - Slava Ukraini Jul 04 '17 at 20:46
  • Please edit your question to say what reference(s) you are using, and how you think it justifies your claims/reasoning. Otherwise your question is too broad, because an answer is such a reference, and why would you believe it? (Oh. Because it gets the most votes? Ha ha ha.) PS The wikipedia tuple calculus article is a pretty good alternate presentation. – philipxy Jul 04 '17 at 23:18

1 Answers1

1

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.)

philipxy
  • 14,867
  • 6
  • 39
  • 83
  • "Calculating domain dependent/unsafe query results for finite domains is straightforward" . So in my above example domain is finite and I can list out all tuples right making it finite and safe? – Zephyr Jul 05 '17 at 12:20
  • What does 'list out all tuples" mean? I just said that "extra operators" are needed to calculate finite unsafe query results. And I said safe queries are ones that can be calculated using the operators that *are* in the relational algebra. So how are you expecting "list" them *within* the relational algebra? Please try what the PS suggests. Notice that "difficult to find" is a rhetorical euphemism for "impossible to find". PS You are taking a class. They gave you references. Read them. – philipxy Jul 05 '17 at 12:30
  • By listing out all tuples I mean all tuples except the one in the relation i.e (1,20) and (2,25) – Zephyr Jul 05 '17 at 12:35
  • You just defined listing in term of listing. What does listing mean? PS The definition of safely is talking about a particular set of relational operators. You need to "list" using those. That set doesn't include an operator to make a relation given domain values. If you *had* the obvious operator then you could write an expression whose value holds all possible tuples A, and you could calculate {t | NOT R(t)} via A MINUS R. But you changed the operator set, so you changed what "safe" meant. And that "safe" would not be *useful* because its queries can involve "big" computations--eg for A. – philipxy Jul 05 '17 at 12:47
  • Yeah, A minus R was what I meant. I didn't understand what do you mean by changing the operator set. And I know that it is not useful as it involves big computations but still it was possible. – Zephyr Jul 05 '17 at 13:15
  • "I didn't understand what do you mean by changing the operator set." is not clear/gramatical. If you mean, 'I didn't understand what you meant by changing the operator set (but now I do), ok. But if you are saying something else, like asking the question, 'what do you mean by changing the operator set', just clarify so I can respond. PS As far as I can see everything in these comments is already in the answer. Eg I even explicitly remind that it matters what "relation algebra" means. (Which is redundant, because *of course* it matters.) – philipxy Jul 05 '17 at 13:31
  • I meant " what do you mean by changing operator set" – Zephyr Jul 05 '17 at 14:18
  • I meant "changing the meaning of 'relational algebra' (a certain set of operators) (to include further operators)". But if you cannot see that then you need to spend more time (re)reading and comprehending what you are reading. (See "the extra operators needed" in my answer.) (What else could it mean? I said "If you had the obvious operator"--ie added it to the set of operators, ie changed the set of operators that 'relational algbra' referred to in the definition.) – philipxy Jul 05 '17 at 15:55