Trying to understand "Only" and "All" constraints in Tuple Relational Calculus

203 Views Asked by At

Suppose we have three schemas:

Instructor(id:integer, name:string, age:integer, salary:real)
Works(eid:integer, did:integer, pct-time:integer)
Dept(did:integer, budget:real, managerid:integer)

Let me start this by showing two similar problems:

a) Find the manager ids of instructors who manage all departments with budgets greater than $1 million.

soln1

b) Find the manager ids of instructors who only manage departments with budgets greater than $1 million.

soln2

My problem is that I cannot figure out why the u=[managerid] = s[managerid] and u[budget] > 1000000 constraints are switched. Can someone explain in words why the order affects the result?

1

There are 1 best solutions below

0
On

The calculus for (a) asks for instructor rows where if a department is big then they manage it.

The calculus for (b) asks for instructor rows where if they manage a department then it is big.

The phrasing I've chosen arises by using English words that paraphrase the logical operators. It happens that if you make the English more precise (accounting for "for all" & "for some"/"there exists" and naming "them" & "it") the structures are still parallel.

As to "why" we can describe your English phrasings as differing by the changing and moving of a word and as having the same meanings as my English, that's just "because" that's how English is. These queries are effectively defining the meaning of phrases "subjects verb all objects" and "subjects only verb nouns".

why the [...] constraints are switched
why the order affects the result

A "why" question in math doesn't make sense. We assume statements, then a whole bunch of things are true & false. There is no "why". We could reasonably interpret "why ..." in that context as "what is a proof of .."? But you don't mean that here. The English statements differ, so why wouldn't the queries differ? The queries differ, so why wouldn't the results differ? What do you mean, "why"? Why what, exactly? Why not?