-1

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?

philipxy
  • 14,867
  • 6
  • 39
  • 83
noob
  • 1
  • 1
  • Hi. Is seems like the problem is maybe you think the two English phrasing describe the same thing? Please confirm. They don't. What are some other ways you would express those sentences in English? Since they don't, why should the queries be the same? What do think the queries ought to be, and why? Since they have to differ *somehow*, why does it matter how? Yes, maybe the query change parallels the English change--but, why wouldn't it? Please google 'stackexchange.com homework' & [ask]. PS Many "all" queries involve variants of [tag:relational-division]. – philipxy Oct 24 '17 at 06:58
  • Please edit your question to [use text for text; don't use images/links](https://meta.stackoverflow.com/a/285557/3404097). Use the name of a symbol or the name of its operator or google 'unicode' with one of those. – philipxy Oct 24 '17 at 06:59
  • I understand the difference in the phrasing. The problem is I can't translate that as a TRC query. I apologize about the links, I am still new to SE and am learning how to properly format my questions. I will edit my question to use text for text later. – noob Oct 24 '17 at 07:09

1 Answers1

0

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?

philipxy
  • 14,867
  • 6
  • 39
  • 83