the study of relations (i.e., database tables) and relational operators (join, selection, projection, etc.) as a kind of algebraic structure.
Questions tagged [relational-algebra]
86 questions
29
votes
3 answers
Do subqueries add expressive power to SQL queries?
Does SQL need subqueries?
Imagine a sufficiently generalized implementation of the structured query language for relation databases. Since the structure of the canonical SQL SELECT statement is actually pretty important for this to make sense, I…
Patrick87
- 12,924
- 1
- 45
- 77
18
votes
2 answers
Does the 'difference' operation add expressiveness to a query language that already includes 'join'?
The set difference operator (e.g., EXCEPT in some SQL variants) is one of the many fundamental operators of relational algebra. However, there are some databases that do not support the set difference operator directly, but which support LEFT JOIN…
Ken Li
- 3,106
- 3
- 24
- 38
13
votes
1 answer
Is there an isomorphism between (subset of) category theory and relational algebra?
It comes from big data perspective. Basically, many frameworks (like Apache Spark) "compensate" lack of relational operations by providing Functor/Monad-like interfaces and there is a similar movement towards cats-to-SQL conversions (Slick in…
dk14
- 243
- 1
- 7
8
votes
1 answer
A relational algebra extended to model the full DML ("CRUD") domain
There are multiple references about the relational algebra for modeling queries (SELECT) but I have found very very little on the expanded algebra that would include concepts in all of DML such as INSERT, UPDATE, DELETE and maybe even MERGE,…
Jason Kleban
- 557
- 3
- 12
6
votes
2 answers
Optimizing a join where each table has a selection
Consider the following query:
SELECT Customer.Name FROM Customer
INNER JOIN Order on Order.CustomerId = Customer.Id
WHERE Customer.Preferred = True AND
Order.Complete = False
Let's suppose all of the relevant attributes (Customer.Preferred,…
Xodarap
- 1,538
- 1
- 10
- 17
5
votes
4 answers
When should you use the existential and universal quantifiers for Relational Calculus?
Could someone explain to me WHEN do you use existential and universal quantifiers for Relational Calculus?
Given this schema:
Hotel(hotelNo, hotelName, city)
The expression below gets all hotel names based in London (expressed in Domain Relational…
benscabbia
- 201
- 2
- 8
5
votes
1 answer
"Functional dependencies" with cardinality constraints
Let us write $\{ A_1, \ldots, A_k\} \rightrightarrows^n \{B_1, \ldots, B_m\}$ for a relation $R$ if for all $\langle a_1, \ldots, a_k\rangle$ we have $\left\lvert \pi_{B_1, \ldots, B_m} \sigma_{\bigwedge_{i = 1}^k A_i = a_i} R\right\rvert \le n$…
Kristóf Marussy
- 171
- 2
4
votes
2 answers
Relational algebra and indexes
How might indexes be represented in the context of relational algebra?
How would an optimizer transform a query to use indexes?
t123
- 203
- 1
- 5
4
votes
1 answer
Difference between the Cartesian product in set theory and in relational algebra
What's the difference between the Cartesian product in set theory and in relational algebra?
The Cartesian product in set theory is defined as:
$$A \times B = \{(a, b) \mid (a \in A) \land (b \in B)\}$$
I think this is exactly how it works in…
4
votes
1 answer
What is OUTER UNION and why is it partially compatible
I am trying to understand how a OUTER UNION $∪^✳$ works, and why it is only partially compatible.
I am aware this operation was created to take union of tuples from two relations if the relation are not type compatible (which I…
orange
- 197
- 1
- 1
- 10
4
votes
1 answer
NL and NP compute different binary relations, so what?
Let the binary relation computed by a nondeterministic transducer be the relation between input strings and the possible output strings the transducer can produce (and accept) for the given input string.
It is easy to see that the nondeterministic…
Thomas Klimpel
- 5,440
- 29
- 69
4
votes
2 answers
"At least one" clause in Relational Algebra
I'm fairly new to the syntax of relational algebra, and I'm having a hard time understanding how I could set a "at least one" clause.
Example: I have:
a table with books (listing the title, year published and ID),
a table with authors (listing…
Balaam
- 143
- 1
- 1
- 5
4
votes
1 answer
Computing number of block reads given relational algebra statement
So I'm just starting to learn about query processing and such in databases and I'm having some trouble. I don't really understand how to compute the minimum number of block reads given a relation and a query I guess you could say. If anyone could…
user7233
4
votes
1 answer
Origin of theta-joins
I've taken an introductory database course where like many good database courses, they taught relational algebra, including $\theta$-joins. However, I've recently read E. F. Codd's 1970 paper, A Relational Model of Data for Large Shared Databanks,…
DPenner1
- 143
- 4
3
votes
0 answers
Algorithm for segmenting input query into query/join tree
Wondering what algorithms look like for implementing a complex JOIN query handler. Taking a look at this paper Building Query Compilers they talk about Query Graphs and Join Trees and Cost Functions for determining how well join trees are when the…
Lance Pollard
- 2,323
- 1
- 19
- 34