ArticleslgStudy

mathematics

Tuple relational calculus

Tuple relational calculus is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Tuple relational calculus rather than just read about it. In short: Tuple calculus is a calculus that was created and introduced by Edgar F. Codd as part of the relational model, in order to provide a declarative database-query language for data manipulation in this data model.

Key takeaways

  • Tuple relational calculus belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Tuple relational calculus to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Tuple relational calculus from memory before moving on to harder problems.

Reference excerpt

Tuple calculus is a calculus that was created and introduced by Edgar F. Codd as part of the relational model, in order to provide a declarative database-query language for data manipulation in this data model. It formed the inspiration for the database-query languages QUEL and SQL, of which the latter, although far less faithful to the original relational model and calculus, is now the de facto standard database-query language; a dialect of SQL is used by nearly every relational-database-management system. Michel Lacroix and Alain Pirotte proposed domain calculus, which is closer to first-order logic and together with Codd showed that both of these calculi (as well as relational algebra) are equivalent in expressive power. Subsequently, query languages for the relational model were called relationally complete if they could express at least all of these queries.

Definition

Relational database Since the calculus is a query language for relational databases we first have to define a relational database. The basic relational building block is the domain (somewhat similar, but not equal to, a data type). A tuple is a finite sequence of attributes, which are ordered pairs of domains and values. A relation is a set of (compatible) tuples. Although these relational concepts are mathematically defined, those definitions map loosely to traditional database concepts. A table is an accepted visual representation of a relation; a tuple is similar to the concept of a row. We first assume the existence of a set C of column names, examples of which are "name", "author", "address", etcetera. We define headers as finite subsets of C. A relational database schema is defined as a tuple S = (D, R, h) where D is the domain of atomic values (see relational model for more on the notions of domain and atomic value), R is a finite set of relation names, and

h : R → 2C a function that associates a header with each relation name in R. (Note that this is a simplification from the full relational model where there is more than one domain and a header is not just a set of column names but also maps these column names to a domain.) Given a domain D we define a tuple over D as a partial function that maps some column names to an atomic value in D. An example would be (name : "Harry", age : 25).

t : C ⇸ D The set of all tuples over D is denoted as TD. The subset of C for which a tuple t is defined is called the domain of t (not to be confused with the domain in the schema) and denoted as dom(t). Finally we define a relational database given a schema S = (D, R, h) as a function

db : R → 2TD that maps the relation names in R to finite subsets of TD, such that for every relation name r in R and tuple t in db(r) it holds that

dom(t) = h(r). The latter requirement simply says that all the tuples in a relation should contain the same column names, namely those defined for it in the schema.

Atoms For the construction of the formulas we will assume an infinite set V of tuple variables. The formulas are defined given a database schema S = (D, R, h) and a partial function type : V ⇸ 2C, called at type assignment, that assigns headers to some tuple variables. We then define the set of atomic formulas A[S,type] with the following rules:

if v and w in V, a in type(v) and b in type(w) then the formula v.a = w.b is in A[S,type], if v in V, a in type(v) and k denotes a value in D then the formula v.a = k is in A[S,type], and if v in V, r in R and type(v) = h(r) then the formula r(v) is in A[S,type]. Examples of atoms are:

(t.age = s.age) — t has an age attribute and s has an age attribute with the same value (t.name = "Codd") — tuple t has a name attribute and its value is "Codd" Book(t) — tuple t is present in relation Book. The formal semantics of such atoms is defined given a database db over S and a tuple variable binding val : V → TD that maps tuple variables to tuples over the domain in S:

v.a = w.b is true if and only if val(v)(a) = val(w)(b) v.a = k is true if and only if val(v)(a) = k r(v) is true if and only if val(v) is in db(r)

Formulas The atoms can be combined into formulas, as is usual in first-order logic, with the logical operators ∧ (and), ∨ (or) and ¬ (not), and we can use the existential quantifier (∃) and the universal quantifier (∀) to bind the variables. We define the set of formulas F[S,type] inductively with the following rules:

every atom in A[S,type] is also in F[S,type] if F1 and F2 are in F[S,type] then the formula F1 ∧ F2 is also in F[S,type] if F1 and F2 are in F[S,type] then the formula F1 ∨ F2 is also in F[S,type] if F is in F[S,type] then the formula ⁠¬F⁠ is also in F[S,type] if v in V, H a header and F a formula in F[S,type[v→H]] then the formula ⁠∃v:H(f)⁠ is also in F[S,type], where type[v→H] denotes the function that is equal to type except that it maps v to H, if v in V, H a header and F a formula in F[S,type[v→H]] then the formula ⁠∀v:H(f)⁠ is also in F[S,type] Examples of formulas:

t.name = "C. J. Date" ∨ t.name = "H. Darwen" Book(t) ∨ Magazine(t) ∀t:{author, title, subject}(¬(Book(t)∧t.author= "C. J. Date" ∧ ¬(t.subject= "relational model")))

Note that the last formula states that all books that are written by C. J. Date have as their subject the relational model. As usual we omit brackets if this causes no ambiguity about the semantics of the formula. We will assume that the quantifiers quantify over the universe of all tuples over the domain in the schema. This leads to the following formal semantics for formulas given a database db over S and a tuple variable binding val : V → TD:

F1 ∧ F2 is true if and only if F1 is true and F2 is true, F1 ∨ F2 is true if and only if F1 is true or F2 is true or both are true, ⁠¬f⁠ is true if and only if F is not true, ⁠∃v:H(f)⁠ is true if and only if there is a tuple t over D such that dom(t) = H and the formula F is true for val[v→t], and ⁠∀v:H(f)⁠ is true if and only if for all tuples t over D such that dom(t) = H the formula F is true for val[v→t].

Queries Finally we define what a query expression looks like given a schema S = (D, R, h):

{ 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:

Semantic and syntactic restriction

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Tuple relational calculus

Start with the simplest possible case. Write down what Tuple relational calculus claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Tuple relational calculus before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Tuple relational calculus ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Tuple relational calculus

In research
Tuple relational calculus appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Tuple relational calculus in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Tuple relational calculus is common in secondary-school and first-year university syllabi. It links to neighbouring topics Logical calculi, Relational model, so understanding it makes those chapters shorter.
In everyday life
Look for Tuple relational calculus outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Tuple relational calculus” →

How to study Tuple relational calculus in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Tuple relational calculus means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Tuple relational calculus out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Tuple relational calculus in simple terms?

Tuple calculus is a calculus that was created and introduced by Edgar F. Codd as part of the relational model, in order to provide a declarative database-query language for data manipulation in this data model.

Why does Tuple relational calculus matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Tuple relational calculus?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Tuple relational calculus.

Tags

  • Logical calculi
  • Relational model

Keep exploring