Relational Calculus

Tuple Relational Calculus

  • It is a non-procedural query language

  • This means that it will mention the required information without specifying the procedure to obtain it

  • An expression in tuple relational calculus is denoted as follows: {t | P(t)}

  • In other words, it is the set of all tuples t such that predicate P is true for t

  • t is a tuple variable and t[A] denotes the value of tuple t for attribute A

  • t \in r denotes that tuple t is in relation r

  • The predicate can contain:

    • A set of attributes and constants

    • A set of comparison operators: (<, ≤, =, ≠, >, ≥)

    • A set of connectives: and (∧), or (v)‚ not (¬)

    • An implication (⇒): x ⇒ y, i.e. if x if true, then y is true

      x ⇒ y ≡ ¬x v y

    • A set of quantifiers:

      \exists t\inr (Q (t)) ≡ "there exists" a tuple t in relation r such that predicate Q(t) is true

      \forall t\inr (Q (t)) ≡ Q(t) is true "for all" tuples t in relation r

  • Ex. Finding ID, name, dept_name and salary of all instructors who have salary greater than 80000: {t | t ∈ instructor ∧ t [salary] > 80000}

Domain Relational Calculus

  • It is a non-procedural language as well

  • It is as powerful as tuple relational calculus

  • An expression in domain relational calculus is denoted as follows: {<x1,x2,...xnx_1, x_2, ... x_n>|P(x1,x2,...,xnx_1, x_2, ..., x_n)}

    where x1,x2,...,xnx_1, x_2, ..., x_n are domain variables and P is the predicate

  • Ex. Finding ID, name, dept_name and salary of all instructors who have salary greater than 80000:

    {<i, n, d, s> | <i, n, d, s> ∈ instructor ∧ s > 80000}

Last updated