Search code examples
databasedomain-calculus

About query written in Domain Relational Calculus


I am trying to learn Domain relational calculus. Considering the below relations and queries, why can't we write for{<c>|< b, l, c, a> ∈ borrow ∧ a>1200} the second question? I have a feeling that it has something to do with whether the query is safe, but how come the answer for question one works? I don't know what exactly is wrong. Could you please help to explain? Many thanks! enter image description here enter image description here Source from http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/Chapter3/node18.html#SECTION00142000000000000000 and the relations it refers to is here http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/Chapter3/node8.html#SECTION00121000000000000000


Solution

  • Remember, that the definition of query in Domain Relational Calculus

    {<x1, ..., xn> | P(<x1, ..., xn>)}
    

    says that the variables x1, ..., xn that appear to the left of ‘|’ must be the only free variables in the formula p(...). In your example, variables b,l,a are not bound and remain free. In the correct answer, the existence quantifier binds them.