Skip to content
Get App

Tuple Relational Calculus (Formal Definition)

Introduction to tuple relational calculus in DBMS, covering formal definitions, query formulation, and predicate logic basics.

Key Takeaways

  • Tuple relational calculus is a non-procedural query language focusing on what data is required rather than how to retrieve it.
  • Queries in tuple relational calculus are expressed as formulas built from atoms involving tuple variables, attributes, and constants.
  • Free and bound variables are distinguished by the presence of quantifiers, which are essential in query formulation.
  • Logical equivalences and predicate calculus principles underpin the construction and interpretation of tuple relational calculus formulas.
  • Safe expressions are necessary in tuple relational calculus to avoid infinite or undefined query results.

What the video covers

  • Introduction to the course continuation on DBMS focusing on relational calculus after covering basics like ER model and relational algebra.
  • Explanation of relational algebra as a procedural language versus relational calculus as a non-procedural query language.
  • Detailed introduction to tuple relational calculus and its query structure involving tuple variables and predicates.
  • Clarification of free and bound tuple variables with examples involving existential and universal quantifiers.
  • Description of how tuple relational calculus formulas are constructed from atoms and how they relate to relations and attributes.
  • Examples showing the use of constants in formulas to address specific query conditions, such as salary comparisons.
  • Discussion on logical operators and equivalences in predicate calculus applied to tuple relational calculus formulas.
  • Explanation of safe versus unsafe expressions in tuple relational calculus to ensure finite query results.
  • Use of quantifiers (existential and universal) and their logical equivalences in formulating queries.
  • Summary emphasizing the predicate calculus foundation of tuple relational calculus and its components like attributes and constants.

Answers

Questions about this video

What is the main difference between relational algebra and tuple relational calculus?

Relational algebra is a procedural query language where you specify the sequence of operations to get the result, whereas tuple relational calculus is non-procedural, focusing only on what data is required without specifying how to retrieve it.

What are free and bound variables in tuple relational calculus?

A free variable is a tuple variable not associated with any quantifier, while a bound variable is one that is quantified by existential or universal quantifiers within the formula.

Why is it important to distinguish between safe and unsafe expressions in tuple relational calculus?

Safe expressions ensure that queries produce finite and well-defined results, preventing infinite relations or undefined outputs that can arise from unsafe expressions.

Full Transcript — Download SRT & Markdown

