Questions tagged [relational-algebra]

For questions about the algebra of relational model theory, involving operations like Projection (π) Selection (σ), Rename (ρ), and Natural join (⋈).

Relational algebra, first created by Edgar F. Codd while at IBM, is a family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it.

The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL.

The five basic operators of Codd's algebra are:

  • selection
  • projection
  • Cartesian product
  • set union
  • set difference

References:

46 questions
10
votes
1 answer

Convert query in words to relational algebra

I have a follow-up question to a question I have previously asked on SO. Instead of the query from my initial question, I want to convert the following into relational algebra: List the names and phone numbers of the bidders who are not always…
bawse
  • 201
  • 1
  • 3
8
votes
2 answers

How are joins Commutative and Associative?

I have read all over the place that joins are associative and commutative. So A join (B join C) should be the same as (A join C) join B. But I have a really hard time understanding how this can be so. Assume that A has a property in common with B…
Justin
  • 183
  • 1
  • 1
  • 4
5
votes
1 answer

the verbosity of "(SELECT * FROM A)"?

This might be a novice question. But sometimes, I find it necessary to use things like (SELECT * FROM A) in doing relational algebra in SQL (instead of using the relation A itself). For example, when trying to work on the UNION of two relations A…
tinlyx
  • 3,810
  • 14
  • 50
  • 79
5
votes
2 answers

Creating relationships between tables that where not specified in the given UML diagram

Good evening! I'm working on designing my very first actual database from the following UML class diagram (in French unfortunately): I'm at the point of creating the relational sketch of it which I created this way: Yet, it creates some issues…
4
votes
1 answer

Do my relational algebra operations produce the desired results?

I have these tables: Sailors sid sname rating age --- ------ ------ --- 22 dustin 7 45 31 john 8 55 58 ben 10 35 Boats bid bname color --- --------- ----- 101 …
windy401
  • 169
  • 2
  • 8
4
votes
1 answer

Theta join explanation

Take the following relational schemes: R(A, B, C) S(D, E, F) where the attributes A and D are the primary keys, respectively. Assume to have an instance r of R with n tuples and an instance s of S with m tuples. Moreover, assume to have a…
user962800
  • 179
  • 1
  • 4
3
votes
2 answers

Long Relational Algebraic expression provided than actually required

Schema Diagram: Make a list of project numbers for projects that involve an employee whose last name is ‘Smith’, either as a worker or as a manager of the department that controls the project. The given solution is : However, I believe that…
Argon
  • 133
  • 3
3
votes
1 answer

Declarative and Procedural Query Languages

In the book Database System Concepts 6th Edition, Chapter 2 (Relational Algebra), it states that there are three formal query languages, the relational algebra, the tuple relational calculus and the domain relational calculus, which are declarative…
3
votes
1 answer

Proof that Inner Join is Commutative

I'm trying to prove to myself that the order of inner joins doesn't matter, but, in an abstract sense, I'm coming up with nothing. How would one go about proving that the order of a set of INNER JOINs that are executed to turn many tables into a…
joe55
  • 33
  • 3
3
votes
2 answers

Minimum and Maximum Number of Tuples

Consider Relations R and S where are R is having m tuples and S is having n tuples . m<=n . What would be the minimum and maximum number of tuples in each of the following cases (Assume that nothing is mentioned about key constraints) R union S R…
pC_
  • 33
  • 1
  • 1
  • 4
2
votes
1 answer

Does R ⋈ (S ∪ T) = (R ⋈ S) ∪ (R ⋈ T) hold for bag semantics?

Does R ⋈ (S ∪ T) = (R ⋈ S) ∪ (R ⋈ T) hold for relational algebra bag semantics? I don't know whether this holds for bag semantics for join and union.
2
votes
1 answer

Unsure how to formulate Relational Algebra Query

The question asks: Given two relations A and B, Both of which are over attributes x and y. Write a query under bag semantics that returns A if B is empty and B otherwise The way I interpreted this question was "empty" meant there were no tuples in…
user249280
2
votes
0 answers

Relational Algebra: how to express the combination of aggregation and projection?

Here I have a table, I would like to query the average salary of departments, the SQL statement should be select dept_name, avg(salary) from employee I try to express this SQL in relational algebra. My assumption is as follows. You can see that…
2
votes
0 answers

How to write group by and having in a relational algebra interpreter?

I am practising writing relational algebra (RA) expressions in RA interpreter from Duke, but I can't figure out how to represent group by or having (from SQL). I have this expression, but I need to group it by countries, and get only those that have…
2
votes
0 answers

Converting from domain calculus to relational algebra

At university I have been given these three relations: Customer (Name, City, Account) Offer (Product_Description Supplier, Price) Order (Name, Product_Description, Quantity, Supplier) and this domain calculus: {Name, City | ∃ Account,…
Anes
  • 63
  • 1
  • 3
1
2 3 4