4 Tuple Relational Calculus
4 Tuple Relational Calculus
usually called ‘Calculus’; rather RC comes from the first order predicate calculus from
the field of Logic. There are two types of RCs – tuple relational calculus (TRC) and
domain relational calculus (DRC). Here the tuple relational calculus is discussed.
In TRC, expressions are of the form {t / (t)}, where t is a tuple variable, i.e. a variable
denoting a tuple of some fixed length and is a formula built from atoms and a
collection of operators to be defined.
i. R(s), where R is a relation name and s is a tuple variable. This atom stands for
the assertion that s is a tuple in relation R.
ii. s[i] u[j], where u and s are tuple variables and is an arithmetic comparison
operator (<, >, =). This atom stands for the assertion that ith component of s
stands in relation to the jth component of u.
iii. s[i] a or a s[i] are same as above; only difference is that a is a constant.
Formulas and free and bound occurrences of tuple variable in these formulas are defined
recursively as follows:
is psi.
Recall {t/ (t)} is a tuple relational calculus expression where t is the only free variable.
Union only makes sense if R and S have the same arity. The variable t is assumed to have
some fixed length.
It means R X S is the set of tuples t of length (r+s) such that there exists u and v, with u
in R, v in S, the first r components of t form u and the next s components of t form v.
Selection : The selection F (R) is expressed by {t/ R(t) F} where F is the formula F
with each operand I denoting the ith component replaced by t[I]
Example Schema 1:
3. R.A. : sname, marks (course = ‘IEP’ sub_title = ‘DBMS’ status = ‘elective’ (STUDENT X STUDY))
Example Schema 2 :
TRC : {t2 / (e) ( e EMP) t.sal > 10,500 t. e_name = e.e_name t.sal = e.sal}