OK, so this is a bit of a rant, the write ups to this point have all conflated (I love it when I get to use that word) relational algebra with relational databases. It's surely true that a very common use for relational algebra is in database theory, but they're so much more than that.
This explanation could get technical but, bear with me and I'll keep it as simple as possible, but no simpler (thanks Einstein). So what is relational algebra? It's an algebra (I'll use the first reference there as it's good enough) for relations. I'll restate here what I need, though.
An algebra is a set of things, with rules for putting things together in order to make meaningful sentences, and a set of transformation rules that transform sentences into other sentences. That's not really helpful, so let me try an example and focus on simple arithmetic. Let my set of things be all natural numbers and the plus operator. Also, let my rules for meaningful sentences be that a meaningful sentence is one of
This is pretty simple but good enough to illustrate the point, it means that "5" is a meaningful sentence, "2 + 2" is a meaningful sentence, but "+" and "2 2" are not meaningful sentences. Finally, a transformation rule (and I'll pick a really easy one):
- if n is a number, then n + 0 is n
What we see from the definition is that algebras are, really, very general. There's a wonderful paper out there "Simple Word Problems in Universal Algebras" by Knuth and Bendix which is anything but simple but it gives you a hint of just how far algebras can go.
A relation is a set of ordered pairs of things. All this means is that one thing can be connected to another thing by means of a relation. For example, if my relation is childOf then "(me, Mom)" and "(me, Dad)" are elements of the set defined by childOf. Ordering is important (Mom, me) would not be an element of childOf, but could be an element of a different relation called parentOf. Relations can have all sorts of properties that we use as short hand notations to express certain ideas. But the most general definition is as above. Oh, if you're worried about relations of 3 or more things I can nest my relations, so if I want 3 things to be related I can just write "(a, (b, c))" and if you just thought wait, that looks like an S-expression except for the use of comma instead of period, you'd be right; S-expressions represent a certain type of relation. But there are also other kinds of relations and, indeed, the transformation rules of an algebra form one or more relations.
At this point you can see that relations and algebras are really very general concepts. Certainly Codd's paper from 1970 defined one particular set of things, and relations between those things and, thus, defined a relational algebra. But there are other relational algebras out there. The first one that comes to my mind was an unnamed, I think, relational algebra that was created in order to provide formal semantics to the Z formal method. For various reasons, I needed to understand that relational algebra and ended up in a one day class where it was explained to me. I still have, and treasure, the materials and notes I took that day. This relational algebra is wonderfully expressive and based on a branch of mathematics known as category theory. That relational algebra is also incredibly deep and understanding it is no easy matter. All I want to add with respect to it is that I was told that its creator, when the project was over is reported to have said "That's enough of this practical stuff, I'm off to do some theory.
So, to finish my rant. Yes, relational algebras are often used in database theory, but they can be used for so much more.