Relation Algebra - Relational Calculus

In summary: Great! Thank you! (Sun)In summary, the conversation discusses the equivalent expressions in relational calculus for various expressions in relation algebra, including projection, selection, union, intersection, set difference, cartesian product, natural join, and division. The conversation also raises a question about whether the expressions should be written as sets or tuples, but concludes that as long as the meaning is clear, either format is acceptable.
  • #1
mathmari
Gold Member
MHB
5,049
7
Hey! :giggle:

Give for the following expressions of relation algebra the equivalent expression in relational calculus.
1. $\sigma_{B=A}(R(A,B,C))$
2. $\pi_{B,C}(R(A,B,C))$
3. $R(A,B,C)\cup S(A,B,C)$
4. $R(A,B,C)\cap S(A,B,C)$
5. $R(A,B,C)\setminus S(A,B,C)$
6. $R(A,B,C)\times S(D,C,E)$
7. $R(A,B,C)\Join S(B,C,E)$
8. $R(A,B) \div S(B)$I have done the following :

1. $\{x_1, x_2, x_3\mid R(x_1, x_2, x_3)\land (x_2=x_1)\}$
2. $\{y_1, y_2\mid \exists x_1\exists x_2\exists x_3 \left (R(x_1,x_2,x_3)\land y_1=x_2\land y_2=x_3\right )\}$
3. $\{x_1, x_2, x_3\mid R(x_1, x_2, x_3)\lor S(x_1, x_2, x_3)\}$
4. $\{x_1, x_2, x_3\mid R(x_1, x_2, x_3)\land S(x_1, x_2, x_3)\}$
5. $\{x_1, x_2, x_3\mid R(x_1, x_2, x_3)\land \neg S(x_1, x_2, x_3)\}$
6. $\{x_1, x_2, x_3, x_4, x_5, x_6\mid R(x_1,x_2,x_3) \land S(x_4,x_5,x_6)\}$
7. $\{ x_1, x_2, x_3, x_4 \mid R(x_1,x_2,x_3) \land S(x_2,x_3,x_4)\}$
8. $\{x_1 \mid R(x_1,x_2)\land S(x_2)\}$Is everything correct and complete? :unsure:
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
Hey mathmari!

Shouldn't it be for instance $\{(x_1, x_2, x_3)\mid R(x_1, x_2, x_3)\land (x_2=x_1)\}$? 🤔

Otherwise I think everything is correct. (Sun)
 
  • #3
Klaas van Aarsen said:
Shouldn't it be for instance $\{(x_1, x_2, x_3)\mid R(x_1, x_2, x_3)\land (x_2=x_1)\}$? 🤔

Otherwise I think everything is correct. (Sun)

Ah you mean that we should write them as tuples? :unsure:
 
  • #4
mathmari said:
Ah you mean that we should write them as tuples? :unsure:
Yes. As far as I know, we have to, or it won't be correct syntax for sets.
Then again, it is clear what it means, so there is a chance that in the particular context it is considered to be an acceptable short hand abbreviation... 🤔
 
  • #5
Klaas van Aarsen said:
Yes. As far as I know, we have to, or it won't be correct syntax for sets.
Then again, it is clear what it means, so there is a chance that in the particular context it is considered to be an acceptable short hand abbreviation... 🤔

Ah ok! I wrote the above in that way because I saw the below part in the notes :

1636395916131.png
 
  • #6
mathmari said:
Ah ok! I wrote the above in that way because I saw the below part in the notes :

View attachment 11436
Ok. Then I guess it is just fine. (Sun)
 
  • #7
Klaas van Aarsen said:
Ok. Then I guess it is just fine. (Sun)

Great! Thank you! (Sun)
 

FAQ: Relation Algebra - Relational Calculus

What is Relation Algebra?

Relation Algebra is a mathematical framework used to model and analyze data relationships in relational databases. It consists of a set of operations and rules for manipulating and combining relations, which are essentially tables of data.

What is Relational Calculus?

Relational Calculus is a formal language used to specify and query data in relational databases. It is based on first-order logic and allows users to describe the desired result without specifying how to obtain it, making it a declarative language.

What is the difference between Relation Algebra and Relational Calculus?

The main difference between Relation Algebra and Relational Calculus is that Relation Algebra is a procedural language, meaning it specifies how to obtain the desired result, while Relational Calculus is a declarative language that only describes the desired result. Relation Algebra is also more powerful and expressive than Relational Calculus, but it is less user-friendly.

What are some common operations in Relation Algebra?

Some common operations in Relation Algebra include selection, projection, union, difference, intersection, join, and division. These operations allow users to filter, combine, and manipulate data in a relational database.

How is Relational Calculus used in database systems?

Relational Calculus is used in database systems to specify queries and retrieve data from a relational database. It is the basis for SQL, the most commonly used language for interacting with relational databases. Relational Calculus allows for more flexible and powerful queries compared to SQL, but it is less user-friendly and requires more knowledge of formal logic.

Similar threads

Replies
3
Views
1K
Replies
12
Views
3K
Replies
4
Views
706
Replies
32
Views
5K
Replies
1
Views
2K
Replies
32
Views
1K
Back
Top