Relational DB :Relation-type Algebra?

In summary: I think that in summary, relations are closed under composition, and it is just too time- and energy-consuming to follow this approach all the time.
  • #1
WWGD
Science Advisor
Gold Member
7,007
10,463
Hi, say we have entities A,B,C in a Relational Database. Is there a sort-of operational algebra that allows us to determine that if, say, A and B are in a many-many relation and B and C are in a 1-many relation, then A,C are in a certain relationship, i.e., a composition algebra between relations (whenever "composable", of course)? And, while we are at it, when are relations "composable" (in a formal way, ignoring semantic issues of whether the composition is meaningful) , meaning if A is related to B and B to C, can we say A is related to C? Any Mathematical Analogies more than welcome.
Thanks.
 
Technology news on Phys.org
  • #2
If it's any help, the set-theoretic definition of an SQL join of two tables is the subset of all elements of the Cartesian product of those two tables that satisfies the specified join condition.

If we consider each table ##T## to be a function ##f_T:\mathbb{N}\times col.names(T)\to U## where ##U## is the set of all possible values in all allowed data types, such that ##f(n,\alpha)## is the value in row ##n##, column ##\alpha## of table ##T## then we can write an inner join on column ##\alpha## of tables ##A## and ##B## as

$$InnerJoin(A,B,\alpha)=\{(a_i,b_j)\in A\times B\ |\ f_A(i,\alpha)=f_B(j,\alpha)\}$$

This is readily extendable to outer joins and other types of joins, and to joins of more than two tables.

It's not an algebraic construct yet, as no group or similar operation has been defined, but at least it gives a set-theoretic foundation on which one might be able to do so
 
  • Like
Likes WWGD
  • #3
You're talking about relational algebra i.e. basically operations on sets. So, in relational databases operations are operations on some kind of sets and we have the usual operations of projection, selection, join etc. If you don't know much about these, a good start is Wikipedia's page about Relational Algebra
 
  • #4
I think I understand them pretty well, but I don't see how referring every question to set operations clarifies things in here. Seems like understanding computer programs in terms of logical operators and switches.
 
Last edited:
  • #5
@QuantumQuest : Of course you are correct, it is just too time-consuming to try to answer things at the most fundamental level, however interesting and illuminating it often is to do so. Time limitations make this approach impractical , despite allowing for a solution.

And, I guess that at the end of the day, relations are closed under composition. I make an effort not to be a hack, but sometimes I just hope to get an answer that works even without fully understanding it. It is just too time- and energy- consuming to follow this approach all the time.

Thanks for your comments, though.
 

1. What is relational database?

A relational database is a type of database that organizes data into tables with rows and columns. These tables are then linked together by establishing relationships between them, allowing for efficient data retrieval and storage.

2. What is relation-type algebra?

Relation-type algebra is a type of mathematical algebra that is used to manipulate and query data in a relational database. It includes a set of operations that can be applied to relations, such as selection, projection, union, intersection, and join.

3. What are the benefits of using relation-type algebra?

Using relation-type algebra allows for a more logical and organized way of querying and manipulating data in a relational database. It also ensures data integrity and consistency by following set rules and operations.

4. Can relation-type algebra be used in other types of databases?

No, relation-type algebra is specifically designed for use in relational databases. Other types of databases, such as NoSQL databases, use different data models and query languages.

5. What are some common operations in relation-type algebra?

Some common operations in relation-type algebra include select, which allows for the retrieval of specific rows from a table based on certain conditions, and project, which allows for the selection of specific columns from a table.

Similar threads

  • Programming and Computer Science
Replies
6
Views
1K
  • Special and General Relativity
5
Replies
146
Views
6K
  • Programming and Computer Science
Replies
2
Views
2K
  • Topology and Analysis
Replies
9
Views
2K
Replies
2
Views
881
Replies
7
Views
1K
  • General Math
Replies
1
Views
1K
  • Special and General Relativity
Replies
12
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Special and General Relativity
Replies
1
Views
544
Back
Top