Tuple and Domain Relational Calculus in DBMS
Tuple Relational Calculus:
The primary construct of the tuple-oriented relational calculus is the tuple calculus expression. It is essentially a non-procedural definition of some relation in terms of some given set of relations. Such an expression can be used to define the result of a query or the target of an update or a view, etc.
The expression of the tuple calculus is constructed from the following elements:
i. Tuple variables
ii. Conditions
iii. Well-formed formulas (WFFs)
Tuple Variables:
The variables in relational calculus are like variables in programming languages in that they are restricted by their types T, U, and V….. Each tuple variable is constrained to the range over some named relation. If tuple variable T represents tuple t, then the expression T. A represents the component A of t, where A is an attribute of the relation over which T ranges.
Conditions:
Conditions of the form x*y, where * in any one of the relation operators =, <>, <, >, >=, and at least one of x and y is an expression of the form T>A and the other is either a similar expression or a constant.
Well-formed formulas (WFFs):
The WFFs should be those sequences of symbols that are unambiguous and make sense. This can be ensured by stating some rules for the construction of WFFs.
A WFF is constructed from conditions, Boolean operators (AND, OR, NOT) and quantifiers. According to rules F–F5 mentioned below:
F1: Every condition is a WFF.
F2: If f is a WFF, then so are f and NOT (f).
F3: If f and g are WFFs then so are (f AND g) and (f OR g).
F4: If f is a WFF in which T occurs as a free variable then T (f) and T(f) are WFFs.
F5: Nothing else is a WFF.
The tuple relational calculus is based on specifying the number of tuple variables. Each tuple variable ranges over a particular database relation. It means that the variable may take as its value any individual tuple from that relation.
Domain Relational Calculus:
The domain relational calculus differs from the tuple calculus in that its variables ranges over domains rather than relations. Expressions of the domain calculus are constructed from the following elements.
i. Domain variables
ii. Conditions
ii. Well-formed formulas (WFFs)
Domain variables:
Each domain variable is constrained to range over some specified domain.
Conditions:
Conditions can take two forms. These are:
i. Simple comparison of the form x*y, as for the tuple calculus, except that x and y are now domain variables.
ii. Membership conditions of the form X. Here X is a relation and each “term” is a pair A: V, where A, in turn, is an attribute of X and V is either a domain variable or a constant.