Tuple and Domain Relational Calculus

TUPLE RELATIONAL CALCULUS

The tuple relational calculus is a non-procedural query language. It describes the desired information without giving a specific procedure for obtaining that information. It is the set of all the tuples t such that predicate P is true for t. We use t[A] to denote the value of tuple t on attribute A. It also uses quantifiers:
∃ t ∈ r (Q(t)) = there exists a tuple in t in relation r such that predicate Q(t) is true.
∀ t ∈ r (Q(t)) = Q(t) is true for all tuples in relation r.

Queries-
{ v : H | f(v) }

where v is a tuple variable, H a header and f(v) a formula in F[S,type] where type = { (v, H) } and with v as its only free variable. The result of such a query for a given database db over S is the set of all tuples t over D with dom(t) = H such that f is true for db and val = { (v, t) }.

Examples of query expressions are:

  • { t : {name} | ∃ s : {name, wage} ( Employee(s) ∧ s.wage = 50.000 ∧ t.name = s.name ) }
  • { t : {supplier, article} | ∃ s : {s#, sname} ( Supplier(s) ∧ s.sname = t.supplier ∧ ∃ p : {p#, pname} ( Product(p) ∧ p.pname = t.article ∧ ∃ a : {s#, p#} ( Supplies(a) ∧ s.s# = a.s# ∧ a.p# = p.p# ) 


DOMAIN RELATIONAL CALCULUS

It is the second form of relational calculus, called domain relational calculus, which uses domain variables that take values from the domain of an attribute, rather than values for an entire tuple. It serves as the theoretical basis of the widely used QBE language just as relational algebra serves as the basis for the SQL language. 

Notation-

 { a1, a2, a3, ..., an | P (a1, a2, a3, ... ,an)}  

Where a1, a2 are attributes  P stands for formula built by inner attributes.

Queries Example-

{< article, page, subject > |  ∈ javatpoint ∧ subject = 'database'}  

Output: This query will yield the article, page, and subject from the relational java t point where the subject is a database.

Post a Comment

0 Comments