Semantics

Semantics of Eval(E, DB) is given by appeal to range restricted relational calculus with multiset semantics

Answers(Q, DB) - denotes the answers to RC query Q over DB

  1. Si is a table with arity Cnum(Ei) and extension Eval(Ei, DB)
  2. x¯=x1,,xn

For Ri/nρ

  1. Relation name: Eval(Ri, DB) = Answers({(x¯)|Ri(x¯)},DB) where Cnum(Ri) = n
  2. Constant: Eval(c) = Answers({(x)|x=c}, DB) where Cnum(Ri) = 1
  3. Selection: Eval(σ#i=#j(E1), DB) = Answers({(x¯)|S1(x¯)(xi=xj)}, DB) where Cnum(σ#i=#j(E1)) = Cnum(E1)
  4. Projection: Eval(π#i1,...,#im(E1)) = Answers({(xi1,,xim)|xim+1,,xin}, DB) where Cnum(π#i1,...,#im(E1)) = m
  5. Duplicate elimination: Eval(elim E1, DB) = Answers({(x¯)|elim S1(x¯)}, DB) where Cnum(elim E1) = Cnum(E1)
  6. Cross product: Eval(E1×E2, DB) = Answers({(x¯,y¯)|S1(x¯)S2(y¯)},DB) where Cnum(E1×E2) = Cnum(E1) + Cnum(E2)
  7. Multiset Union: Eval(E1E2, DB) = Answers({(x¯)|S1(x¯)S2(x¯)}, DB) where Cnum(E1E2) = Cnum(E1)
  8. Multiset Difference: (Except all) Eval (E1E2, DB) = Answers({(x¯)|S1(x¯)¬S2(x¯)}, DB) where Cnum(E_1 - E_2) = Cnum(E1)
  9. Multiset Difference: (Alternative not exists) Eval (E1E2, DB) = Answers({(x¯)|S1(x¯)¬(S1(x¯)S2(x¯))}, DB) where Cnum(E_1 - E_2) = Cnum(E1)
Multiset difference with alternative semantics can be used when translating subqueries in SQL conditions