00:06
Speaker A
Hello everyone, wonderful greetings for the day. Are you wondering to hear a new voice here? From now on, I'll be your instructor and would like to take this wonderful course on DBMS forward from relational calculus since we have already learned the basics
00:23
Speaker A
of DBMS, the database system architecture, ER model, relational database model, relational algebra, and other basic stuff. We shall proceed with relational calculus. In the coming videos, we will focus on important DBMS topics like the relational calculus, both the tuple
00:42
Speaker A
relational calculus and the domain relational calculus. We will formulate some queries in SQL, the structured query language, normalization, transactions and transaction control, concurrency control, file structures, indexing and hashing, and whatnot. Let's start this wonderful journey from here on. In today's
01:02
Speaker A
presentation, we are going to focus on the tuple relational calculus with the formal definition. We have already seen relational algebra, where relational algebra is a procedural language. What do we mean by a procedural language? Because whenever we want some
01:18
Speaker A
output, we need to give the sequence of procedures that generates the answer to our queries. But relational calculus, in contrast, is a non-procedural query language. It means if we want to get the desired information, we need not give the
01:33
Speaker A
complete sequence of procedures in order to get that information. In simple terms, we can simply mention what is required, how it should be taken, and the system will take care of it. Say in relational algebra, we need to explicitly mention
01:47
Speaker A
what is required and how to get those data, but in relational calculus, we can mention only what is required, and how it is done, we need not worry about it. And how a query structure looks here in relational calculus, to be precise, the
02:01
Speaker A
tuple relational calculus. The query in tuple relational calculus looks like this. What do we mean by this? It means the set of all tuples such that the predicate is true for that tuple t. And it's important to know about what is
02:16
Speaker A
a free variable and what is a bounded variable. In tuple relational calculus, we call a variable a free variable unless it is quantified by an existential or universal quantifier. Existential means there exists an x such that is an existential quantifier.
02:34
Speaker A
Universal quantifier means for every x or for all x. I'll just give you an example. In this example, this t is a tuple variable, and this tuple variable belongs to the instructor. And if there exists another tuple variable y which belongs to the
02:51
Speaker A
department such that the department name is the same on the tuple variable d and the department name on the tuple variable y. And this is an example query in tuple relational calculus. No worries, let's not go deep into the details now. In this
03:06
Speaker A
presentation, we are focusing on the basic level. So what is this t? This t and y are tuple variables. In this example, if you note here, this t is a free variable because this tuple variable t is not
03:19
Speaker A
bound by any quantifier, whereas this y is a bound variable because this y is actually quantified by the existential quantifier. It means there exists y such that. Let's now see how to formulate a tuple relational calculus formula. See, we want our queries to be answered by
03:39
Speaker A
the system. Whatever we write as a query, that is basically built up of formulae, and formulae are built out of atoms. Shortly, we are going to see what is a formula and how atoms constitute a formula. And in this presentation, we are
03:55
Speaker A
going to understand what is a formula, how we can write a formula, how multiple formulas can be combined together, when we will call a formula a valid formula, and when we write an expression using multiple formulas, we also want
04:09
Speaker A
to check whether that expression is a safe expression or not. Let's come to the point. A tuple relational calculus formula is built up out of atoms. How? I'll explain this. When we say that s belongs to r, it means this r is the relation and s
04:29
Speaker A
is a tuple variable. So if you note here, we have atoms like s belongs to r, and combining all these, we get a formula. And we have formulas like this also. When we say this s of x, we can use some comparative operators
04:46
Speaker A
and we can use the other tuple variables. In this example, this x is an attribute on which the tuple variable s is defined. On this side, if you note, this y is an attribute on which the tuple variable u is defined. So if you take a
05:01
Speaker A
relation, say we'll take a relation r, obviously this relation will be comprised of attributes and tuples, where we call the tuples as rows and we call the attributes as columns, where this x and y are referred to be attributes.
05:16
Speaker A
I mean, they are the columns, and s and u are referred to as the tuple variables. Is there any need that a tuple relational formula should always have a tuple variable on this side and this side? No, it need not be the case. The right-hand side
05:31
Speaker A
may also be a constant. Say, for example, in this case, we have an attribute x that is defined on the tuple variable s, but on the right-hand side, we can see c, a constant, because there are some
05:43
Speaker A
situations where we may need to address a specific condition. For example, we want to find out the list of all employees who are drawing the salary of ten thousand dollars. In this case, the right-hand side should be ten thousand dollars.
05:58
Speaker A
And here are the various tuple relational formulas. We will see more about the atoms. Basically, an atom is a formula. So we are talking about the relational calculus. Actually, they are built upon the predicate calculus. If we say p1 is a formula,
06:15
Speaker A
then so are negation of p1 and p1. This is a simple formula. For example, if p1 and p2 are formulas, then so are p1 or p2, p1 and p2, and p1 implies p2. These are all possible only when p1 and p2 are
06:33
Speaker A
formulas. We have just seen what is a formula in the previous slide. If you still need some clarity, I request you to watch the previous slide and come back to this place so that you will understand about formulas. Let's continue dealing with
06:47
Speaker A
this. If p1 of s is a formula containing a free tuple variable s, then we will call a tuple variable a free tuple variable if it is not associated with any of the quantifiers, whether it is an
07:01
Speaker A
existential or universal quantifier. If p1 of s is a formula containing a free tuple variable s and we have a relation r, r is a relation, then there exists s that belongs to relation r if p1 of s is
07:17
Speaker A
true, that is, this formula is true. And not only that, we can also use for all or for every s belongs to r, this p1 of s is true. I mean, this formula is true. In simple terms, if p1 of s is a formula
07:32
Speaker A
which contains a tuple variable s and r is a relation, then we can use both quantifiers, existential quantifier as well as universal quantifier. And if we have two formulas p1 and p2, then this is equivalent to negation of negation of p1
07:49
Speaker A
or negation of p2. Just see like this. If we are bringing this inside, negation of negation gets cancelled. We will end up with p1 only. This negation brings this r into and, and then this negation makes this negation cancel. So negation of
08:04
Speaker A
negation p1 or negation p2 will give p1 and p2 since p1 and p2 are formulas. For all t that belongs to r, p1 of t, this is also equivalent to negation of if there exists t that belongs to r which is
08:21
Speaker A
negation of p1 of t. For example, if we are bringing negation on both the sides, for all quantifier will become if there exists quantifier, and here p1 of t becomes negation of p1 of t. This is how we can build formulas. p1 implies p2 is
08:37
Speaker A
equivalent to negation of p1 or p2. Before we step into the next topic, we will quickly revisit the points in a glimpse. So basically, this tuple relational calculus contains formulas that satisfy the predicate calculus formulas. So basically, a formula in a
08:54
Speaker A
tuple relational calculus will have a set of attributes and constants. For example, if we are referring to salary equal to 10,000, where salary is the attribute and 10,000 is the constant. Say we are comparing salary is equal to 10,
09:09
Speaker A
000. We can also use other operators like less than, less than or equal to, equal to, not equal to, greater than.
09:25
Speaker A
even if we want a negate then we can go for negation operation which gives the not of the value so true means false false means true as mentioned this is a predicate relational calculus so this is also satisfying the implication rule
09:38
Speaker A
which uses p1 implies p2 in other words if p1 then p2 and coming to the last one since double relational calculus follows the predicate approach then obviously this will also use the quantifiers existential and universal there exists such that and for all or
09:57
Speaker A
for every before we sign out let's see the safety of expressions one of the serious issues to be addressed is writing a proper double relation calculus expression see if we don't handle the expressions well we may end up in generating an infinite relation
10:14
Speaker A
because a tuple relational calculus is basically a non-procedural language where we will mention only what is required so if we don't write the expression properly we may end up in generating an infinite relation for example in this case if you note we are
10:31
Speaker A
writing an expression like this as a set of all tuples where the predicate is which is not the tuple belongs to the instructor and we use a negation here the problem with this is we should not allow such kind of expressions because
10:46
Speaker A
there may be many tuples that are not in the instructor relation but what we have written we have written set of all tuples that are not in the instructor relation the problem is there may be many tuples that are not in the
10:58
Speaker A
instructor relation and we should not allow any such expressions and we call such expressions as unsafe expressions and how to handle these unsafe expressions we are introducing the concept of domain of a tuple relational formula how this domain solves the
11:15
Speaker A
problem of unsafe expressions suppose if we are defining a domain like this domain of p it means the set of all values that appear in an expression will be there in one or more relations and this guarantees the finite results say
11:31
Speaker A
if we are defining a domain and that domain is containing the set of all values that appear in an expression then we will definitely not end up in infinite relations so the expression when we write using domains should
11:44
Speaker A
guarantee finite results i'll give you one example say if we are writing an expression like this t belongs to instructor and t of salary is greater than 80 000 and that is actually inside a domain now what do we mean by this it
11:58
Speaker A
means this is the set containing 80 000 and all the values appearing in any attribute of any tuple in the instructor relation so this guarantees us from ending up in an infinite relation so we can simply say the set of all
12:14
Speaker A
tuples such that the predicate on the tuple is true is safe if all values in the result are from the domain domain of p we will see more about domains in the domain relational calculus topic for now let's have only the basics and that's it
12:29
Speaker A
guys i hope now you understood the basics of double relational calculus in the next presentation we will see some queries in tuple relational calculus i'll see you in the next presentation and thank you for watching [Music] [Applause] [Music]
12:53
Speaker A
you
Topics:tuple relational calculusDBMSrelational calculusrelational algebranon-procedural query languagepredicate calculusexistential quantifieruniversal quantifiersafe expressionsquery formulation

Get More with the SozAI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries and speaker detection. 30 minutes free.

Or transcribe another YouTube video here →