Relational calculus is non procedural, it is a language for expressing what we want without expressing. Relational calculus has a variable. For tuple relational calculus, the variable ranges over the tuples of a relation. For domain relational calculus, the variables ranges over the values of the domain.
Tuple Oriented Relational Calculus
The basic construct of tuple calculus is a tuple calculus expression. Tuple Calculus expressions are made up of following constructs or elements.
- Tuple Variable :
A tuple variable is a variable that ‘ ranges over’ some named relation i.e. a variable whose only permitted values are tuples of that relation.
Tuple variables are denoted by uppercase letters. For example T, U, V etc. If the tuple variable T represents tuple t (at given time), then the expression T. A represents the A component of t( at that time), where A is an attribute of the relation over which T Ranges.
- Conditions :
Conditions are of the form x * y, where * is any relational operator =, !=, <, <=, >, >= and at least one of the x & y is an expression of the form T.A & other is either a similar expression or a constant.
- Well Formed Formulas (WFFs) :
A WFF is constructed from conditions, Boolean operators ( AND, OR, NOT) and quantifiers (∃, ∀) according to the following rules:
- Every condition is WFF.
- If f is a WFFs, then (f) and NOT(f) are also WFFs.
- If f and G are WFFs, then (f AND g) and (f oOR g) are also WFFs.
- If f is WFF in which T occurs as a free variable then ∃T(f) are WFFs.
- Nothing else is a WFF.
- Criteria for free and bound variables :
- Within the condition all tuple variable occurrences are free.
- Tuple variable occurrence in the WFFs(f), NOT(f) are free/bound according as they are free/bound in f.
- Tuple variable occurrences in the WFFs(f AND g), (f OR g) are free/bound according as they are free/bound in f or g.
- Occurrence of T that are free in f are bound in the WFFs ∃T(f), ∀ T(f). Other tuple variable occurrence in f are free/bound in these WFFs as they are free/bound in f.
- Tuple calculus expression :
Form of expression is
T.A, U.B, ……., V.C [WHERE f]
Where T, U, …….., V are tuple variable; A, B, ……C are attributes of the associated relation; & f is a WFF containing exactly T, U, ……, V as free variables. The value of this expression is a projection of that subset of the cartesian product T x U x …..x V for which f evaluates to true. If “where f” is omitted then the value is a projection of entire cartesian product.
Domain Oriented Relational Calculus
The domain oriented relational calculus differs from the tuples calculus in that its variable ranges over domain rather than relations.
Expressions of the domain calculus are constructed from the following elements.
- Domain Variables :
Domain variables are denoted by uppercase letters. For example D,E,F etc. Each domain variable is constrained to range over some specified domain.
- Conditions :
Conditions can takes two forms :
- Simply comparisons :
Form is x * y, same as for the tuple calculus, except that x and y are now the domain variables ( or constants).
- Membership Condition :
The form is R (term, term, …..). Here R is a relation and each “term” is a pair A : V, where A is an attribute of R and V is either a domain variable or a constant.
- Simply comparisons :
- Well Formed Formulas (WFFs):
Same as tuple calculus section but with revised definition of condition
- Free and Bound Variables :
Same as tuple calculus.
- Domain Calculus Expressions :
A domain calculus expression is then an expression of the form D, E, ….., F [WHERE f] where D, E, ….., F are domain variables and f is a WFF containing exactly D, E, ….., F are free variables. The values of this expression is that subset of the cartesian product D x E x …. x F (where D, E, ….., F range over all their possible values) for which f evaluated to true – or if “WHERE f” is omitted that entire cartesian product.
Questions on Tuple Relational Calculus :
Consider the following Relations : 1. Suppliers (SID, Sname, Rating) 2. Parts (PID, Pname, Color) 3. Catalog (SID,PID, Cost)
Query 1 : SID of suppliers whose rating is greater than 10.
Query 2 : Sname of suppliers who supplied some part.
Query 3 : Sname of suppliers who supply some red part.
Query 4 : SID suppliers who supplied red part.
Query 5 : SID of suppliers who supplied some red part or Green part.
Query 6 : SID of suppliers who supplied some red and some Green parts.
Query 7 : SID of suppliers who supplied every part.
|Questions Based on Relational Algebra (Gate Questions Included) -Part 2||What is a Transaction in DBMS ?|
Incoming search terms:
- difference between tuple relational calculus and domain relational calculus in dbms
- Relational calculus in dbms
- relational calculus examples with solutions
- diffrence between tuple relational calculas and domain relational calculas
- tuple relational calculus solved examples
- tupl reation cacules in dbms syntax example result
- rtypes elational calculus in dbms
- free bund tuple variables
- difference between tuple relational calculus and domain relational calculus
- difference between tuple and domain relational calculus in tabular form